简体   繁体   English

在iOs phonegap应用程序上使用scrolltoelement不会滚动iAnim

[英]iScroll no animation using scrolltoelement on iOs phonegap app

I am working on a iOs phonegap app. 我正在使用iOs phonegap应用程序。 It is built with the help of backbone and some other library's. 它是在骨干网和其他一些图书馆的帮助下构建的。 For scrolling i used iScroll. 对于滚动,我使用了iScroll。 Which is working fine, but ive got a problem with the following. 哪个工作正常,但我在以下方面遇到了问题。

events: {
    'click a.navigate-right' : 'setPos',
    'click li.table-view-divider' : 'accordion',
    'click .scroll-down' : 'scrolldown'
},

scrolldown: function(e){
    App.homeView.iscroll.scrollToElement("#firstrow", 1000, 0, -41);
},

This is not working. 这是行不通的。

But when i place the exact same line in the safari dev console (iphone device attached). 但是,当我将完全相同的行放在safari开发控制台(连接iphone设备)中时。

App.homeView.iscroll.scrollToElement("#firstrow", 1000, 0, -41);

It is working like a charm. 它像魅力一样运作。 Anyone else has these problems too?! 还有其他人有这些问题吗? I checked if the variables/objects existed with console.log() in the event handler and they did. 我检查了事件处理程序中console.log()是否存在变量/对象,并且确实存在。

Thanks in advance 提前致谢

Unable to reproduce. 无法复制。 Works fine for me in a prototyped setup. 在原型设置中对我来说效果很好。 Must be one of two things: something doesn't exist when event handler is called, or event handler isn't actually binded to correct button. 必须是以下两件事之一:调用事件处理程序时不存在某些内容,或者实际上未将事件处理程序绑定到正确的按钮。 Here's how you can test, unless you want to put whole code somewhere I can step through myself: 测试的方法如下,除非您要将整个代码放在我可以自己解决的地方:

  1. Test to see if event handler is binded to '.scroll-down' button: From console, try to call the method scrolldown. 测试以查看事件处理程序是否绑定到“ .scroll-down”按钮:从控制台,尝试调用方法向下滚动。 ex. 例如 ThatView.scrolldown(); ThatView.scrolldown(); If it works as expected, then the problem is that the event handler is not binded to the button. 如果按预期方式工作,则问题在于事件处理程序未绑定到按钮。 If it doesn't work, add an alert or console.log into scrolldown method, and see if that fires on button press. 如果它不起作用,则将警报或console.log添加到向下滚动方法中,并查看是否在按下按钮时触发该事件。 If it doesn't, its definitely event binding problem. 如果没有,那肯定是事件绑定问题。

  2. Test to see if App.homeView.iscroll.scrollToElement exists, and that "#firstrow" exists when method is called: Place a breakpoint in your code inside the scrolldown method, click on button, and check to see that App.homeView.iscroll.scrollToElement exists. 测试以查看是否存在App.homeView.iscroll.scrollToElement以及在调用方法时是否存在“ #firstrow”:在代码中的一个downdown方法中放置一个断点,单击按钮,然后检查一下App.homeView.iscroll .scrollToElement存在。 Also check to make sure $("#firstrow") exists. 还要检查以确保$(“#firstrow”)存在。

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

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