]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
carousel: move common checks to a function (#34621)
authorXhmikosR <xhmikosr@gmail.com>
Tue, 10 Aug 2021 14:50:32 +0000 (17:50 +0300)
committerGitHub <noreply@github.com>
Tue, 10 Aug 2021 14:50:32 +0000 (17:50 +0300)
js/src/carousel.js

index 75f34e422b321301bb0601f8f9944d11d940a895..b0aed38721017c648d8e39a22c9342c0f0dc0875 100644 (file)
@@ -260,8 +260,13 @@ class Carousel extends BaseComponent {
   }
 
   _addTouchEventListeners() {
+    const hasPointerPenTouch = event => {
+      return this._pointerEvent &&
+        (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
+    }
+
     const start = event => {
-      if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
+      if (hasPointerPenTouch(event)) {
         this.touchStartX = event.clientX
       } else if (!this._pointerEvent) {
         this.touchStartX = event.touches[0].clientX
@@ -276,7 +281,7 @@ class Carousel extends BaseComponent {
     }
 
     const end = event => {
-      if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
+      if (hasPointerPenTouch(event)) {
         this.touchDeltaX = event.clientX - this.touchStartX
       }