mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
some fixes
This commit is contained in:
52
src/Node.ts
52
src/Node.ts
@@ -405,10 +405,10 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
y -= offset;
|
y -= offset;
|
||||||
|
|
||||||
var cachedSceneCanvas = new SceneCanvas({
|
var cachedSceneCanvas = new SceneCanvas({
|
||||||
pixelRatio: pixelRatio,
|
pixelRatio: pixelRatio,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
}),
|
}),
|
||||||
cachedFilterCanvas = new SceneCanvas({
|
cachedFilterCanvas = new SceneCanvas({
|
||||||
pixelRatio: pixelRatio,
|
pixelRatio: pixelRatio,
|
||||||
width: 0,
|
width: 0,
|
||||||
@@ -632,8 +632,8 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
if (typeof filter !== 'function') {
|
if (typeof filter !== 'function') {
|
||||||
Util.error(
|
Util.error(
|
||||||
'Filter should be type of function, but got ' +
|
'Filter should be type of function, but got ' +
|
||||||
typeof filter +
|
typeof filter +
|
||||||
' instead. Please check correct filters'
|
' instead. Please check correct filters'
|
||||||
);
|
);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -643,8 +643,8 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
Util.error(
|
Util.error(
|
||||||
'Unable to apply filter. ' +
|
'Unable to apply filter. ' +
|
||||||
e.message +
|
e.message +
|
||||||
' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.'
|
' This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1414,10 +1414,10 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
if (zIndex < 0 || zIndex >= this.parent.children.length) {
|
if (zIndex < 0 || zIndex >= this.parent.children.length) {
|
||||||
Util.warn(
|
Util.warn(
|
||||||
'Unexpected value ' +
|
'Unexpected value ' +
|
||||||
zIndex +
|
zIndex +
|
||||||
' for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to ' +
|
' 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) +
|
(this.parent.children.length - 1) +
|
||||||
'.'
|
'.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@@ -1585,8 +1585,8 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
if (!Util.isValidSelector(sel)) {
|
if (!Util.isValidSelector(sel)) {
|
||||||
Util.warn(
|
Util.warn(
|
||||||
'Selector "' +
|
'Selector "' +
|
||||||
sel +
|
sel +
|
||||||
'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'
|
'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'
|
||||||
);
|
);
|
||||||
Util.warn(
|
Util.warn(
|
||||||
'If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'
|
'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<Config extends NodeConfig = NodeConfig> {
|
|||||||
skewX: GetSet<number, this>;
|
skewX: GetSet<number, this>;
|
||||||
skewY: GetSet<number, this>;
|
skewY: GetSet<number, this>;
|
||||||
|
|
||||||
to: (params: animOptions) => void;
|
to: (params: AnimTo) => void;
|
||||||
|
|
||||||
transformsEnabled: GetSet<string, this>;
|
transformsEnabled: GetSet<string, this>;
|
||||||
|
|
||||||
@@ -2591,8 +2591,8 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
if (!_NODES_REGISTRY[className]) {
|
if (!_NODES_REGISTRY[className]) {
|
||||||
Util.warn(
|
Util.warn(
|
||||||
'Can not find a node with class name "' +
|
'Can not find a node with class name "' +
|
||||||
className +
|
className +
|
||||||
'". Fallback to "Shape".'
|
'". Fallback to "Shape".'
|
||||||
);
|
);
|
||||||
className = 'Shape';
|
className = 'Shape';
|
||||||
}
|
}
|
||||||
@@ -2611,20 +2611,10 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface animOptions {
|
interface AnimTo extends NodeConfig {
|
||||||
x?: number
|
onFinish?: Function;
|
||||||
y?: number;
|
onUpdate?: Function;
|
||||||
height?: number;
|
duration?: number;
|
||||||
width?: number;
|
|
||||||
skewX?: number;
|
|
||||||
skewY?: number;
|
|
||||||
scaleY?: number;
|
|
||||||
scaleX?: number;
|
|
||||||
rotation?: number;
|
|
||||||
opacity?: number;
|
|
||||||
offsetY?: number;
|
|
||||||
offsetX?: number;
|
|
||||||
brightness?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Node.prototype.nodeType = 'Node';
|
Node.prototype.nodeType = 'Node';
|
||||||
|
11
src/Tween.ts
11
src/Tween.ts
@@ -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,
|
||||||
|
1
src/index-types.d.ts
vendored
1
src/index-types.d.ts
vendored
@@ -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;
|
||||||
|
Reference in New Issue
Block a user