diff options
Diffstat (limited to 'vendor/twbs/bootstrap/js/dist/util/swipe.js')
-rw-r--r-- | vendor/twbs/bootstrap/js/dist/util/swipe.js | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/vendor/twbs/bootstrap/js/dist/util/swipe.js b/vendor/twbs/bootstrap/js/dist/util/swipe.js index 9808601a2..7d4da7e5b 100644 --- a/vendor/twbs/bootstrap/js/dist/util/swipe.js +++ b/vendor/twbs/bootstrap/js/dist/util/swipe.js @@ -1,25 +1,21 @@ /*! - * Bootstrap swipe.js v5.2.2 (https://getbootstrap.com/) + * Bootstrap swipe.js v5.3.0-alpha1 (https://getbootstrap.com/) * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./config'), require('../dom/event-handler'), require('./index')) : + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./config.js'), require('../dom/event-handler.js'), require('./index.js')) : typeof define === 'function' && define.amd ? define(['./config', '../dom/event-handler', './index'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Swipe = factory(global.Config, global.EventHandler, global.Index)); -})(this, (function (Config, EventHandler, index) { 'use strict'; - - const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; - - const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config); - const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); +})(this, (function (Config, EventHandler, index_js) { 'use strict'; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.2.2): util/swipe.js + * Bootstrap (v5.3.0-alpha1): util/swipe.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ + /** * Constants */ @@ -45,109 +41,91 @@ leftCallback: '(function|null)', rightCallback: '(function|null)' }; + /** * Class definition */ - class Swipe extends Config__default.default { + class Swipe extends Config { constructor(element, config) { super(); this._element = element; - if (!element || !Swipe.isSupported()) { return; } - this._config = this._getConfig(config); this._deltaX = 0; this._supportPointerEvents = Boolean(window.PointerEvent); - this._initEvents(); - } // Getters - + } + // Getters static get Default() { return Default; } - static get DefaultType() { return DefaultType; } - static get NAME() { return NAME; - } // Public - + } + // Public dispose() { - EventHandler__default.default.off(this._element, EVENT_KEY); - } // Private - + EventHandler.off(this._element, EVENT_KEY); + } + // Private _start(event) { if (!this._supportPointerEvents) { this._deltaX = event.touches[0].clientX; return; } - if (this._eventIsPointerPenTouch(event)) { this._deltaX = event.clientX; } } - _end(event) { if (this._eventIsPointerPenTouch(event)) { this._deltaX = event.clientX - this._deltaX; } - this._handleSwipe(); - - index.execute(this._config.endCallback); + index_js.execute(this._config.endCallback); } - _move(event) { this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX; } - _handleSwipe() { const absDeltaX = Math.abs(this._deltaX); - if (absDeltaX <= SWIPE_THRESHOLD) { return; } - const direction = absDeltaX / this._deltaX; this._deltaX = 0; - if (!direction) { return; } - - index.execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback); + index_js.execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback); } - _initEvents() { if (this._supportPointerEvents) { - EventHandler__default.default.on(this._element, EVENT_POINTERDOWN, event => this._start(event)); - EventHandler__default.default.on(this._element, EVENT_POINTERUP, event => this._end(event)); - + EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event)); + EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event)); this._element.classList.add(CLASS_NAME_POINTER_EVENT); } else { - EventHandler__default.default.on(this._element, EVENT_TOUCHSTART, event => this._start(event)); - EventHandler__default.default.on(this._element, EVENT_TOUCHMOVE, event => this._move(event)); - EventHandler__default.default.on(this._element, EVENT_TOUCHEND, event => this._end(event)); + EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event)); + EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event)); + EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event)); } } - _eventIsPointerPenTouch(event) { return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); - } // Static - + } + // Static static isSupported() { return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; } - } return Swipe; |