triceam / app-UI

app-UI is a collection of user interface components that may be helpful to web and mobile developers for creating interactive applications using HTML and JavaScript, especially those targeting mobile devices. app-UI is a continual work in progress - it was born out of the necessity to have rich & native-feeling interfaces in HTML/JS experiences, and it works great with PhoneGap applications (http://www.phonegap.com). app-UI can easily be styled/customized using CSS.
http://triceam.github.com/app-UI/
Other
1.27k stars 239 forks source link

Using scrollToElement in App-UI #47

Closed makkart closed 11 years ago

makkart commented 11 years ago

Hi,

First of all, thank you for App-UI! It´s lightweight, fast and amazing.

I have a long list divided in alphabetical order with a header for each letter. I have button for each letter on the top and want to scroll to the header when the button is pressed for each letter. I cant get this to work. I first tried with anchor-tags but that messed up the page badly. I have read Cubics iScroll-documentation and tried all tips I could find on google, no luck..

Im sure its not that hard but then again im still learning. Any tips on how to do this?

Thanks in advance.

makkart commented 11 years ago

I really need help with this one. I cant figure out how to call the iScroll that is setup by App-UI. And if i make a new iScroll and call scrollToElement on that, sure I get the scrolling going by then I have two iScrolls on top of each other and that is messing up the regular scrolling. All I need to know is what to put "here".scrollToElement('#'+id, 100); What element is the iScroll connected to? I just cant find it.

Thanks.

makkart commented 11 years ago

Alright, so I figured it out. Almost drove me crazy but I did it. It was not that hard so im feeling a bit stupid.

If your are using slidingview you call the scroller with: window.rightViewNavigator.scroller or window.leftViewNavigator.scroller

If you have a single viewnavigator it´s window.viewNavigator.scroller

So it goes like window.rightViewNavigator.scroller.scrollToElement('#'+id, 100);

This might help someone.. I hope =)

Closing this one also.