Here is an example that will only scroll a panel to its top position.
Note: there is some quirk that I have not figured out yet that prevents this example and the api in use from providing universal panel positioning. So only use it to scroll to the top of a a panel.
Step-1: create your design with a panel and set its properties as follows
– enable vertical scrollbar
– increase the content area height property to a large value so the panel will scroll
Step-2: generate code and inspect to find the panel’s scrollbar ID
See attachment scroll-to-top.png
Step-3: add widget that when selected can fire an On Change – Run JavaScript action, e.g., button or link widget
– Use the snippet of code shown below with the #m1-GotoTop- id changed to the id you discover when you look it up the generated HTML file
$('#m1-GotoTop-')[0].myScroll.scrollTo(0,0,"500ms")
See attachment scroll-to-top-1.png
Step-4: save file and run in Test Center or on your device
Here is the .mobi design file used in this example. The button that initiates scrolling is at the bottom of the panel and offscreen. You can scroll the panel in the designer by selecting it and then hover your mouse over the right side scroller that appears. Then click and drag the scroller when it highlights as you fly over it.
Open it in the Design Center and click the Run in Test Center action.
See attachment GotoTop.mobi
Attachments:
You must be
logged in to view attached files.