2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-05 16:42:29 +03:00

JS: minor refactoring (#35183)

* add missing comments
* shorten block comments
* reorder constants
* reorder public/private methods
* sort exports alphabetically in util/index.js
* fix a couple of typos
This commit is contained in:
XhmikosR
2021-10-13 15:19:28 +03:00
committed by GitHub
parent db44392bda
commit e8f702666f
21 changed files with 261 additions and 384 deletions
+18
View File
@@ -1,6 +1,17 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.1.3): util/swipe.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import EventHandler from '../dom/event-handler'
import { execute, typeCheckConfig } from './index'
/**
* Constants
*/
const NAME = 'swipe'
const EVENT_KEY = '.bs.swipe'
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`
@@ -25,6 +36,10 @@ const DefaultType = {
endCallback: '(function|null)'
}
/**
* Class definition
*/
class Swipe {
constructor(element, config) {
this._element = element
@@ -39,10 +54,12 @@ class Swipe {
this._initEvents()
}
// Public
dispose() {
EventHandler.off(this._element, EVENT_KEY)
}
// Private
_start(event) {
if (!this._supportPointerEvents) {
this._deltaX = event.touches[0].clientX
@@ -114,6 +131,7 @@ class Swipe {
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
}
// Static
static isSupported() {
return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
}