scroll.scrollToLayer(layer, originX, originY, animate, animationOptions)

Scroll to a specific layer. You can only scroll to layers that are children of the scroll.content layer.
译:滚动到一个特定的层。你只能滚动scroll.content层的子层。

Arguments(参数)
  1. layer — A layer object. 译:层对象。
  2. originX — A number between 0 and 1. (Optional) 译:介于0和1之间的数字。(可选)
  3. originY — A number between 0 and 1. (Optional) 译:介于0和1之间的数字。(可选)
  4. animate — A boolean, set to true by default. (Optional) 译: 一个布尔值,默认设置为真。(可选)
  5. animationOptions — An object with curve, time, delay and repeat properties. (Optional) 译:具有曲线、时间、延迟和重复特性的对象。(可选)
# Create ScrollComponent 
scroll = new ScrollComponent
    width: 500
    height: 500

# Define Background 
layerA = new Layer
    x: 500
    y: 1000
    image: "bg.png"
    parent: scroll.content

# Scroll to this layer 
scrollerA = new Layer
    parent: scroll.content

scroll.scrollToLayer(scrollerA)

The originX and originY arguments define the point within the layer that will be scrolled to. The default values are 0,0 - which is the top-left corner.
译:该originX和originY参数在层内,将滚动到定义点。默认值是00,这是左上角。

scroll.scrollToLayer(
    layerA
    0.5, 0
    true
    time: 2
)

results matching ""

    No results matching ""