mirror of
https://github.com/konvajs/konva.git
synced 2026-01-09 11:34:38 +08:00
Merge branch 'master' of github.com:konvajs/konva
This commit is contained in:
@@ -249,13 +249,13 @@ export abstract class BaseLayer extends Container {
|
|||||||
* @return {Konva.Layer} this
|
* @return {Konva.Layer} this
|
||||||
*/
|
*/
|
||||||
batchDraw() {
|
batchDraw() {
|
||||||
if (this._waitingForDraw) {
|
if (!this._waitingForDraw) {
|
||||||
return;
|
this._waitingForDraw = true;
|
||||||
|
Util.requestAnimFrame(() => {
|
||||||
|
this.draw();
|
||||||
|
this._waitingForDraw = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
Util.requestAnimFrame(() => {
|
|
||||||
this._waitingForDraw = false;
|
|
||||||
this.draw();
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export abstract class Container extends Node {
|
|||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
child = children[i];
|
child = children[i];
|
||||||
// reset parent to prevent many _setChildrenIndices calls
|
// reset parent to prevent many _setChildrenIndices calls
|
||||||
delete child.parent;
|
child.parent = null;
|
||||||
child.index = 0;
|
child.index = 0;
|
||||||
child.remove();
|
child.remove();
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ export abstract class Container extends Node {
|
|||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
child = children[i];
|
child = children[i];
|
||||||
// reset parent to prevent many _setChildrenIndices calls
|
// reset parent to prevent many _setChildrenIndices calls
|
||||||
delete child.parent;
|
child.parent = null;
|
||||||
child.index = 0;
|
child.index = 0;
|
||||||
child.destroy();
|
child.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -719,7 +719,7 @@ export abstract class Node {
|
|||||||
if (parent && parent.children) {
|
if (parent && parent.children) {
|
||||||
parent.children.splice(this.index, 1);
|
parent.children.splice(this.index, 1);
|
||||||
parent._setChildrenIndices();
|
parent._setChildrenIndices();
|
||||||
delete this.parent;
|
this.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// every cached attr that is calculated via node tree
|
// every cached attr that is calculated via node tree
|
||||||
|
|||||||
16
src/Util.ts
16
src/Util.ts
@@ -542,20 +542,16 @@ export const Util = {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_waiting: false,
|
|
||||||
animQueue: [],
|
animQueue: [],
|
||||||
requestAnimFrame(callback) {
|
requestAnimFrame(callback) {
|
||||||
Util.animQueue.push(callback);
|
Util.animQueue.push(callback);
|
||||||
if (Util._waiting) {
|
if (Util.animQueue.length === 1) {
|
||||||
return;
|
requestAnimationFrame(function () {
|
||||||
}
|
const queue = Util.animQueue;
|
||||||
requestAnimationFrame(() => {
|
Util.animQueue = [];
|
||||||
Util.animQueue.forEach(cb => {
|
queue.forEach(function (cb) { cb(); });
|
||||||
cb();
|
|
||||||
});
|
});
|
||||||
Util.animQueue = [];
|
}
|
||||||
Util._waiting = false;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
createCanvasElement() {
|
createCanvasElement() {
|
||||||
var canvas = isBrowser
|
var canvas = isBrowser
|
||||||
|
|||||||
Reference in New Issue
Block a user