简体   繁体   English

升级到iScroll5后,iScroll on ios不起作用

[英]iScroll on ios doesn't work after upgrading to iScroll5

I have a cordova app for ipad that uses iScroll to scroll among pages. 我有一个用于ipad的cordova应用程序,它使用iScroll在页面之间滚动。
All worked fine until i upgraded to iScroll5. 一切正常,直到我升级到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): 这是我之前使用它的一个例子(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): 这就是我现在使用它的方式(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! 谢谢!

So, first things first, in your "scrollEnd" event instead of passing the updatePages() function as a parmeter, you are calling it. 首先,首先,在您的“scrollEnd”事件中,而不是将updatePages()函数作为参数传递,您正在调用它。 So it will run only once, when the page is loaded not on scrollEnd. 因此,当页面加载不在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. 如果仅靠这一点无法解决您的问题,那么您应该检查您的CSS。

From iscroll.js documentation: 来自iscroll.js文档:

[...]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). 如果你的#wrapper元素是相对的或静态的,那么你应该用一些相对单位明确定义高度(%不起作用)。

  • 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). 如果您的#wrapper元素位于绝对位置或固定位置,那么您应该应用上面的规则,或者您可以使用topbottom (两者都必须指定)。

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. 如果它仍然无法工作,那么确保在DOM准备好后启动你的IScroll对象,但考虑到它之前适用于你,这不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM