简体   繁体   中英

iScroll no animation using scrolltoelement on iOs phonegap app

I am working on a iOs phonegap app. It is built with the help of backbone and some other library's. For scrolling i used 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).

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.

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. ex. 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. 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. Also check to make sure $("#firstrow") exists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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