vue3-touch-events
Advanced tools
+46
-25
@@ -110,4 +110,18 @@ /** | ||
| // process event and pass 'this' onward | ||
| touchMoveEvent(event, $this); | ||
| touchMoveEvent(event, $this, false); | ||
| } | ||
| else { | ||
| // TODO: mobile support | ||
| // if rollover events are wanted and this is a mouse event | ||
| if (hasEvent($this, 'rollover') && event.clientX != null) { | ||
| var mouseEvent = event; | ||
| // if the mouse is actually over this object (within this obj's bounds) | ||
| const rect = $this.element.getBoundingClientRect(); | ||
| if (mouseEvent.clientX >= rect.left && mouseEvent.clientX <= rect.right && | ||
| mouseEvent.clientY >= rect.top && mouseEvent.clientY <= rect.bottom) { | ||
| // process rollovers only and pass 'this' onward | ||
| touchMoveEvent(event, $this, true); | ||
| } | ||
| } | ||
| } | ||
| } | ||
@@ -117,3 +131,3 @@ /** | ||
| */ | ||
| function touchMoveEvent(event, $this = null) { | ||
| function touchMoveEvent(event, $this = null, onlyProcessRollover = false) { | ||
| if ($this == null) | ||
@@ -126,26 +140,29 @@ $this = this.$$touchObj; | ||
| $this.currentY = curY; | ||
| //-------------------------------------------------------------------------------------- | ||
| // DRAG ONCE | ||
| //-------------------------------------------------------------------------------------- | ||
| if (!$this.touchMoved) { | ||
| var tapTolerance = $this.options.tapTolerance; | ||
| $this.touchMoved = Math.abs($this.startX - $this.currentX) > tapTolerance || | ||
| Math.abs($this.startY - $this.currentY) > tapTolerance; | ||
| // trigger `drag.once` only once after mouse FIRST moved while dragging the element | ||
| // (`touchMoved` is the flag that indicates we no longer need to trigger this) | ||
| if ($this.touchMoved) { | ||
| cancelTouchHoldTimer($this); | ||
| triggerEvent(event, $this.element, 'drag.once'); | ||
| // dont process if only rollover wanted! | ||
| if (!onlyProcessRollover) { | ||
| //-------------------------------------------------------------------------------------- | ||
| // DRAG ONCE | ||
| //-------------------------------------------------------------------------------------- | ||
| if (!$this.touchMoved) { | ||
| var tapTolerance = $this.options.tapTolerance; | ||
| $this.touchMoved = Math.abs($this.startX - $this.currentX) > tapTolerance || | ||
| Math.abs($this.startY - $this.currentY) > tapTolerance; | ||
| // trigger `drag.once` only once after mouse FIRST moved while dragging the element | ||
| // (`touchMoved` is the flag that indicates we no longer need to trigger this) | ||
| if ($this.touchMoved) { | ||
| cancelTouchHoldTimer($this); | ||
| triggerEvent(event, $this.element, 'drag.once'); | ||
| } | ||
| } | ||
| } | ||
| //-------------------------------------------------------------------------------------- | ||
| // SWIPE | ||
| //-------------------------------------------------------------------------------------- | ||
| // performance: only process swipe events if `swipe.*` event is registered on this element | ||
| else if ($this.hasSwipe && !$this.swipeOutBounded) { | ||
| var swipeOutBounded = $this.options.swipeTolerance; | ||
| // Process swipe events using cones | ||
| if (Math.abs($this.startX - $this.currentX) / Math.abs($this.startY - $this.currentY) > $this.options.swipeConeSize && | ||
| Math.abs($this.startY - $this.currentY) / Math.abs($this.startX - $this.currentX) > $this.options.swipeConeSize) { | ||
| $this.swipeOutBounded = (Math.abs($this.startY - $this.currentY) < swipeOutBounded) && (Math.abs($this.startX - $this.currentX) < swipeOutBounded); | ||
| //-------------------------------------------------------------------------------------- | ||
| // SWIPE | ||
| //-------------------------------------------------------------------------------------- | ||
| // performance: only process swipe events if `swipe.*` event is registered on this element | ||
| else if ($this.hasSwipe && !$this.swipeOutBounded) { | ||
| var swipeOutBounded = $this.options.swipeTolerance; | ||
| // Process swipe events using cones | ||
| if (Math.abs($this.startX - $this.currentX) / Math.abs($this.startY - $this.currentY) > $this.options.swipeConeSize && | ||
| Math.abs($this.startY - $this.currentY) / Math.abs($this.startX - $this.currentX) > $this.options.swipeConeSize) { | ||
| $this.swipeOutBounded = (Math.abs($this.startY - $this.currentY) < swipeOutBounded) && (Math.abs($this.startX - $this.currentX) < swipeOutBounded); | ||
| } | ||
| } | ||
@@ -165,2 +182,6 @@ } | ||
| } | ||
| // exit if only rollovers wanted! | ||
| if (onlyProcessRollover) { | ||
| return; | ||
| } | ||
| //-------------------------------------------------------------------------------------- | ||
@@ -167,0 +188,0 @@ // DRAG |
+1
-1
| { | ||
| "name": "vue3-touch-events", | ||
| "version": "5.0.12", | ||
| "version": "5.0.13", | ||
| "description": "Simple touch events support for vue.js 3", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
50830
2.35%557
3.92%6
20%