Merge branch 'risingBirdSong-addAnimationOptionInterface' into master

This commit is contained in:
Anton Lavrenov
2020-08-12 14:16:11 -05:00
3 changed files with 17 additions and 3 deletions

View File

@@ -2544,7 +2544,7 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
skewX: GetSet<number, this>; skewX: GetSet<number, this>;
skewY: GetSet<number, this>; skewY: GetSet<number, this>;
to: (params: any) => void; to: (params: AnimTo) => void;
transformsEnabled: GetSet<string, this>; transformsEnabled: GetSet<string, this>;
@@ -2611,6 +2611,12 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
} }
} }
interface AnimTo extends NodeConfig {
onFinish?: Function;
onUpdate?: Function;
duration?: number;
}
Node.prototype.nodeType = 'Node'; Node.prototype.nodeType = 'Node';
Node.prototype._attrsAffectingSize = []; Node.prototype._attrsAffectingSize = [];

View File

@@ -1,6 +1,6 @@
import { Util } from './Util'; import { Util } from './Util';
import { Animation } from './Animation'; import { Animation } from './Animation';
import { Node } from './Node'; import { Node, NodeConfig } from './Node';
import { Konva } from './Global'; import { Konva } from './Global';
import { Line } from './shapes/Line'; import { Line } from './shapes/Line';
@@ -149,6 +149,13 @@ class TweenEngine {
} }
} }
export interface TweenConfig extends NodeConfig {
onFinish?: Function;
onUpdate?: Function;
duration?: number;
node: Node;
}
/** /**
* Tween constructor. Tweens enable you to animate a node between the current state and a new state. * Tween constructor. Tweens enable you to animate a node between the current state and a new state.
* You can play, pause, reverse, seek, reset, and finish tweens. By default, tweens are animated using * You can play, pause, reverse, seek, reset, and finish tweens. By default, tweens are animated using
@@ -187,7 +194,7 @@ export class Tween {
onReset: Function; onReset: Function;
onUpdate: Function; onUpdate: Function;
constructor(config) { constructor(config: TweenConfig) {
var that = this, var that = this,
node = config.node, node = config.node,
nodeId = node._id, nodeId = node._id,

View File

@@ -93,6 +93,7 @@ declare namespace Konva {
export const Tween: typeof import('./Tween').Tween; export const Tween: typeof import('./Tween').Tween;
export type Tween = import('./Tween').Tween; export type Tween = import('./Tween').Tween;
export type TweenConfig = import('./Tween').TweenConfig;
export const Easings: typeof import('./Tween').Easings; export const Easings: typeof import('./Tween').Easings;
export const Arc: typeof import('./shapes/Arc').Arc; export const Arc: typeof import('./shapes/Arc').Arc;