mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
improved transform caching
This commit is contained in:
35
src/Node.js
35
src/Node.js
@@ -50,16 +50,20 @@
|
||||
'offsetYChange.kinetic'
|
||||
].join(SPACE);
|
||||
|
||||
// clear transform cache pair
|
||||
function _clearTransformCacheEachChild(node) {
|
||||
_clearTransformCache.call(node);
|
||||
}
|
||||
function _clearTransformCache() {
|
||||
this._clearCache(TRANSFORM);
|
||||
this._clearAbsoluteTransformCache();
|
||||
}
|
||||
|
||||
// clear absolute transform cache pair
|
||||
function _clearAbsoluteTransformCacheEachChild(node) {
|
||||
_clearAbsoluteTransformCache.call(node);
|
||||
}
|
||||
function _clearAbsoluteTransformCache() {
|
||||
this._clearCache(ABSOLUTE_TRANSFORM);
|
||||
|
||||
if (this.children) {
|
||||
this.getChildren().each(_clearTransformCacheEachChild);
|
||||
this.getChildren().each(_clearAbsoluteTransformCacheEachChild);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,26 +105,10 @@
|
||||
this.on('opacityChange.kinetic', _clearAbsoluteOpacityCache);
|
||||
|
||||
this._clearTransformCache = _clearTransformCache;
|
||||
this._clearAbsoluteTransformCache = _clearAbsoluteTransformCache;
|
||||
this._clearVisibleCache = _clearVisibleCache;
|
||||
this._clearAbsoluteOpacityCache = _clearAbsoluteOpacityCache;
|
||||
},
|
||||
_handleCache: function(attr) {
|
||||
var func;
|
||||
|
||||
// if attr is not defined, and we haven't already cleared the cache
|
||||
if (attr !== undefined && this.cache[attr] !== undefined) {
|
||||
func = Kinetic.Node.clearCacheFuncs[attr];
|
||||
|
||||
// custom clear cache method
|
||||
if (func) {
|
||||
func.call(this);
|
||||
}
|
||||
// default clear cache method
|
||||
else {
|
||||
this._clearCache(attr);
|
||||
}
|
||||
}
|
||||
},
|
||||
_clearCache: function(attr){
|
||||
delete this.cache[attr];
|
||||
},
|
||||
@@ -842,8 +830,7 @@
|
||||
* @memberof Kinetic.Node.prototype
|
||||
*/
|
||||
getAbsoluteTransform: function() {
|
||||
return this._getAbsoluteTransform();
|
||||
//return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
|
||||
return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
|
||||
},
|
||||
_getAbsoluteTransform: function() {
|
||||
// absolute transform
|
||||
|
Reference in New Issue
Block a user