page.snapToPage(page, animate, animationOptions)
Snap to a specific page. Takes three arguments: a page.content layer, animate (true or false) and animation options. By default, animate is set to true and the animationCurve use a spring curve.
译:捕捉到一个特定的页面。需要三个参数:一个page.content层、动画(true or false)和动画选项。默认情况下,动画设置为true,AnimationCurve使用弹簧曲线。
page = new PageComponent
width: Screen.width
height: Screen.height
pageOne = new Layer
width: page.width
height: page.height
parent: page.content
backgroundColor: "#28affa"
pageTwo = new Layer
width: page.width
height: page.height
backgroundColor: "#90D7FF"
page.addPage(pageTwo, "right")
# Automatically scroll to pageTwo
page.snapToPage( pageTwo)
In the example above, we can customize the scrolling animation by defining custom animationOptions as well.
译:在上面的例子中,我们可以通过定义自定义animationoptions以及自定义滚动动画。
# Define a slower easing curve
page.snapToPage(
pageTwo
true
animationOptions = curve: "ease", time: 2)