Events

Events are things that you can listen for. They can originate from the user, like a touch or click, or from an animation that ends. Most objects support event listening in Framer, but you will most often listen for events on layers.
When an event is called, the first argument is the event information. Depending on the event, this can contain mouse positions, mouse deltas etc. The second argument is always the layer that the event occurred to.
To listen for an event, you can use the on function:
事件是你能聆听的东西。它们可以来自用户,像一个触摸或点击,或从一个动画,结束。大多数对象支持事件监听者,但你会经常听取事件层。当一个事件被调用时,第一个参数是事件信息。根据不同的事件,这可以包含鼠标的位置,鼠标三角洲等二总是层发生。要听一个事件,你可以使用函数:

layerA = new Layer
layerA.name = "Layer A"

layerA.on Events.Click, (event, layer) ->
    print "Clicked", layer.name

# Output: "Clicked", "Layer A"

To stop listening for an event, you can use the off function:
译:停止听一个事件,你可以使用“0ff”功能:

layerA = new Layer
layerA.name = "Layer A"

clickHandler = (event, layer) ->
    print "Clicked", layer.name

layerA.on(Events.Click, clickHandler)
layerA.off(Events.Click, clickHandler)

results matching ""

    No results matching ""