From cc7c6edd1f9b9a936104d95e03ed4f598b1c15a1 Mon Sep 17 00:00:00 2001 From: Anton Lavrenov Date: Wed, 12 Aug 2020 14:15:57 -0500 Subject: [PATCH] some fixes --- src/Node.ts | 52 ++++++++++++++++++-------------------------- src/Tween.ts | 11 ++++++++-- src/index-types.d.ts | 1 + 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/src/Node.ts b/src/Node.ts index b7ddd66f..2c627fdd 100644 --- a/src/Node.ts +++ b/src/Node.ts @@ -405,10 +405,10 @@ export abstract class Node { y -= offset; var cachedSceneCanvas = new SceneCanvas({ - pixelRatio: pixelRatio, - width: width, - height: height, - }), + pixelRatio: pixelRatio, + width: width, + height: height, + }), cachedFilterCanvas = new SceneCanvas({ pixelRatio: pixelRatio, width: 0, @@ -632,8 +632,8 @@ export abstract class Node { if (typeof filter !== 'function') { Util.error( 'Filter should be type of function, but got ' + - typeof filter + - ' instead. Please check correct filters' + typeof filter + + ' instead. Please check correct filters' ); continue; } @@ -643,8 +643,8 @@ export abstract class Node { } catch (e) { Util.error( 'Unable to apply filter. ' + - e.message + - ' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.' + e.message + + ' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.' ); } @@ -1414,10 +1414,10 @@ export abstract class Node { if (zIndex < 0 || zIndex >= this.parent.children.length) { Util.warn( 'Unexpected value ' + - zIndex + - ' for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to ' + - (this.parent.children.length - 1) + - '.' + zIndex + + ' for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to ' + + (this.parent.children.length - 1) + + '.' ); } var index = this.index; @@ -1585,8 +1585,8 @@ export abstract class Node { if (!Util.isValidSelector(sel)) { Util.warn( 'Selector "' + - sel + - '" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".' + sel + + '" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".' ); Util.warn( 'If you have a custom shape with such className, please change it to start with upper letter like "Triangle".' @@ -2544,7 +2544,7 @@ export abstract class Node { skewX: GetSet; skewY: GetSet; - to: (params: animOptions) => void; + to: (params: AnimTo) => void; transformsEnabled: GetSet; @@ -2591,8 +2591,8 @@ export abstract class Node { if (!_NODES_REGISTRY[className]) { Util.warn( 'Can not find a node with class name "' + - className + - '". Fallback to "Shape".' + className + + '". Fallback to "Shape".' ); className = 'Shape'; } @@ -2611,20 +2611,10 @@ export abstract class Node { } } -interface animOptions { - x?: number - y?: number; - height?: number; - width?: number; - skewX?: number; - skewY?: number; - scaleY?: number; - scaleX?: number; - rotation?: number; - opacity?: number; - offsetY?: number; - offsetX?: number; - brightness?: number; +interface AnimTo extends NodeConfig { + onFinish?: Function; + onUpdate?: Function; + duration?: number; } Node.prototype.nodeType = 'Node'; diff --git a/src/Tween.ts b/src/Tween.ts index 08cf147e..16f68dbe 100644 --- a/src/Tween.ts +++ b/src/Tween.ts @@ -1,6 +1,6 @@ import { Util } from './Util'; import { Animation } from './Animation'; -import { Node } from './Node'; +import { Node, NodeConfig } from './Node'; import { Konva } from './Global'; 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. * 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; onUpdate: Function; - constructor(config) { + constructor(config: TweenConfig) { var that = this, node = config.node, nodeId = node._id, diff --git a/src/index-types.d.ts b/src/index-types.d.ts index 6f7e9043..f6bdfc50 100644 --- a/src/index-types.d.ts +++ b/src/index-types.d.ts @@ -93,6 +93,7 @@ declare namespace Konva { export const Tween: typeof import('./Tween').Tween; export type Tween = import('./Tween').Tween; + export type TweenConfig = import('./Tween').TweenConfig; export const Easings: typeof import('./Tween').Easings; export const Arc: typeof import('./shapes/Arc').Arc;