iScroll on ios doesn't work after upgrading to iScroll5
Asked Answered
T

1

11

I have a cordova app for ipad that uses iScroll to scroll among pages.
All worked fine until i upgraded to iScroll5. I changed my code, to use new constructor and parameters, but it still doesn't work. It simply doesn't scroll.
I don't know if i'm missing something obvious, but I cannot find an exaustive documentation about the upgrade.

This is an example of how I used it before (iScroll4):

var options = {hScroll:false, hScrollbar:false, snap:true, onScrollEnd: updatePages(), momentum: false};
var scroller = new iScroll("wrapper", options);  

And this is how I use it now (iScroll5):

var options = {scrollX: false, snap: true, momentum: false};  
var scroller = new IScroll("#wrapper", options);  
scroller.on("scrollEnd", updatePages());

Any help is greatly appreciated! Thanks!

Taunton answered 28/5, 2015 at 14:50 Comment(0)
H
1

So, first things first, in your "scrollEnd" event instead of passing the updatePages() function as a parmeter, you are calling it. So it will run only once, when the page is loaded not on scrollEnd. You should change it to:

scroller.on("scrollEnd", updatePages);

If that alone doesn't fix your problem, then you should propably check your CSS.

From iscroll.js documentation:

[...]remember that the script needs to know the height/width of the scrolling area.

That means:

  • If your #wrapper element is positioned relative or static then you should have explicitly defined height with some relative unit (% won't work).

  • If your #wrapper element is positioned absolute or fixed then you should either apply the rule above or you could use top and bottom instead (both must be specified).

If it still won't work, then make sure your IScroll object is initiated after the DOM is ready, but considering it worked for you before, this isn't the problem.

Haile answered 24/9, 2017 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.