diff options
author | XhmikosR <xhmikosr@gmail.com> | 2020-12-03 17:18:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 17:18:59 +0300 |
commit | cfe31592d7b487a769fd8d14ddf7898c07425280 (patch) | |
tree | 79d9dc546df2099295a948a26ca2f9ae71a3a733 /js/dist/carousel.js | |
parent | cfd00b5eeb7b7440afb3f115a66ea3c58e2e2d5d (diff) |
Dist (#32323)
Diffstat (limited to 'js/dist/carousel.js')
-rw-r--r-- | js/dist/carousel.js | 165 |
1 files changed, 105 insertions, 60 deletions
diff --git a/js/dist/carousel.js b/js/dist/carousel.js index b44997cf45..64cc63a335 100644 --- a/js/dist/carousel.js +++ b/js/dist/carousel.js @@ -5,7 +5,7 @@ */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data.js', './dom/event-handler.js', './dom/manipulator.js', './dom/selector-engine.js'], factory) : + typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine)); }(this, (function (Data, EventHandler, Manipulator, SelectorEngine) { 'use strict'; @@ -147,8 +147,6 @@ } }; - function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } - function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } @@ -158,8 +156,55 @@ * ------------------------------------------------------------------------ */ - var NAME = 'carousel'; var VERSION = '5.0.0-alpha3'; + + var BaseComponent = /*#__PURE__*/function () { + function BaseComponent(element) { + if (!element) { + return; + } + + this._element = element; + Data__default['default'].setData(element, this.constructor.DATA_KEY, this); + } + + var _proto = BaseComponent.prototype; + + _proto.dispose = function dispose() { + Data__default['default'].removeData(this._element, this.constructor.DATA_KEY); + this._element = null; + } + /** Static */ + ; + + BaseComponent.getInstance = function getInstance(element) { + return Data__default['default'].getData(element, this.DATA_KEY); + }; + + _createClass(BaseComponent, null, [{ + key: "VERSION", + get: function get() { + return VERSION; + } + }]); + + return BaseComponent; + }(); + + function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } + + function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + + function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; } + + function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; } + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'carousel'; var DATA_KEY = 'bs.carousel'; var EVENT_KEY = "." + DATA_KEY; var DATA_API_KEY = '.data-api'; @@ -227,25 +272,29 @@ * ------------------------------------------------------------------------ */ - var Carousel = /*#__PURE__*/function () { - function Carousel(element, config) { - this._items = null; - this._interval = null; - this._activeElement = null; - this._isPaused = false; - this._isSliding = false; - this.touchTimeout = null; - this.touchStartX = 0; - this.touchDeltaX = 0; - this._config = this._getConfig(config); - this._element = element; - this._indicatorsElement = SelectorEngine__default['default'].findOne(SELECTOR_INDICATORS, this._element); - this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; - this._pointerEvent = Boolean(window.PointerEvent); - - this._addEventListeners(); + var Carousel = /*#__PURE__*/function (_BaseComponent) { + _inheritsLoose(Carousel, _BaseComponent); - Data__default['default'].setData(element, DATA_KEY, this); + function Carousel(element, config) { + var _this; + + _this = _BaseComponent.call(this, element) || this; + _this._items = null; + _this._interval = null; + _this._activeElement = null; + _this._isPaused = false; + _this._isSliding = false; + _this.touchTimeout = null; + _this.touchStartX = 0; + _this.touchDeltaX = 0; + _this._config = _this._getConfig(config); + _this._indicatorsElement = SelectorEngine__default['default'].findOne(SELECTOR_INDICATORS, _this._element); + _this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; + _this._pointerEvent = Boolean(window.PointerEvent); + + _this._addEventListeners(); + + return _this; } // Getters @@ -304,7 +353,7 @@ }; _proto.to = function to(index) { - var _this = this; + var _this2 = this; this._activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element); @@ -316,7 +365,7 @@ if (this._isSliding) { EventHandler__default['default'].one(this._element, EVENT_SLID, function () { - return _this.to(index); + return _this2.to(index); }); return; } @@ -333,11 +382,11 @@ }; _proto.dispose = function dispose() { + _BaseComponent.prototype.dispose.call(this); + EventHandler__default['default'].off(this._element, EVENT_KEY); - Data__default['default'].removeData(this._element, DATA_KEY); this._items = null; this._config = null; - this._element = null; this._interval = null; this._isPaused = null; this._isSliding = null; @@ -373,20 +422,20 @@ }; _proto._addEventListeners = function _addEventListeners() { - var _this2 = this; + var _this3 = this; if (this._config.keyboard) { EventHandler__default['default'].on(this._element, EVENT_KEYDOWN, function (event) { - return _this2._keydown(event); + return _this3._keydown(event); }); } if (this._config.pause === 'hover') { EventHandler__default['default'].on(this._element, EVENT_MOUSEENTER, function (event) { - return _this2.pause(event); + return _this3.pause(event); }); EventHandler__default['default'].on(this._element, EVENT_MOUSELEAVE, function (event) { - return _this2.cycle(event); + return _this3.cycle(event); }); } @@ -396,33 +445,33 @@ }; _proto._addTouchEventListeners = function _addTouchEventListeners() { - var _this3 = this; + var _this4 = this; var start = function start(event) { - if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) { - _this3.touchStartX = event.clientX; - } else if (!_this3._pointerEvent) { - _this3.touchStartX = event.touches[0].clientX; + if (_this4._pointerEvent && PointerType[event.pointerType.toUpperCase()]) { + _this4.touchStartX = event.clientX; + } else if (!_this4._pointerEvent) { + _this4.touchStartX = event.touches[0].clientX; } }; var move = function move(event) { // ensure swiping with one touch and not pinching if (event.touches && event.touches.length > 1) { - _this3.touchDeltaX = 0; + _this4.touchDeltaX = 0; } else { - _this3.touchDeltaX = event.touches[0].clientX - _this3.touchStartX; + _this4.touchDeltaX = event.touches[0].clientX - _this4.touchStartX; } }; var end = function end(event) { - if (_this3._pointerEvent && PointerType[event.pointerType.toUpperCase()]) { - _this3.touchDeltaX = event.clientX - _this3.touchStartX; + if (_this4._pointerEvent && PointerType[event.pointerType.toUpperCase()]) { + _this4.touchDeltaX = event.clientX - _this4.touchStartX; } - _this3._handleSwipe(); + _this4._handleSwipe(); - if (_this3._config.pause === 'hover') { + if (_this4._config.pause === 'hover') { // If it's a touch-enabled device, mouseenter/leave are fired as // part of the mouse compatibility events on first tap - the carousel // would stop cycling until user tapped out of it; @@ -430,15 +479,15 @@ // (as if it's the second time we tap on it, mouseenter compat event // is NOT fired) and after a timeout (to allow for mouse compatibility // events to fire) we explicitly restart cycling - _this3.pause(); + _this4.pause(); - if (_this3.touchTimeout) { - clearTimeout(_this3.touchTimeout); + if (_this4.touchTimeout) { + clearTimeout(_this4.touchTimeout); } - _this3.touchTimeout = setTimeout(function (event) { - return _this3.cycle(event); - }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval); + _this4.touchTimeout = setTimeout(function (event) { + return _this4.cycle(event); + }, TOUCHEVENT_COMPAT_WAIT + _this4._config.interval); } }; @@ -558,7 +607,7 @@ }; _proto._slide = function _slide(direction, element) { - var _this4 = this; + var _this5 = this; var activeElement = SelectorEngine__default['default'].findOne(SELECTOR_ACTIVE_ITEM, this._element); @@ -619,9 +668,9 @@ nextElement.classList.remove(directionalClassName, orderClassName); nextElement.classList.add(CLASS_NAME_ACTIVE); activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName); - _this4._isSliding = false; + _this5._isSliding = false; setTimeout(function () { - EventHandler__default['default'].trigger(_this4._element, EVENT_SLID, { + EventHandler__default['default'].trigger(_this5._element, EVENT_SLID, { relatedTarget: nextElement, direction: eventDirectionName, from: activeElementIndex, @@ -707,24 +756,20 @@ event.preventDefault(); }; - Carousel.getInstance = function getInstance(element) { - return Data__default['default'].getData(element, DATA_KEY); - }; - - _createClass(Carousel, null, [{ - key: "VERSION", + _createClass$1(Carousel, null, [{ + key: "Default", get: function get() { - return VERSION; + return Default; } }, { - key: "Default", + key: "DATA_KEY", get: function get() { - return Default; + return DATA_KEY; } }]); return Carousel; - }(); + }(BaseComponent); /** * ------------------------------------------------------------------------ * Data Api implementation |