fixed drag and drop regression by busting the transform cache inside the clearTransform method

This commit is contained in:
Eric Rowell
2013-08-10 13:59:31 -07:00
parent 1c51d65a93
commit 0d6b8bdd79
3 changed files with 16 additions and 6 deletions

View File

@@ -99,6 +99,10 @@
this.on(transformChangeStr, _clearTransformCache);
this.on('visibleChange.kinetic', _clearVisibleCache);
this.on('opacityChange.kinetic', _clearAbsoluteOpacityCache);
this._clearTransformCache = _clearTransformCache;
this._clearVisibleCache = _clearVisibleCache;
this._clearAbsoluteOpacityCache = _clearAbsoluteOpacityCache;
},
_handleCache: function(attr) {
var func;
@@ -838,7 +842,8 @@
* @memberof Kinetic.Node.prototype
*/
getAbsoluteTransform: function() {
return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
return this._getAbsoluteTransform();
//return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
},
_getAbsoluteTransform: function() {
// absolute transform
@@ -1080,6 +1085,9 @@
}
}
},
/**
* clears the transform and returns the original transform
*/
_clearTransform: function() {
var trans = {
@@ -1104,6 +1112,8 @@
this.attrs.skewX = 0;
this.attrs.skewY = 0;
this._clearTransformCache();
return trans;
},
_setTransform: function(trans) {
@@ -1113,7 +1123,7 @@
this.attrs[key] = trans[key];
}
delete this.cache.transform;
this._clearTransformCache();
},
_fireBeforeChangeEvent: function(attr, oldVal, newVal) {
this._fire(BEFORE + Kinetic.Util._capitalize(attr) + CHANGE, {
@@ -1231,6 +1241,7 @@
* @memberof Kinetic.Node.prototype
*/
getTransform: function() {
//return this._getTransform();
return this._getCache(TRANSFORM, this._getTransform);
}
});

View File

@@ -8,7 +8,7 @@
<script src="../js/performanceTests.js"></script>
<!-- versions -->
<!--
<script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.5.2.min.js"></script>
<script>
run(Kinetic);
@@ -28,7 +28,7 @@
<script>
run(Kinetic);
</script>
-->
<script src="../../dist/kinetic-dev.js"></script>
<script>
run(Kinetic);

View File

@@ -1444,8 +1444,7 @@ Test.Modules.DRAG_AND_DROP = {
offset: {
x: 50,
y: 25
},
dragOnTop: true
}
});
group.add(rect);