|
409 | 409 | };
|
410 | 410 | },
|
411 | 411 | dragStart: function(event) {
|
| 412 | + var e = event.touches ? event.touches[0] : event; |
412 | 413 | this.zIndex = 2, this.shiftX = this.shiftStartX = this.left, this.shiftY = this.shiftStartY = this.top,
|
413 |
| - this.mouseMoveStartX = event.pageX, this.mouseMoveStartY = event.pageY, this.animate = !1, |
| 414 | + this.mouseMoveStartX = e.pageX, this.mouseMoveStartY = e.pageY, this.animate = !1, |
414 | 415 | this.dragging = !0, document.addEventListener("mousemove", this.documentMouseMove),
|
415 |
| - this.$emit("dragstart", this.wrapEvent(event)); |
| 416 | + document.addEventListener("touchmove", this.documentMouseMove), this.$emit("dragstart", this.wrapEvent(event)); |
416 | 417 | },
|
417 | 418 | drag: function(event) {
|
418 |
| - var distanceX = event.pageX - this.mouseMoveStartX, distanceY = event.pageY - this.mouseMoveStartY; |
| 419 | + var e = event.touches ? event.touches[0] : event, distanceX = e.pageX - this.mouseMoveStartX, distanceY = e.pageY - this.mouseMoveStartY; |
419 | 420 | this.shiftX = distanceX + this.shiftStartX, this.shiftY = distanceY + this.shiftStartY;
|
420 | 421 | var gridX = Math.round(this.shiftX / this.cellWidth), gridY = Math.round(this.shiftY / this.cellHeight);
|
421 | 422 | gridX = Math.min(gridX, this.rowCount - 1), gridY = Math.max(gridY, 0);
|
|
436 | 437 | var _this2 = this;
|
437 | 438 | this.draggable && (this.timer = setTimeout(function() {
|
438 | 439 | _this2.dragStart(event);
|
439 |
| - }, this.dragDelay), document.addEventListener("mouseup", this.documentMouseUp)); |
| 440 | + }, this.dragDelay), document.addEventListener("mouseup", this.documentMouseUp), |
| 441 | + document.addEventListener("touchend", this.documentMouseUp)); |
440 | 442 | },
|
441 | 443 | documentMouseMove: function(event) {
|
442 | 444 | this.draggable && this.dragging && this.drag(event);
|
|
446 | 448 | var dx = this.shiftStartX - this.shiftX, dy = this.shiftStartY - this.shiftY, distance = Math.sqrt(dx * dx + dy * dy);
|
447 | 449 | this.animate = !0, this.dragging = !1, this.mouseMoveStartX = 0, this.mouseMoveStartY = 0,
|
448 | 450 | this.shiftStartX = 0, this.shiftStartY = 0, document.removeEventListener("mousemove", this.documentMouseMove),
|
449 |
| - document.removeEventListener("mouseup", this.documentMouseUp); |
| 451 | + document.removeEventListener("touchmove", this.documentMouseMove), document.removeEventListener("mouseup", this.documentMouseUp), |
| 452 | + document.removeEventListener("touchend", this.documentMouseUp); |
450 | 453 | var $event = this.wrapEvent(event);
|
451 |
| - distance < 5 && this.$emit("click", $event), this.$emit("dragend", $event); |
| 454 | + distance < 4 && this.$emit("click", $event), this.$emit("dragend", $event); |
452 | 455 | }
|
453 | 456 | }
|
454 | 457 | };
|
|
546 | 549 | class: _vm.className,
|
547 | 550 | style: _vm.style,
|
548 | 551 | on: {
|
549 |
| - mousedown: _vm.mousedown |
| 552 | + mousedown: _vm.mousedown, |
| 553 | + touchstart: _vm.mousedown |
550 | 554 | }
|
551 | 555 | }, [ _vm._t("default") ], 2);
|
552 | 556 | },
|
|
0 commit comments