scroll.wrap(layer)
Wraps a layer within a new ScrollComponent. This is useful to create scrollable layers out of imported layers.
译:在一个新的scrollcomponent裹一层。这是从导入层创建滚动层有用。
# Import files from Sketch
sketch = Framer.Importer.load "imported/Scrollable"
# Wrap the "content" layer group
scroll = ScrollComponent.wrap(sketch.content)
Now, scroll is the variable name of the ScrollComponent. This also automatically wraps your layer within a ScrollContent layer, which you can select to adjust certain properties like momentum, overdrag or bounce.
译:现在,scroll是ScrollComponent的变量名。这也将自动换一个ScrollContent层,可以选择调整某些动量属性,overdrag或反弹。
# Import files from Sketch
sketch = Framer.Importer.load "imported/Scrollable"
# Wrap the "content" layer group
scroll = ScrollComponent.wrap(sketch.content)
# Change scroll properties
scroll.scrollHorizontal = false
scroll.speedY = 0.5
# Change scroll.content properties
scroll.content.draggable.momentum = true
scroll.content.draggable.overdrag = false
scroll.content.draggable.bounce = false