androidcordovaiscroll4

iScroll4 with long list not response on Samsung galaxy2 and 3


I have a PhoneGap application with iScroll4, its basically iScroll example with 2000 list items.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>iScroll demo: iOS Perfect Scrollbar</title>

<link rel="stylesheet" type="text/css" href="css/general.css">
<link rel="stylesheet" type="text/css" href="css/scrollbar.css">

<script src="js/jquery-1.7.1.js"></script>
<script src="js/iscroll.js"></script>
<script src="js/alldata.js"></script>

<script type="text/javascript">

var myScroll;
function loaded() {
    myScroll = new iScroll('wrapper', 
    { 
        scrollbarClass: 'myScrollbar',
        hideScrollbar:false,
        /*onBeforeScrollStart: function (e) { return false; }*/
    });
}

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

document.addEventListener('DOMContentLoaded', loaded, false);

</script>

<script>
    function initList(){
        for(var i=0; i<allData.length; i++){
            var line = "<li style='color:#"+ allData[i].Color + ";'>" + allData[i].EventName + "</li>"
            $("#thelist").append(line);
        }
    }

    $(document).ready(function(){
        initList();
        initList();
        initList();
        initList();
        //alert("Finished!");
    });
</script>

</head>
<body>
<div id="header"><a href="http://cubiq.org/iscroll">iScroll</a></div>
<div id="wrapper">
    <div id="scroller">
        <ul id="thelist">
        </ul>
    </div>
</div>

<div id="footer"></div>

</body>
</html>

Note: the variable allData is a JSON array with 500 objects.
EDITED: It works fine on Motorola Atrix (2.3.3) and on Galaxy 3,
But it doesn't move on Galaxy 2 (4.2.2) and Galaxy3 after 1000 list items, strange Motorola Atrix is has lower Android version and it's web-toolkit is slower

Is there any way to resolve that problem?


Solution

  • After the data is loaded you just need to refresh the list.

    function initList(){
            for(var i=0; i<allData.length; i++){
                var line = "<li style='color:#"+ allData[i].Color + ";'>" + allData[i].EventName + "</li>"
                $("#thelist").append(line);
            }
    
            myScroll.refresh();
        }