Transformer fixes

This commit is contained in:
Anton Lavrenov 2018-07-12 11:04:20 +07:00
parent e6c5325ccb
commit aaa3461b1f
5 changed files with 55 additions and 8 deletions

View File

@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [new version][unreleased]
## Fixed
* Some `Konva.Transformer` fixes
## [2.1.7][2018-07-03]
## Fixed

View File

@ -2,7 +2,7 @@
* Konva JavaScript Framework v2.1.7
* http://konvajs.github.io/
* Licensed under the MIT
* Date: Thu Jul 05 2018
* Date: Thu Jul 12 2018
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@ -19305,7 +19305,10 @@
window.removeEventListener('mouseup', this._handleMouseUp, true);
window.removeEventListener('touchend', this._handleMouseUp, true);
this.fire('transformend');
this.getNode().fire('transformend');
var node = this.getNode();
if (node) {
node.fire('transformend');
}
}
},

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -599,7 +599,10 @@
window.removeEventListener('mouseup', this._handleMouseUp, true);
window.removeEventListener('touchend', this._handleMouseUp, true);
this.fire('transformend');
this.getNode().fire('transformend');
var node = this.getNode();
if (node) {
node.fire('transformend');
}
}
},

View File

@ -681,6 +681,42 @@ suite('Transformer', function() {
tr.destroy();
});
test.only('can destroy with attached node while resize', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var rect = new Konva.Rect({
x: 100,
y: 60,
draggable: true,
width: 100,
height: 100,
fill: 'yellow'
});
layer.add(rect);
var tr = new Konva.Transformer({
node: rect
});
layer.add(tr);
layer.draw();
stage.simulateMouseDown({
x: 100,
y: 60
});
assert.equal(tr.isTransforming(), true);
tr.destroy();
assert.equal(tr.isTransforming(), false);
assert.equal(tr.getNode(), undefined);
});
test('can add padding', function() {
var stage = addStage();
var layer = new Konva.Layer();
@ -1004,7 +1040,7 @@ suite('Transformer', function() {
var stage = addStage();
var layer = new Konva.Layer({
y: 100,
scaleY: -1,
scaleY: -1
});
stage.add(layer);
@ -1179,12 +1215,12 @@ suite('Transformer', function() {
draggable: true,
width: 10,
height: 10,
fill: 'yellow',
fill: 'yellow'
});
layer.add(rect);
var tr = new Konva.Transformer({
node: rect,
node: rect
});
layer.add(tr);
layer.draw();