Fix click stage event on dragend, Fix some Transformer cursor behavior. fix #463

This commit is contained in:
Anton Lavrenov
2018-09-27 10:59:27 +03:00
parent c0911572e7
commit 15b9d66b20
8 changed files with 144 additions and 20 deletions

View File

@@ -566,7 +566,10 @@
}
} else {
this._fire(MOUSEUP, { evt: evt, target: this, currentTarget: this });
this._fire(CLICK, { evt: evt, target: this, currentTarget: this });
if (Konva.listenClickTap) {
this._fire(CLICK, { evt: evt, target: this, currentTarget: this });
}
if (fireDblClick) {
this._fire(DBL_CLICK, {
evt: evt,
@@ -671,7 +674,9 @@
}
} else {
this._fire(TOUCHEND, { evt: evt, target: this, currentTarget: this });
this._fire(TAP, { evt: evt, target: this, currentTarget: this });
if (Konva.listenClickTap) {
this._fire(TAP, { evt: evt, target: this, currentTarget: this });
}
if (fireDblClick) {
this._fire(DBL_TAP, {
evt: evt,

View File

@@ -4,6 +4,7 @@
var ATTR_CHANGE_LIST = [
'resizeEnabledChange',
'rotateAnchorOffsetChange',
'rotateEnabledChange',
'enabledAnchorsChange',
'anchorSizeChange',
'borderEnabledChange',
@@ -331,7 +332,6 @@
// add hover styling
anchor.on('mouseenter', function() {
var layer = this.getLayer();
var tr = this.getParent();
var rad = Konva.getAngle(tr.rotation());
@@ -341,15 +341,14 @@
var isMirrored = scale.y * scale.x < 0;
var cursor = getCursor(name, rad, isMirrored);
anchor.getStage().content.style.cursor = cursor;
layer.batchDraw();
tr._cursorChange = true;
});
anchor.on('mouseout', function() {
var layer = this.getLayer();
if (!layer) {
if (!anchor.getStage() || !this.getParent()) {
return;
}
anchor.getStage().content.style.cursor = '';
layer.batchDraw();
this.getParent()._cursorChange = false;
});
this.add(anchor);
},
@@ -809,6 +808,10 @@
}
},
destroy: function() {
// console.log(this.isTransforming() && this.getStage());
if (this.getStage() && this._cursorChange) {
this.getStage().content.style.cursor = '';
}
Konva.Group.prototype.destroy.call(this);
this.detach();
this._removeEvents();