diff options
| author | XhmikosR <[email protected]> | 2021-10-13 15:19:28 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-13 15:19:28 +0300 |
| commit | e8f702666f285a3e69866ed1f8d29fa6eaaaeabb (patch) | |
| tree | 944b2dc894f49f8278d41d096e4388e9ac83157b /js/src/util/swipe.js | |
| parent | db44392bda22f3d5319d2880c992f76d27d2a60c (diff) | |
| download | bootstrap-e8f702666f285a3e69866ed1f8d29fa6eaaaeabb.tar.xz bootstrap-e8f702666f285a3e69866ed1f8d29fa6eaaaeabb.zip | |
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
Diffstat (limited to 'js/src/util/swipe.js')
| -rw-r--r-- | js/src/util/swipe.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/util/swipe.js b/js/src/util/swipe.js index a78f598d9..87a5f7f5a 100644 --- a/js/src/util/swipe.js +++ b/js/src/util/swipe.js @@ -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 } |
