mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-10 23:54:08 +02:00
carousel: move common checks to a function (#34621)
This commit is contained in:
@@ -260,8 +260,13 @@ class Carousel extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_addTouchEventListeners() {
|
_addTouchEventListeners() {
|
||||||
|
const hasPointerPenTouch = event => {
|
||||||
|
return this._pointerEvent &&
|
||||||
|
(event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
|
||||||
|
}
|
||||||
|
|
||||||
const start = event => {
|
const start = event => {
|
||||||
if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) {
|
if (hasPointerPenTouch(event)) {
|
||||||
this.touchStartX = event.clientX
|
this.touchStartX = event.clientX
|
||||||
} else if (!this._pointerEvent) {
|
} else if (!this._pointerEvent) {
|
||||||
this.touchStartX = event.touches[0].clientX
|
this.touchStartX = event.touches[0].clientX
|
||||||
@@ -276,7 +281,7 @@ class Carousel extends BaseComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const end = event => {
|
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
|
this.touchDeltaX = event.clientX - this.touchStartX
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user