Nishant Mahajan
Nishant Mahajan

Reputation: 264

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...

Upvotes: 5

Views: 4781

Answers (2)

Amit Agrawal
Amit Agrawal

Reputation: 39

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

Upvotes: 2

Melvin Joseph Mani
Melvin Joseph Mani

Reputation: 1496

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.

Upvotes: 2

Related Questions