vue3-touch-events
Advanced tools
Comparing version 5.0.9 to 5.0.10
@@ -66,4 +66,5 @@ // index.js | ||
$this.touchStartTime = event.timeStamp; | ||
$this.hasSwipe = hasEvent(this, "swipe") || hasEvent(this, "swipe.left") || hasEvent(this, "swipe.right") || hasEvent(this, "swipe.top") || hasEvent(this, "swipe.bottom"); | ||
if (hasEvent(this, "hold")) { | ||
$this.hasSwipe = hasEvent($this, "swipe") || hasEvent($this, "swipe.left") || hasEvent($this, "swipe.right") || hasEvent($this, "swipe.top") || hasEvent($this, "swipe.bottom"); | ||
$this.hasZoom = hasEvent($this, "zoom") || hasEvent($this, "zoom.in") || hasEvent($this, "zoom.out"); | ||
if (hasEvent($this, "hold")) { | ||
$this.touchHoldTimer = setTimeout(function() { | ||
@@ -95,3 +96,3 @@ $this.touchHoldTimer = null; | ||
cancelTouchHoldTimer($this); | ||
triggerEvent(event, this, "drag.once"); | ||
triggerEvent(event, $this.element, "drag.once"); | ||
} | ||
@@ -104,17 +105,17 @@ } else if ($this.hasSwipe && !$this.swipeOutBounded) { | ||
} | ||
if (hasEvent(this, "rollover") && movedAgain) { | ||
if (movedAgain && hasEvent($this, "rollover")) { | ||
var now = event.timeStamp; | ||
if ($this.touchRollTime == null || now > $this.touchRollTime + $this.options.rollOverFrequency) { | ||
$this.touchRollTime = now; | ||
triggerEvent(event, this, "rollover"); | ||
triggerEvent(event, $this.element, "rollover"); | ||
} | ||
} | ||
if (hasEvent(this, "drag") && $this.touchStarted && $this.touchMoved && movedAgain) { | ||
if ($this.touchStarted && $this.touchMoved && movedAgain && hasEvent($this, "drag")) { | ||
var now = event.timeStamp; | ||
if ($this.touchDragTime == null || now > $this.touchDragTime + $this.options.dragFrequency) { | ||
$this.touchDragTime = now; | ||
triggerEvent(event, this, "drag"); | ||
triggerEvent(event, $this.element, "drag"); | ||
} | ||
} | ||
if ($this.touchStarted && (hasEvent(this, "zoom") || hasEvent(this, "zoom.in") || hasEvent(this, "zoom.out"))) { | ||
if ($this.touchStarted && $this.hasZoom) { | ||
var now = event.timeStamp; | ||
@@ -140,13 +141,13 @@ if ($this.touchZoomTime == null || now > $this.touchZoomTime + $this.options.zoomFrequency) { | ||
const zoomFactor = newDistance / $this.initialZoomDistance; | ||
if (hasEvent(this, "zoom")) { | ||
if (hasEvent($this, "zoom")) { | ||
if (Math.abs(zoomFactor - 1) > $this.options.zoomDistance / $this.initialZoomDistance) { | ||
triggerEvent(event, this, "zoom", zoomFactor); | ||
triggerEvent(event, $this.element, "zoom", zoomFactor); | ||
} | ||
} | ||
if (hasEvent(this, "zoom.in") || hasEvent(this, "zoom.out")) { | ||
if (hasEvent($this, "zoom.in") || hasEvent($this, "zoom.out")) { | ||
if (Math.abs(newDistance - $this.initialZoomDistance) > $this.options.zoomInOutDistance) { | ||
if (newDistance > $this.initialZoomDistance) { | ||
triggerEvent(event, this, "zoom.in"); | ||
triggerEvent(event, $this.element, "zoom.in"); | ||
} else { | ||
triggerEvent(event, this, "zoom.out"); | ||
triggerEvent(event, $this.element, "zoom.out"); | ||
} | ||
@@ -183,3 +184,3 @@ } | ||
if (!$this.touchMoved) { | ||
if (hasEvent(this, "longtap") && event.timeStamp - $this.touchStartTime > $this.options.longTapTimeInterval) { | ||
if (hasEvent($this, "longtap") && event.timeStamp - $this.touchStartTime > $this.options.longTapTimeInterval) { | ||
if (event.cancelable) { | ||
@@ -189,3 +190,3 @@ event.preventDefault(); | ||
triggerEvent(event, this, "longtap"); | ||
} else if (hasEvent(this, "hold") && touchholdEnd) { | ||
} else if (hasEvent($this, "hold") && touchholdEnd) { | ||
if (event.cancelable) { | ||
@@ -206,3 +207,3 @@ event.preventDefault(); | ||
} | ||
if (hasEvent(this, "swipe." + direction)) { | ||
if (hasEvent($this, "swipe." + direction)) { | ||
triggerEvent(event, this, "swipe." + direction, direction); | ||
@@ -222,4 +223,4 @@ } else { | ||
} | ||
function hasEvent($el, eventType) { | ||
var callbacks = $el.$$touchObj.callbacks[eventType]; | ||
function hasEvent($this, eventType) { | ||
var callbacks = $this.callbacks[eventType]; | ||
return callbacks != null && callbacks.length > 0; | ||
@@ -269,2 +270,3 @@ } | ||
var touchObj = $el.$$touchObj || { | ||
element: $el, | ||
callbacks: {}, | ||
@@ -271,0 +273,0 @@ hasBindTouchEvents: false, |
{ | ||
"name": "vue3-touch-events", | ||
"version": "5.0.9", | ||
"version": "5.0.10", | ||
"description": "Simple touch events support for vue.js 3", | ||
@@ -5,0 +5,0 @@ "type": "module", |
37122
379