Setting the initial page
snapToPage() you can decide which page should be visible when your prototype loads.
With the following line of code, the PageComponent will jump instantly to the eighth page:
# jump to the eighth page page.snapToPage page.content.children, no
The pages are children of the
content layer, so I passed ‘child layer with index nr. 7’ to
no argument makes it happen without animation.
snapToPage() function can take three arguments. The first argument is mandatory; the other two are optional:
- Which page to scroll to. (Has to be a layer object, using a number will not work.)
- Whether the transition should be animated. (Optional.
animationOptionsobject for overriding the default animation settings. (Optional)
The following line will have the PageComponent animate to the eighth page over 5 seconds.
# scroll to the eighth page page.snapToPage page.content.children, yes, animationOptions = time: 5