diff options
| author | Bobby <[email protected]> | 2024-08-16 20:47:33 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-16 20:47:33 -0400 |
| commit | 6b28433d9cfde435be8ec2bd6cf91e6324d08865 (patch) | |
| tree | 8343c27b8b95ff5639233e81cf157f92e5688466 /js/src/util/swipe.js | |
| parent | d53094ec16ba385faae2973ddee648698b32ab24 (diff) | |
| parent | 048f56f51460df75e92a2f7b472e1c56baeb68f7 (diff) | |
| download | bootstrap-main.tar.xz bootstrap-main.zip | |
Diffstat (limited to 'js/src/util/swipe.js')
| -rw-r--r-- | js/src/util/swipe.js | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/js/src/util/swipe.js b/js/src/util/swipe.js index 87a5f7f5a..d2f708711 100644 --- a/js/src/util/swipe.js +++ b/js/src/util/swipe.js @@ -1,12 +1,13 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/swipe.js + * Bootstrap 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' +import EventHandler from '../dom/event-handler.js' +import Config from './config.js' +import { execute } from './index.js' /** * Constants @@ -25,23 +26,24 @@ const CLASS_NAME_POINTER_EVENT = 'pointer-event' const SWIPE_THRESHOLD = 40 const Default = { + endCallback: null, leftCallback: null, - rightCallback: null, - endCallback: null + rightCallback: null } const DefaultType = { + endCallback: '(function|null)', leftCallback: '(function|null)', - rightCallback: '(function|null)', - endCallback: '(function|null)' + rightCallback: '(function|null)' } /** * Class definition */ -class Swipe { +class Swipe extends Config { constructor(element, config) { + super() this._element = element if (!element || !Swipe.isSupported()) { @@ -54,6 +56,19 @@ class Swipe { this._initEvents() } + // Getters + static get Default() { + return Default + } + + static get DefaultType() { + return DefaultType + } + + static get NAME() { + return NAME + } + // Public dispose() { EventHandler.off(this._element, EVENT_KEY) @@ -118,15 +133,6 @@ class Swipe { } } - _getConfig(config) { - config = { - ...Default, - ...(typeof config === 'object' ? config : {}) - } - typeCheckConfig(NAME, config, DefaultType) - return config - } - _eventIsPointerPenTouch(event) { return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH) } |
