mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
performance update
This commit is contained in:
parent
47870c9c68
commit
ca1ccdaf82
11
package.json
11
package.json
@ -40,16 +40,15 @@
|
||||
"gulp-typescript": "^5.0.1",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"gulp-util": "^3.0.8",
|
||||
"mocha": "6.2.1",
|
||||
"mocha": "6.2.2",
|
||||
"mocha-headless-chrome": "^2.0.3",
|
||||
"parcel-bundler": "^1.12.3",
|
||||
"prettier": "^1.18.2",
|
||||
"rollup": "^1.23.0",
|
||||
"prettier": "^1.19.1",
|
||||
"rollup": "^1.27.0",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
||||
"rollup-plugin-typescript2": "^0.24.3",
|
||||
"typescript": "^3.6.3"
|
||||
"rollup-plugin-typescript2": "^0.25.2",
|
||||
"typescript": "^3.7.2"
|
||||
},
|
||||
"keywords": [
|
||||
"canvas",
|
||||
|
42
src/Node.ts
42
src/Node.ts
@ -1675,22 +1675,44 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
||||
}
|
||||
}
|
||||
_getAbsoluteTransform(top?: Node) {
|
||||
var at = new Transform();
|
||||
|
||||
// start with stage and traverse downwards to self
|
||||
this._eachAncestorReverse(function(node) {
|
||||
var transformsEnabled = node.getTransformsEnabled();
|
||||
|
||||
var at;
|
||||
// we we need position relative to an ancestor, we will iterate for all
|
||||
if (top) {
|
||||
at = new Transform();
|
||||
// start with stage and traverse downwards to self
|
||||
this._eachAncestorReverse(function(node: Node) {
|
||||
var transformsEnabled = node.transformsEnabled();
|
||||
|
||||
if (transformsEnabled === 'all') {
|
||||
at.multiply(node.getTransform());
|
||||
} else if (transformsEnabled === 'position') {
|
||||
at.translate(
|
||||
node.x() - node.offsetX(),
|
||||
node.y() - node.offsetY()
|
||||
);
|
||||
}
|
||||
}, top);
|
||||
return at;
|
||||
} else {
|
||||
// try to use a cached value
|
||||
if (this.parent) {
|
||||
// transform will be cached
|
||||
at = this.parent.getAbsoluteTransform().copy();
|
||||
} else {
|
||||
at = new Transform();
|
||||
}
|
||||
var transformsEnabled = this.transformsEnabled();
|
||||
if (transformsEnabled === 'all') {
|
||||
at.multiply(node.getTransform());
|
||||
at.multiply(this.getTransform());
|
||||
} else if (transformsEnabled === 'position') {
|
||||
at.translate(
|
||||
node.getX() - node.getOffsetX(),
|
||||
node.getY() - node.getOffsetY()
|
||||
this.x() - this.offsetX(),
|
||||
this.y() - this.offsetY()
|
||||
);
|
||||
}
|
||||
}, top);
|
||||
return at;
|
||||
return at;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* get absolute scale of the node which takes into
|
||||
|
@ -28,7 +28,7 @@
|
||||
var maxY = height - 10;
|
||||
var minY = 0;
|
||||
|
||||
var startBunnyCount = 10;
|
||||
var startBunnyCount = 1000;
|
||||
var isAdding = false;
|
||||
var count = 0;
|
||||
var container;
|
||||
@ -98,8 +98,9 @@
|
||||
bunnys.push(bunny);
|
||||
layer.add(bunny);
|
||||
|
||||
layer.draw();
|
||||
|
||||
}
|
||||
layer.draw();
|
||||
}
|
||||
|
||||
function onTouchStart(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user