Merge branch 'master' of github.com:konvajs/konva

This commit is contained in:
Anton Lavrenov
2019-02-05 16:43:57 -05:00
4 changed files with 15 additions and 19 deletions

View File

@@ -249,13 +249,13 @@ export abstract class BaseLayer extends Container {
* @return {Konva.Layer} this
*/
batchDraw() {
if (this._waitingForDraw) {
return;
if (!this._waitingForDraw) {
this._waitingForDraw = true;
Util.requestAnimFrame(() => {
this.draw();
this._waitingForDraw = false;
});
}
Util.requestAnimFrame(() => {
this._waitingForDraw = false;
this.draw();
});
return this;
}

View File

@@ -66,7 +66,7 @@ export abstract class Container extends Node {
for (var i = 0; i < children.length; i++) {
child = children[i];
// reset parent to prevent many _setChildrenIndices calls
delete child.parent;
child.parent = null;
child.index = 0;
child.remove();
}
@@ -85,7 +85,7 @@ export abstract class Container extends Node {
for (var i = 0; i < children.length; i++) {
child = children[i];
// reset parent to prevent many _setChildrenIndices calls
delete child.parent;
child.parent = null;
child.index = 0;
child.destroy();
}

View File

@@ -719,7 +719,7 @@ export abstract class Node {
if (parent && parent.children) {
parent.children.splice(this.index, 1);
parent._setChildrenIndices();
delete this.parent;
this.parent = null;
}
// every cached attr that is calculated via node tree

View File

@@ -542,20 +542,16 @@ export const Util = {
return -1;
}
},
_waiting: false,
animQueue: [],
requestAnimFrame(callback) {
Util.animQueue.push(callback);
if (Util._waiting) {
return;
}
requestAnimationFrame(() => {
Util.animQueue.forEach(cb => {
cb();
if (Util.animQueue.length === 1) {
requestAnimationFrame(function () {
const queue = Util.animQueue;
Util.animQueue = [];
queue.forEach(function (cb) { cb(); });
});
Util.animQueue = [];
Util._waiting = false;
});
}
},
createCanvasElement() {
var canvas = isBrowser