mirror of
https://github.com/konvajs/konva.git
synced 2026-01-22 21:02:26 +08:00
fix drag&drop on mobile
This commit is contained in:
@@ -283,4 +283,50 @@ Konva.Stage.prototype.simulateMouseUp = function(pos) {
|
||||
Konva.DD._endDragAfter(evt);
|
||||
};
|
||||
|
||||
Konva.Stage.prototype.simulateTouchStart = function(pos) {
|
||||
var top = this.content.getBoundingClientRect().top;
|
||||
|
||||
this._touchstart({
|
||||
touches: [
|
||||
{
|
||||
clientX: pos.x,
|
||||
clientY: pos.y + top
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
Konva.Stage.prototype.simulateTouchMove = function(pos) {
|
||||
var top = this.content.getBoundingClientRect().top;
|
||||
|
||||
var evt = {
|
||||
touches: [
|
||||
{
|
||||
clientX: pos.x,
|
||||
clientY: pos.y + top
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
this._touchmove(evt);
|
||||
Konva.DD._drag(evt);
|
||||
};
|
||||
|
||||
Konva.Stage.prototype.simulateTouchEnd = function(pos) {
|
||||
var top = this.content.getBoundingClientRect().top;
|
||||
|
||||
var evt = {
|
||||
touches: [
|
||||
{
|
||||
clientX: pos.x,
|
||||
clientY: pos.y + top
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
Konva.DD._endDragBefore(evt);
|
||||
this._touchend(evt);
|
||||
Konva.DD._endDragAfter(evt);
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user