new Animation(func [, layers])
Animation constructor.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
func |
AnimationFn | function executed on each animation frame. The function is passed a frame object, which contains |
|
layers |
Konva.Layer | Array |
<optional> |
layer(s) to be redrawn on each animation frame. Can be a layer, an array of layers, or null. |
- Source:
- konva.js
Example
// move a node to the right at 50 pixels / second var velocity = 50; var anim = new Konva.Animation(function(frame) { var dist = velocity * (frame.timeDiff / 1000); node.move({x: dist, y: 0}); }, layer); anim.start();
Methods
-
addLayer(layer)
-
add layer. Returns true if the layer was added, and false if it was not
Parameters:
Name Type Description layer
Konva.Layer to add
- Source:
- konva.js
Returns:
true if layer is added to animation, otherwise false
- Type
- Bool
-
getLayers()
-
get layers
- Source:
- konva.js
Returns:
Array of Konva.Layer
- Type
- Array
-
isRunning()
-
determine if animation is running or not. returns true or false
- Source:
- konva.js
Returns:
is animation running?
- Type
- Bool
-
setLayers( [layers])
-
set layers to be redrawn on each animation frame
Parameters:
Name Type Argument Description layers
Konva.Layer | Array <optional>
layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
- Source:
- konva.js
Returns:
this
- Type
- Konva.Animation
-
start()
-
start animation
- Source:
- konva.js
Returns:
this
- Type
- Konva.Animation
-
stop()
-
stop animation
- Source:
- konva.js
Returns:
this
- Type
- Konva.Animation