Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@gmail.com>2021-08-10 17:50:32 +0300
committerGitHub <noreply@github.com>2021-08-10 17:50:32 +0300
commit418fe8113ec78e3b7251322560cd2d4a5bc6b71e (patch)
treec85a92ee8275bdd757152097cc3502c3036ec615
parent2034ead87f848c93b976d3590b51bcfdc79adf99 (diff)
carousel: move common checks to a function (#34621)
-rw-r--r--js/src/carousel.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 75f34e422b..b0aed38721 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -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
}