diff options
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) } |
