Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iScroll 4 not working properly

I have downloaded iScroll.js and used in one of my phonegap project i.e.

<script type="application/javascript" src="iscroll.js"></script>
<script type="text/javascript">
var myScroll;
function loaded() {
myScroll = new iScroll('wrapper');
}
document.addEventListener('DOMContentLoaded', loaded, false);
</script>

It doesn't work on normal browsers too but when i inspect elements it started working absolutely fine?? don't know what the problem is...

like image 586
Nishant Mahajan Avatar asked Oct 08 '22 06:10

Nishant Mahajan


2 Answers

don't define the height and width to inner div where content exists. and create object iScroll after content is dynamically rendered completely.

like image 44
Amit Agrawal Avatar answered Oct 23 '22 04:10

Amit Agrawal


How to use iScroll

1) Need to prevent the default behavior of standard touch events. Easy to do this, by adding preventDefault() in your touchmove event.

2) Initialize the iScroll object on DOMContentLoaded or on window load.

Change your code to,

    function loaded() {
        document.addEventListener('touchmove', function(e){ e.preventDefault(); });
        myScroll = new iScroll('wrapper');
}
document.addEventListener('DOMContentLoaded', loaded, false);

Hope it helped.

like image 155
Melvin Joseph Mani Avatar answered Oct 23 '22 04:10

Melvin Joseph Mani