From b164e143a9b3c1dc56e6bdab2e2557dbb5bc5153 Mon Sep 17 00:00:00 2001 From: josex2r Date: Thu, 3 Nov 2022 18:00:55 +0000 Subject: [PATCH] feat: build dist --- dist/slotmachine.js | 613 ++++++++++-------------------------- dist/slotmachine.js.map | 2 +- dist/slotmachine.min.js | 2 +- dist/slotmachine.min.js.map | 2 +- 4 files changed, 170 insertions(+), 449 deletions(-) diff --git a/dist/slotmachine.js b/dist/slotmachine.js index 5e560ea..d542e28 100644 --- a/dist/slotmachine.js +++ b/dist/slotmachine.js @@ -9,172 +9,11 @@ root["SlotMachine"] = factory(); })(self, () => { return /******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ 75: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.2 -(function() { - var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime; - - if ((typeof performance !== "undefined" && performance !== null) && performance.now) { - module.exports = function() { - return performance.now(); - }; - } else if ((typeof process !== "undefined" && process !== null) && process.hrtime) { - module.exports = function() { - return (getNanoSeconds() - nodeLoadTime) / 1e6; - }; - hrtime = process.hrtime; - getNanoSeconds = function() { - var hr; - hr = hrtime(); - return hr[0] * 1e9 + hr[1]; - }; - moduleLoadTime = getNanoSeconds(); - upTime = process.uptime() * 1e9; - nodeLoadTime = moduleLoadTime - upTime; - } else if (Date.now) { - module.exports = function() { - return Date.now() - loadTime; - }; - loadTime = Date.now(); - } else { - module.exports = function() { - return new Date().getTime() - loadTime; - }; - loadTime = new Date().getTime(); - } - -}).call(this); - -//# sourceMappingURL=performance-now.js.map - - -/***/ }), - -/***/ 87: -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -var now = __webpack_require__(75) - , root = typeof window === 'undefined' ? __webpack_require__.g : window - , vendors = ['moz', 'webkit'] - , suffix = 'AnimationFrame' - , raf = root['request' + suffix] - , caf = root['cancel' + suffix] || root['cancelRequest' + suffix] - -for(var i = 0; !raf && i < vendors.length; i++) { - raf = root[vendors[i] + 'Request' + suffix] - caf = root[vendors[i] + 'Cancel' + suffix] - || root[vendors[i] + 'CancelRequest' + suffix] -} - -// Some versions of FF have rAF but not cAF -if(!raf || !caf) { - var last = 0 - , id = 0 - , queue = [] - , frameDuration = 1000 / 60 - - raf = function(callback) { - if(queue.length === 0) { - var _now = now() - , next = Math.max(0, frameDuration - (_now - last)) - last = next + _now - setTimeout(function() { - var cp = queue.slice(0) - // Clear queue here to prevent - // callbacks from appending listeners - // to the current frame's queue - queue.length = 0 - for(var i = 0; i < cp.length; i++) { - if(!cp[i].cancelled) { - try{ - cp[i].callback(last) - } catch(e) { - setTimeout(function() { throw e }, 0) - } - } - } - }, Math.round(next)) - } - queue.push({ - handle: ++id, - callback: callback, - cancelled: false - }) - return id - } - - caf = function(handle) { - for(var i = 0; i < queue.length; i++) { - if(queue[i].handle === handle) { - queue[i].cancelled = true - } - } - } -} - -module.exports = function(fn) { - // Wrap in a new function to prevent - // `cancel` potentially being assigned - // to the native rAF function - return raf.call(root, fn) -} -module.exports.cancel = function() { - caf.apply(root, arguments) -} -module.exports.polyfill = function(object) { - if (!object) { - object = root; - } - object.requestAnimationFrame = raf - object.cancelAnimationFrame = caf -} - - -/***/ }) - -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } +/******/ "use strict"; +/******/ // The require scope +/******/ var __webpack_require__ = {}; /******/ /************************************************************************/ -/******/ /* webpack/runtime/compat get default export */ -/******/ (() => { -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = (module) => { -/******/ var getter = module && module.__esModule ? -/******/ () => (module['default']) : -/******/ () => (module); -/******/ __webpack_require__.d(getter, { a: getter }); -/******/ return getter; -/******/ }; -/******/ })(); -/******/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports @@ -187,18 +26,6 @@ module.exports.polyfill = function(object) { /******/ }; /******/ })(); /******/ -/******/ /* webpack/runtime/global */ -/******/ (() => { -/******/ __webpack_require__.g = (function() { -/******/ if (typeof globalThis === 'object') return globalThis; -/******/ try { -/******/ return this || new Function('return this')(); -/******/ } catch (e) { -/******/ if (typeof window === 'object') return window; -/******/ } -/******/ })(); -/******/ })(); -/******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) @@ -206,401 +33,295 @@ module.exports.polyfill = function(object) { /******/ /************************************************************************/ var __webpack_exports__ = {}; -// This entry need to be wrapped in an IIFE because it need to be in strict mode. -(() => { -"use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, { - "default": () => (/* binding */ lib) + "default": () => (/* binding */ SlotMachine) }); -// EXTERNAL MODULE: ./node_modules/raf/index.js -var raf = __webpack_require__(87); -var raf_default = /*#__PURE__*/__webpack_require__.n(raf); ;// CONCATENATED MODULE: ./lib/raf.ts - -function raf_raf(cb, timeout = 0) { - setTimeout(() => raf_default()(cb), timeout); +function raf(cb, timeout = 0) { + setTimeout(() => requestAnimationFrame(cb), timeout); } -;// CONCATENATED MODULE: ./lib/timer.ts -class Timer { - constructor(cb, delay) { - this.cb = cb; - this.initialDelay = delay; - this.delay = delay; - this.running = false; - this.resume(); - return this; - } - _start() { - this.timer = setTimeout(() => { - this.running = false; - this.cb(this); - }, this.delay); +;// CONCATENATED MODULE: ./lib/dom.ts +class Container { + constructor(container) { + this.container = container; + this.tiles = []; + this.tileNodes = []; + const tileElements = [].slice.call(this.container.children); + this.container.style.overflow = 'hidden'; + this.element = document.createElement('div'); + this.element.classList.add('slot-machine__container'); + this.element.style.transition = '1s ease-in-out'; + this.container.appendChild(this.element); + this.tiles = [...tileElements].map((element) => new Tile(element)); + this.tileNodes = [ + this.tiles[this.tiles.length - 1].clone(), + ...this.tiles, + this.tiles[0].clone(), + ]; + this.wrapTiles(); + } + wrapTiles() { + this.tileNodes.forEach((tile) => { + this.element.appendChild(tile.element); + }); } - cancel() { - this.running = false; - clearTimeout(this.timer); + get lastTileOffset() { + return this.tiles[0].offset; } - pause() { - if (this.running) { - this.delay -= new Date().getTime() - this.startTime; - this.cancel(); + getTileOffset(index) { + let offset = 0; + for (let i = 0; i < index; i++) { + offset += this.tiles[i].offset; } + return -this.lastTileOffset - offset; } - resume() { - if (!this.running) { - this.running = true; - this.startTime = new Date().getTime(); - this._start(); - } + get maxTopOffset() { + return -1 * (this.tiles.reduce((acc, { offset }) => acc + offset, 0) + this.lastTileOffset); + } +} +class Tile { + constructor(element) { + this.element = element; + this.element.classList.add('slot-machine__tile'); } - reset() { - this.cancel(); - this.delay = this.initialDelay; - this._start(); + clone() { + const element = this.element.cloneNode(true); + return new Tile(element); } - add(extraDelay) { - this.pause(); - this.delay += extraDelay; - this.resume(); + get offset() { + return this.element.offsetHeight; } } -;// CONCATENATED MODULE: ./lib/slot-machine.ts - - -const defaults = { +;// CONCATENATED MODULE: ./lib/constants.ts +function randomInteger(min, max) { + return Math.floor(Math.random() * (max - min + 1)) + min; +} +const DEFAULTS = { active: 0, delay: 200, - auto: false, - spins: 5, - randomize: undefined, - onComplete: undefined, - inViewport: true, + randomize: (_, max) => randomInteger(0, max), direction: 'up', - transition: 'ease-in-out', }; -var FX; -(function (FX) { - FX["NO_TRANSITION"] = "slotMachineNoTransition"; - FX["FAST"] = "slotMachineBlurFast"; - FX["NORMAL"] = "slotMachineBlurMedium"; - FX["SLOW"] = "slotMachineBlurSlow"; - FX["TURTLE"] = "slotMachineBlurTurtle"; - FX["GRADIENT"] = "slotMachineGradient"; - FX["STOP"] = "slotMachineGradient"; -})(FX || (FX = {})); +var CONTAINER_FX; +(function (CONTAINER_FX) { + CONTAINER_FX["GRADIENT"] = "slot-machine__container--gradient"; +})(CONTAINER_FX || (CONTAINER_FX = {})); +var TILE_FX; +(function (TILE_FX) { + TILE_FX["NO_TRANSITION"] = "slot-machine__tile--no-transition"; + TILE_FX["FAST"] = "slot-machine__tile--blur-fast"; + TILE_FX["NORMAL"] = "slot-machine__tile--blur-medium"; + TILE_FX["SLOW"] = "slot-machine__tile--blur-slow"; + TILE_FX["TURTLE"] = "slot-machine__tile--blur-turtle"; + TILE_FX["STOP"] = "slot-machine__tile--gradient"; +})(TILE_FX || (TILE_FX = {})); + +;// CONCATENATED MODULE: ./lib/index.ts + + + +const timeout = (delay) => new Promise((res) => setTimeout(res, delay)); class SlotMachine { constructor(element, options) { - this.element = element; - this.tiles = [].slice.call(this.element.children); this.running = false; this.stopping = false; - this.element.style.overflow = 'hidden'; - this._wrapTiles(); - this._minTop = -this._fakeFirstTile.offsetHeight; - this._maxTop = -this.tiles.reduce((acc, tile) => acc + tile.offsetHeight, 0); - this.changeSettings({ ...defaults, ...options }); - this._setBounds(); + this.element = element; + this.container = new Container(this.element); + this.setOptions(options); + this.active = this.options.active; + this.setupBounds(); this._resetPosition(); - if (this.auto) { - this.run(); - } } - changeSettings(options) { - Object.keys(options).forEach((key) => { - this[key] = options[key]; - }); - } - _wrapTiles() { - this.container = document.createElement('div'); - this.container.classList.add('slotMachineContainer'); - this.container.style.transition = '1s ease-in-out'; - this.element.appendChild(this.container); - this._fakeFirstTile = this.tiles[this.tiles.length - 1].cloneNode(true); - this.container.appendChild(this._fakeFirstTile); - this.tiles.forEach((tile) => { - this.container.appendChild(tile); - }); - this._fakeLastTile = this.tiles[0].cloneNode(true); - this.container.appendChild(this._fakeLastTile); + setOptions(options) { + this.options = { ...DEFAULTS, ...options }; } - _setBounds() { - const initial = this.getTileOffset(this.active); - const first = this.getTileOffset(this.tiles.length); - const last = this.getTileOffset(this.tiles.length); + setupBounds() { + const initial = this.container.getTileOffset(this.active); + const first = this.container.getTileOffset(0); + const last = this.container.getTileOffset(this.container.tiles.length - 1); this._bounds = { up: { - key: 'up', initial, - first: 0, - last, - to: this._maxTop, - firstToLast: last, - lastToFirst: 0, + from: last, + to: 0, + nextReset: 0, + prevReset: this.container.maxTopOffset, }, down: { - key: 'down', initial, - first, - last: 0, - to: this._minTop, - firstToLast: last, - lastToFirst: 0, + from: first, + to: this.container.maxTopOffset, + nextReset: 0, + prevReset: this.container.maxTopOffset, }, }; } + get bounds() { + return this._bounds[this.options.direction]; + } get active() { return this._active; } set active(index) { - if (index < 0 || index >= this.tiles.length || isNaN(index)) { + if (index < 0 || index >= this.container.tiles.length || isNaN(index)) { index = 0; } this._active = index; } - get direction() { - return this._direction; - } - set direction(direction) { - if (this.running) { - return; - } - this._direction = direction === 'down' ? 'down' : 'up'; - } - get bounds() { - return this._bounds[this._direction]; - } get transition() { return this._transition; } set transition(transition) { this._transition = transition || 'ease-in-out'; } - get visibleTile() { - const firstTileHeight = this.tiles[0].offsetHeight; - const rawContainerMargin = this.container.style.transform || ''; - const matrixRegExp = /^matrix\(-?\d+,\s?-?\d+,\s?-?\d+,\s?-?\d+,\s?-?\d+,\s?(-?\d+)\)$/; - const containerMargin = parseInt(rawContainerMargin.replace(matrixRegExp, '$1'), 10); - return Math.abs(Math.round(containerMargin / firstTileHeight)) - 1; - } - get random() { - return Math.floor(Math.random() * this.tiles.length); - } - get custom() { - let choosen = this.random; - if (this.randomize) { - let index = this.randomize(this.active); - if (index < 0 || index >= this.tiles.length) { - index = 0; - } - choosen = index; - } - return choosen; - } get _prevIndex() { const prevIndex = this.active - 1; - return prevIndex < 0 ? this.tiles.length - 1 : prevIndex; + return prevIndex < 0 ? this.container.tiles.length - 1 : prevIndex; } get _nextIndex() { const nextIndex = this.active + 1; - return nextIndex < this.tiles.length ? nextIndex : 0; + return nextIndex < this.container.tiles.length ? nextIndex : 0; } get prevIndex() { - return this.direction === 'up' ? this._nextIndex : this._prevIndex; + return this.options.direction === 'up' ? this._nextIndex : this._prevIndex; } get nextIndex() { - return this.direction === 'up' ? this._prevIndex : this._nextIndex; - } - get visible() { - const rect = this.element.getBoundingClientRect(); - const windowHeight = window.innerHeight || document.documentElement.clientHeight; - const windowWidth = window.innerWidth || document.documentElement.clientWidth; - const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0; - const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0; - return vertInView && horInView; + return this.options.direction === 'up' ? this._prevIndex : this._nextIndex; } set _animationFX(effect) { - const delay = this.delay / 4; - raf_raf(() => { - [...this.tiles, this._fakeLastTile, this._fakeFirstTile].forEach((tile) => { - tile.classList.remove(FX.FAST, FX.NORMAL, FX.SLOW, FX.TURTLE); - if (effect !== FX.STOP) { + const delay = this.options.delay / 4; + raf(() => { + this.container.tiles + .map(({ element }) => element) + .forEach((tile) => { + tile.classList.remove(TILE_FX.FAST, TILE_FX.NORMAL, TILE_FX.SLOW, TILE_FX.TURTLE); + if (effect !== TILE_FX.STOP) { tile.classList.add(effect); } }); - if (effect === FX.STOP) { - this.container.classList.remove(FX.GRADIENT); + if (effect === TILE_FX.STOP) { + this.container.element.classList.remove(CONTAINER_FX.GRADIENT); } else { - this.container.classList.add(FX.GRADIENT); + this.container.element.classList.add(CONTAINER_FX.GRADIENT); } }, delay); } - _changeTransition(delay = this.delay, transition = this.transition) { - this.container.style.transition = `${delay / 1000}s ${transition}`; + _changeTransition(delay = this.options.delay, transition = this.transition) { + this.container.element.style.transition = `${delay / 1000}s ${transition}`; } _changeTransform(margin) { - this.container.style.transform = `matrix(1, 0, 0, 1, 0, ${margin})`; + this.container.element.style.transform = `matrix(1, 0, 0, 1, 0, ${margin})`; } _isGoingBackward() { - return !!(this.active === 0 && - this.nextActive === this.tiles.length - 1); + return !!(this.active === 0 && this.nextActive === this.container.tiles.length - 1); } _isGoingForward() { - return !!(this.active === this.tiles.length - 1 && - this.nextActive === 0); - } - getTileOffset(index) { - let offset = 0; - for (let i = 0; i < index; i++) { - offset += this.tiles[i].offsetHeight; - } - return this._minTop - offset; + return !!(this.active === this.container.tiles.length - 1 && this.nextActive === 0); } _resetPosition(margin) { - this.container.classList.toggle(FX.NO_TRANSITION); + this.container.element.classList.toggle(TILE_FX.NO_TRANSITION); this._changeTransform(margin !== undefined ? margin : this.bounds.initial); - this.container.offsetHeight; - this.container.classList.toggle(FX.NO_TRANSITION); + this.container.element.offsetHeight; + this.container.element.classList.toggle(TILE_FX.NO_TRANSITION); } - next() { - this.direction = 'down'; + async next() { this.nextActive = this.nextIndex; this.running = true; - this.stop(); - return this.nextActive; + await this.stop(0); + return this.active; } - prev() { - this.direction = 'up'; - this.nextActive = this.nextIndex; + async prev() { + this.nextActive = this.prevIndex; this.running = true; - this.stop(); - return this.nextActive; + await this.stop(0); + return this.active; } _getDelayFromSpins(spins) { - let delay = this.delay; + let delay = this.options.delay; this.transition = 'linear'; switch (spins) { case 1: delay /= 0.5; this.transition = 'ease-out'; - this._animationFX = FX.TURTLE; + this._animationFX = TILE_FX.TURTLE; break; case 2: delay /= 0.75; - this._animationFX = FX.SLOW; + this._animationFX = TILE_FX.SLOW; break; case 3: delay /= 1; - this._animationFX = FX.NORMAL; + this._animationFX = TILE_FX.NORMAL; break; case 4: delay /= 1.25; - this._animationFX = FX.NORMAL; + this._animationFX = TILE_FX.NORMAL; break; default: delay /= 1.5; - this._animationFX = FX.FAST; + this._animationFX = TILE_FX.FAST; } return delay; } - shuffle(spins, onComplete) { - if (typeof spins === 'function') { - onComplete = spins; + shuffle(spins) { + if (this.running || this.stopping) { + return; } + this.nextActive = this.options.randomize(this.active, this.container.tiles.length); + this.remainingSpins = spins; + return this._shuffle(); + } + async _shuffle() { this.running = true; - if (!this.visible && this.inViewport === true) { - this.stop(onComplete); - } - else { - const delay = this._getDelayFromSpins(spins); - this._changeTransition(delay); - this._changeTransform(this.bounds.to); - raf_raf(() => { - if (!this.stopping && this.running) { - const left = spins - 1; - this._resetPosition(this.bounds.first); - if (left > 1) { - this.shuffle(left, onComplete); - } - else { - this.stop(onComplete); - } - } - }, delay); + const delay = this._getDelayFromSpins(this.remainingSpins); + this._changeTransition(delay); + this._changeTransform(this.bounds.to); + await timeout(delay); + if (!this.stopping && this.running) { + this.remainingSpins--; + this._resetPosition(this.bounds.from); + if (this.remainingSpins > 1) { + await this._shuffle(); + } + else { + await this.stop(0); + } } - return this.nextActive; } - stop(onStop) { + async stop(spins = 0) { if (!this.running || this.stopping) { return this.nextActive; } + if (this.running && !this.stopping && spins) { + this.remainingSpins = spins; + return; + } this.running = true; this.stopping = true; - if (!Number.isInteger(this.nextActive)) { - this.nextActive = this.custom; - } if (this._isGoingBackward()) { - this._resetPosition(this.bounds.firstToLast); + this._resetPosition(this.bounds.prevReset); } else if (this._isGoingForward()) { - this._resetPosition(this.bounds.lastToFirst); + this._resetPosition(this.bounds.nextReset); } this.active = this.nextActive; const delay = this._getDelayFromSpins(1); this._changeTransition(delay); - this._animationFX = FX.STOP; - this._changeTransform(this.getTileOffset(this.active)); - raf_raf(() => { - this.stopping = false; - this.running = false; - this.nextActive = undefined; - if (typeof this.onComplete === 'function') { - this.onComplete(this.active); - } - if (typeof onStop === 'function') { - onStop.apply(this, [this.active]); - } - }, delay); - return this.active; - } - run() { - if (this.running) { - return; - } - this._timer = new Timer(() => { - if (!this.visible && this.inViewport === true) { - raf_raf(() => { - this._timer.reset(); - }, 500); - } - else { - this.shuffle(this.spins, () => { - this._timer.reset(); - }); - } - }, this.delay); - } - destroy() { - this._fakeFirstTile.remove(); - this._fakeLastTile.remove(); - this.tiles.forEach((tile) => { - this.element.appendChild(tile); - }); - this.container.remove(); + this._animationFX = TILE_FX.STOP; + this._changeTransform(this.container.getTileOffset(this.active)); + await timeout(delay); + this.stopping = false; + this.running = false; + this.nextActive = undefined; } } -;// CONCATENATED MODULE: ./lib/index.ts - -/* harmony default export */ const lib = (SlotMachine); - -})(); - __webpack_exports__ = __webpack_exports__["default"]; /******/ return __webpack_exports__; /******/ })() diff --git a/dist/slotmachine.js.map b/dist/slotmachine.js.map index 139956a..48dca52 100644 --- a/dist/slotmachine.js.map +++ b/dist/slotmachine.js.map @@ -1 +1 @@ -{"version":3,"file":"slotmachine.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;ACVA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA,IAAI;AACJ;AACA;AACA;AACA;AACA;;AAEA,CAAC;;AAED;;;;;;;;ACnCA,UAAU,mBAAO,CAAC,EAAiB;AACnC,2CAA2C,qBAAM;AACjD;AACA;AACA;AACA;;AAEA,eAAe,4BAA4B;AAC3C;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB,eAAe;AACtC;AACA;AACA;AACA,cAAc;AACd,sCAAsC,SAAS;AAC/C;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA,mBAAmB,kBAAkB;AACrC;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB;AACrB;AACA;AACA,uBAAuB;AACvB;AACA;AACA;AACA;AACA;AACA;;;;;;;UC1EA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAw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AAO,EAAE;YAChB,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE;gBAC7C,OAAG,CAAC,GAAG,EAAE;oBACP,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACtB,CAAC,EAAE,GAAG,CAAC,CAAC;aACT;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE;oBAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACtB,CAAC,CAAC,CAAC;aACJ;QACH,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;QAI5B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;CACF;;;ACpdwC;AAEzC,0CAAe,WAAW,EAAC","sources":["webpack://SlotMachine/webpack/universalModuleDefinition","webpack://SlotMachine/./node_modules/performance-now/lib/performance-now.js","webpack://SlotMachine/./node_modules/raf/index.js","webpack://SlotMachine/webpack/bootstrap","webpack://SlotMachine/webpack/runtime/compat get default export","webpack://SlotMachine/webpack/runtime/define property getters","webpack://SlotMachine/webpack/runtime/global","webpack://SlotMachine/webpack/runtime/hasOwnProperty shorthand","webpack://SlotMachine/./lib/raf.ts","webpack://SlotMachine/./lib/timer.ts","webpack://SlotMachine/./lib/slot-machine.ts","webpack://SlotMachine/./lib/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SlotMachine\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SlotMachine\"] = factory();\n\telse\n\t\troot[\"SlotMachine\"] = factory();\n})(self, () => {\nreturn ","// Generated by CoffeeScript 1.12.2\n(function() {\n var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;\n\n if ((typeof performance !== \"undefined\" && performance !== null) && performance.now) {\n module.exports = function() {\n return performance.now();\n };\n } else if ((typeof process !== \"undefined\" && process !== null) && process.hrtime) {\n module.exports = function() {\n return (getNanoSeconds() - nodeLoadTime) / 1e6;\n };\n hrtime = process.hrtime;\n getNanoSeconds = function() {\n var hr;\n hr = hrtime();\n return hr[0] * 1e9 + hr[1];\n };\n moduleLoadTime = getNanoSeconds();\n upTime = process.uptime() * 1e9;\n nodeLoadTime = moduleLoadTime - upTime;\n } else if (Date.now) {\n module.exports = function() {\n return Date.now() - loadTime;\n };\n loadTime = Date.now();\n } else {\n module.exports = function() {\n return new Date().getTime() - loadTime;\n };\n loadTime = new Date().getTime();\n }\n\n}).call(this);\n\n//# sourceMappingURL=performance-now.js.map\n","var now = require('performance-now')\n , root = typeof window === 'undefined' ? global : window\n , vendors = ['moz', 'webkit']\n , suffix = 'AnimationFrame'\n , raf = root['request' + suffix]\n , caf = root['cancel' + suffix] || root['cancelRequest' + suffix]\n\nfor(var i = 0; !raf && i < vendors.length; i++) {\n raf = root[vendors[i] + 'Request' + suffix]\n caf = root[vendors[i] + 'Cancel' + suffix]\n || root[vendors[i] + 'CancelRequest' + suffix]\n}\n\n// Some versions of FF have rAF but not cAF\nif(!raf || !caf) {\n var last = 0\n , id = 0\n , queue = []\n , frameDuration = 1000 / 60\n\n raf = function(callback) {\n if(queue.length === 0) {\n var _now = now()\n , next = Math.max(0, frameDuration - (_now - last))\n last = next + _now\n setTimeout(function() {\n var cp = queue.slice(0)\n // Clear queue here to prevent\n // callbacks from appending listeners\n // to the current frame's queue\n queue.length = 0\n for(var i = 0; i < cp.length; i++) {\n if(!cp[i].cancelled) {\n try{\n cp[i].callback(last)\n } catch(e) {\n setTimeout(function() { throw e }, 0)\n }\n }\n }\n }, Math.round(next))\n }\n queue.push({\n handle: ++id,\n callback: callback,\n cancelled: false\n })\n return id\n }\n\n caf = function(handle) {\n for(var i = 0; i < queue.length; i++) {\n if(queue[i].handle === handle) {\n queue[i].cancelled = true\n }\n }\n }\n}\n\nmodule.exports = function(fn) {\n // Wrap in a new function to prevent\n // `cancel` potentially being assigned\n // to the native rAF function\n return raf.call(root, fn)\n}\nmodule.exports.cancel = function() {\n caf.apply(root, arguments)\n}\nmodule.exports.polyfill = function(object) {\n if (!object) {\n object = root;\n }\n object.requestAnimationFrame = raf\n object.cancelAnimationFrame = caf\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import requestAnimationFrame from 'raf';\nimport { Callback } from './types';\n\nexport default function raf(cb: Callback, timeout = 0) {\n setTimeout(() => requestAnimationFrame(cb), timeout);\n}\n","import { Callback } from './types';\n\nexport default class Timer {\n cb: Callback;\n initialDelay: number;\n delay: number;\n startTime: number;\n timer: NodeJS.Timeout;\n running: boolean;\n\n constructor(cb: Callback, delay: number) {\n this.cb = cb;\n this.initialDelay = delay;\n this.delay = delay;\n this.running = false;\n\n this.resume();\n\n return this;\n }\n\n _start() {\n this.timer = setTimeout(() => {\n this.running = false;\n this.cb(this);\n }, this.delay);\n }\n\n cancel() {\n this.running = false;\n clearTimeout(this.timer);\n }\n\n pause() {\n if (this.running) {\n this.delay -= new Date().getTime() - this.startTime;\n this.cancel();\n }\n }\n\n resume() {\n if (!this.running) {\n this.running = true;\n this.startTime = new Date().getTime();\n\n this._start();\n }\n }\n\n reset() {\n this.cancel();\n this.delay = this.initialDelay;\n this._start();\n }\n\n add(extraDelay: number) {\n this.pause();\n this.delay += extraDelay;\n this.resume();\n }\n}\n","import raf from './raf';\nimport Timer from './timer';\n\nexport type RandomizeCallback = (active: number) => number;\nexport type OnCompleteCallback = (active: number) => any;\n\nexport type Direction = 'up' | 'down';\n\nexport type Bound = {\n key: Direction;\n initial: number;\n first: number;\n last: number;\n to: number;\n firstToLast: number;\n lastToFirst: number;\n};\n\nexport type Bounds = Record;\n\nexport type Options = {\n active?: number;\n delay?: number;\n auto?: boolean;\n spins?: number;\n randomize?: RandomizeCallback;\n onComplete?: OnCompleteCallback;\n inViewport?: boolean;\n direction?: Direction;\n transition?: string;\n};\n\nconst defaults: Options = {\n active: 0, // Active element [Number]\n delay: 200, // Animation time [Number]\n auto: false, // Repeat delay [false||Number]\n spins: 5, // Number of spins when auto [Number]\n randomize: undefined, // Randomize function, must return a number with the selected position\n onComplete: undefined, // Callback function(result)\n inViewport: true, // Stops animations if the element isn´t visible on the screen\n direction: 'up', // Animation direction ['up'||'down']\n transition: 'ease-in-out',\n};\n\nexport enum FX {\n NO_TRANSITION = 'slotMachineNoTransition',\n FAST = 'slotMachineBlurFast',\n NORMAL = 'slotMachineBlurMedium',\n SLOW = 'slotMachineBlurSlow',\n TURTLE = 'slotMachineBlurTurtle',\n GRADIENT = 'slotMachineGradient',\n STOP = 'slotMachineGradient',\n}\n\nexport default class SlotMachine implements Options {\n container: HTMLElement;\n element: HTMLElement;\n tiles: HTMLElement[];\n running: boolean;\n stopping: boolean;\n nextActive?: number;\n\n // options\n delay: number;\n auto: boolean;\n spins: number;\n randomize?: RandomizeCallback;\n onComplete?: OnCompleteCallback;\n inViewport: boolean;\n\n private _active: number;\n private _minTop: number;\n private _maxTop: number;\n private _fakeFirstTile: HTMLElement;\n private _fakeLastTile: HTMLElement;\n private _bounds: Bounds;\n private _direction: Direction;\n private _transition: string;\n private _timer: Timer;\n\n constructor(element: HTMLElement, options: Options) {\n this.element = element;\n // Slot Machine elements\n this.tiles = [].slice.call(this.element.children) as HTMLElement[];\n // Machine is running?\n this.running = false;\n // Machine is stopping?\n this.stopping = false;\n // Disable overflow\n this.element.style.overflow = 'hidden';\n // Wrap elements inside container\n this._wrapTiles();\n // Set min top offset\n this._minTop = -this._fakeFirstTile.offsetHeight;\n // Set max top offset\n this._maxTop = -this.tiles.reduce((acc, tile) => acc + tile.offsetHeight, 0);\n // Call setters if neccesary\n this.changeSettings({ ...defaults, ...options });\n // Initialize spin direction [up, down]\n this._setBounds();\n // Show active element\n this._resetPosition();\n // Start auto animation\n if (this.auto) {\n this.run();\n }\n }\n\n changeSettings(options: Options) {\n Object.keys(options).forEach((key) => {\n // Trigger setters\n this[key] = options[key]; /* @ts-ignore */\n });\n }\n\n _wrapTiles() {\n this.container = document.createElement('div');\n this.container.classList.add('slotMachineContainer');\n this.container.style.transition = '1s ease-in-out';\n this.element.appendChild(this.container);\n\n this._fakeFirstTile = this.tiles[this.tiles.length - 1].cloneNode(true) as HTMLElement;\n this.container.appendChild(this._fakeFirstTile);\n\n this.tiles.forEach((tile) => {\n this.container.appendChild(tile);\n });\n\n this._fakeLastTile = this.tiles[0].cloneNode(true) as HTMLElement;\n this.container.appendChild(this._fakeLastTile);\n }\n\n _setBounds() {\n const initial = this.getTileOffset(this.active);\n const first = this.getTileOffset(this.tiles.length);\n const last = this.getTileOffset(this.tiles.length);\n\n this._bounds = {\n up: {\n key: 'up',\n initial,\n first: 0,\n last,\n to: this._maxTop,\n firstToLast: last,\n lastToFirst: 0,\n },\n down: {\n key: 'down',\n initial,\n first,\n last: 0,\n to: this._minTop,\n firstToLast: last,\n lastToFirst: 0,\n },\n };\n }\n\n get active() {\n return this._active;\n }\n\n set active(index: number) {\n if (index < 0 || index >= this.tiles.length || isNaN(index)) {\n index = 0;\n }\n\n this._active = index;\n }\n\n get direction() {\n return this._direction;\n }\n\n set direction(direction: Direction) {\n if (this.running) {\n return;\n }\n\n this._direction = direction === 'down' ? 'down' : 'up';\n }\n\n get bounds() {\n return this._bounds[this._direction];\n }\n\n get transition() {\n return this._transition;\n }\n\n set transition(transition: string) {\n this._transition = transition || 'ease-in-out';\n }\n\n get visibleTile() {\n const firstTileHeight = this.tiles[0].offsetHeight;\n const rawContainerMargin = this.container.style.transform || '';\n const matrixRegExp = /^matrix\\(-?\\d+,\\s?-?\\d+,\\s?-?\\d+,\\s?-?\\d+,\\s?-?\\d+,\\s?(-?\\d+)\\)$/;\n const containerMargin = parseInt(rawContainerMargin.replace(matrixRegExp, '$1'), 10);\n\n return Math.abs(Math.round(containerMargin / firstTileHeight)) - 1;\n }\n\n get random() {\n return Math.floor(Math.random() * this.tiles.length);\n }\n\n get custom() {\n let choosen = this.random;\n\n if (this.randomize) {\n let index = this.randomize(this.active);\n if (index < 0 || index >= this.tiles.length) {\n index = 0;\n }\n choosen = index;\n }\n\n return choosen;\n }\n\n get _prevIndex() {\n const prevIndex = this.active - 1;\n\n return prevIndex < 0 ? this.tiles.length - 1 : prevIndex;\n }\n\n get _nextIndex() {\n const nextIndex = this.active + 1;\n\n return nextIndex < this.tiles.length ? nextIndex : 0;\n }\n\n get prevIndex() {\n return this.direction === 'up' ? this._nextIndex : this._prevIndex;\n }\n\n get nextIndex() {\n return this.direction === 'up' ? this._prevIndex : this._nextIndex;\n }\n\n get visible() {\n const rect = this.element.getBoundingClientRect();\n const windowHeight = window.innerHeight || document.documentElement.clientHeight;\n const windowWidth = window.innerWidth || document.documentElement.clientWidth;\n const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0;\n const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0;\n\n return vertInView && horInView;\n }\n\n set _animationFX(effect: FX) {\n const delay = this.delay / 4;\n\n raf(() => {\n [...this.tiles, this._fakeLastTile, this._fakeFirstTile].forEach((tile) => {\n tile.classList.remove(FX.FAST, FX.NORMAL, FX.SLOW, FX.TURTLE);\n if (effect !== FX.STOP) {\n tile.classList.add(effect);\n }\n });\n\n if (effect === FX.STOP) {\n this.container.classList.remove(FX.GRADIENT);\n } else {\n this.container.classList.add(FX.GRADIENT);\n }\n }, delay);\n }\n\n _changeTransition(delay = this.delay, transition = this.transition) {\n this.container.style.transition = `${delay / 1000}s ${transition}`;\n }\n\n _changeTransform(margin: number) {\n this.container.style.transform = `matrix(1, 0, 0, 1, 0, ${margin})`;\n }\n\n _isGoingBackward() {\n return !!(\n this.active === 0 &&\n this.nextActive === this.tiles.length - 1\n );\n }\n\n _isGoingForward() {\n return !!(\n this.active === this.tiles.length - 1 &&\n this.nextActive === 0\n );\n }\n\n getTileOffset(index: number) {\n let offset = 0;\n\n for (let i = 0; i < index; i++) {\n offset += this.tiles[i].offsetHeight;\n }\n\n return this._minTop - offset;\n }\n\n _resetPosition(margin?: number) {\n this.container.classList.toggle(FX.NO_TRANSITION);\n this._changeTransform(margin !== undefined ? margin : this.bounds.initial);\n // Force reflow, flushing the CSS changes\n this.container.offsetHeight;\n this.container.classList.toggle(FX.NO_TRANSITION);\n }\n\n next() {\n this.direction = 'down';\n this.nextActive = this.nextIndex;\n this.running = true;\n this.stop();\n\n return this.nextActive;\n }\n\n prev() {\n this.direction = 'up';\n this.nextActive = this.nextIndex;\n this.running = true;\n this.stop();\n\n return this.nextActive;\n }\n\n _getDelayFromSpins(spins: number) {\n let delay = this.delay;\n this.transition = 'linear';\n\n switch (spins) {\n case 1:\n delay /= 0.5;\n this.transition = 'ease-out';\n this._animationFX = FX.TURTLE;\n break;\n case 2:\n delay /= 0.75;\n this._animationFX = FX.SLOW;\n break;\n case 3:\n delay /= 1;\n this._animationFX = FX.NORMAL;\n break;\n case 4:\n delay /= 1.25;\n this._animationFX = FX.NORMAL;\n break;\n default:\n delay /= 1.5;\n this._animationFX = FX.FAST;\n }\n\n return delay;\n }\n\n shuffle(spins: number, onComplete: OnCompleteCallback) {\n // Make spins optional\n if (typeof spins === 'function') {\n onComplete = spins;\n }\n this.running = true;\n // Perform animation\n if (!this.visible && this.inViewport === true) {\n this.stop(onComplete);\n } else {\n const delay = this._getDelayFromSpins(spins);\n // this.delay = delay;\n this._changeTransition(delay);\n this._changeTransform(this.bounds.to);\n raf(() => {\n if (!this.stopping && this.running) {\n const left = spins - 1;\n\n this._resetPosition(this.bounds.first);\n\n if (left > 1) {\n // Repeat animation\n this.shuffle(left, onComplete);\n } else {\n this.stop(onComplete);\n }\n }\n }, delay);\n }\n\n return this.nextActive;\n }\n\n stop(onStop?: OnCompleteCallback) {\n if (!this.running || this.stopping) {\n return this.nextActive;\n }\n\n this.running = true;\n this.stopping = true;\n\n if (!Number.isInteger(this.nextActive)) {\n // Get random or custom element\n this.nextActive = this.custom;\n }\n\n // Check direction to prevent jumping\n if (this._isGoingBackward()) {\n this._resetPosition(this.bounds.firstToLast);\n } else if (this._isGoingForward()) {\n this._resetPosition(this.bounds.lastToFirst);\n }\n\n // Update last choosen element index\n this.active = this.nextActive as number;\n\n // Perform animation\n const delay = this._getDelayFromSpins(1);\n // this.delay = delay;\n this._changeTransition(delay);\n this._animationFX = FX.STOP;\n this._changeTransform(this.getTileOffset(this.active));\n raf(() => {\n this.stopping = false;\n this.running = false;\n this.nextActive = undefined;\n\n if (typeof this.onComplete === 'function') {\n this.onComplete(this.active);\n }\n\n if (typeof onStop === 'function') {\n onStop.apply(this, [this.active]);\n }\n }, delay);\n\n return this.active;\n }\n\n run() {\n if (this.running) {\n return;\n }\n\n this._timer = new Timer(() => {\n if (!this.visible && this.inViewport === true) {\n raf(() => {\n this._timer.reset();\n }, 500);\n } else {\n this.shuffle(this.spins, () => {\n this._timer.reset();\n });\n }\n }, this.delay);\n }\n\n destroy() {\n this._fakeFirstTile.remove();\n this._fakeLastTile.remove();\n // this.$tiles.unwrap();\n\n // Unwrap tiles\n this.tiles.forEach((tile) => {\n this.element.appendChild(tile);\n });\n\n this.container.remove();\n }\n}\n","import SlotMachine from './slot-machine';\n\nexport default SlotMachine;\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"slotmachine.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;UCVA;UACA;;;;;WCDA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;;;;;;;;ACEe,SAAS,GAAG,CAAC,EAAY,EAAE,OAAO,GAAG,CAAC;IACnD,UAAU,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;;;ACJM,MAAM,SAAS;IAKpB,YAAmB,SAAsB;QAAtB,cAAS,GAAT,SAAS,CAAa;QAHzC,UAAK,GAAW,EAAE,CAAC;QACnB,cAAS,GAAW,EAAE,CAAC;QAGrB,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK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QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAGrB,IAAI,IAAI,CAAC,gBAAgB,EAAE,EAAE;YAC3B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAC5C;aAAM,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE;YACjC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAC5C;QAGD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,UAAoB,CAAC;QAGxC,MAAM,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;QACzC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjE,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;QAErB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;CACF","sources":["webpack://SlotMachine/webpack/universalModuleDefinition","webpack://SlotMachine/webpack/bootstrap","webpack://SlotMachine/webpack/runtime/define property getters","webpack://SlotMachine/webpack/runtime/hasOwnProperty shorthand","webpack://SlotMachine/./lib/raf.ts","webpack://SlotMachine/./lib/dom.ts","webpack://SlotMachine/./lib/constants.ts","webpack://SlotMachine/./lib/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SlotMachine\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SlotMachine\"] = factory();\n\telse\n\t\troot[\"SlotMachine\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { Callback } from './types';\n\nexport default function raf(cb: Callback, timeout = 0) {\n setTimeout(() => requestAnimationFrame(cb), timeout);\n}\n","export class Container {\n element: HTMLElement;\n tiles: Tile[] = [];\n tileNodes: Tile[] = [];\n\n constructor(public container: HTMLElement) {\n const tileElements = [].slice.call(this.container.children) as HTMLElement[];\n\n this.container.style.overflow = 'hidden';\n this.element = document.createElement('div');\n this.element.classList.add('slot-machine__container');\n this.element.style.transition = '1s ease-in-out';\n this.container.appendChild(this.element);\n this.tiles = [...tileElements].map((element) => new Tile(element));\n this.tileNodes = [\n this.tiles[this.tiles.length - 1].clone(),\n ...this.tiles,\n this.tiles[0].clone(),\n ];\n this.wrapTiles();\n }\n\n private wrapTiles() {\n this.tileNodes.forEach((tile) => {\n this.element.appendChild(tile.element);\n });\n }\n\n private get lastTileOffset() {\n return this.tiles[0].offset;\n }\n\n getTileOffset(index: number) {\n let offset = 0;\n\n for (let i = 0; i < index; i++) {\n offset += this.tiles[i].offset;\n }\n\n return -this.lastTileOffset - offset;\n }\n\n get maxTopOffset() {\n return -1 * (this.tiles.reduce((acc, { offset }) => acc + offset, 0) + this.lastTileOffset);\n }\n}\n\nexport class Tile {\n constructor(public element: HTMLElement) {\n this.element.classList.add('slot-machine__tile');\n }\n\n clone() {\n const element = this.element.cloneNode(true) as HTMLElement;\n\n return new Tile(element);\n }\n\n get offset() {\n return this.element.offsetHeight;\n }\n}\n","import { Options } from './types';\n\nfunction randomInteger(min: number, max: number) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\nexport const DEFAULTS: Required = {\n active: 0, // Active element [Number]\n delay: 200, // Animation time [Number]\n randomize: (_, max) => randomInteger(0, max), // Randomize function, must return a number with the selected position\n direction: 'up', // Animation direction ['up'||'down']\n};\n\nexport enum CONTAINER_FX {\n GRADIENT = 'slot-machine__container--gradient',\n}\n\nexport enum TILE_FX {\n NO_TRANSITION = 'slot-machine__tile--no-transition',\n FAST = 'slot-machine__tile--blur-fast',\n NORMAL = 'slot-machine__tile--blur-medium',\n SLOW = 'slot-machine__tile--blur-slow',\n TURTLE = 'slot-machine__tile--blur-turtle',\n STOP = 'slot-machine__tile--gradient',\n}\n","import raf from './raf';\nimport { Container } from './dom';\nimport type { Bounds, Options } from './types';\nimport { DEFAULTS, TILE_FX, CONTAINER_FX } from './constants';\n\nconst timeout = (delay: number) => new Promise((res) => setTimeout(res, delay));\n\nexport default class SlotMachine {\n container: Container;\n element: HTMLElement;\n running = false;\n stopping = false;\n nextActive?: number;\n\n private remainingSpins: number;\n private options: Required;\n private _active: number;\n private _bounds: Bounds;\n private _transition: string;\n\n constructor(element: HTMLElement, options: Options) {\n this.element = element;\n // Setup DOM\n this.container = new Container(this.element);\n // Set plugin options\n this.setOptions(options);\n this.active = this.options.active;\n this.setupBounds();\n // Show active element\n this._resetPosition();\n }\n\n setOptions(options: Options) {\n this.options = { ...DEFAULTS, ...options };\n }\n\n private setupBounds() {\n const initial = this.container.getTileOffset(this.active);\n const first = this.container.getTileOffset(0);\n const last = this.container.getTileOffset(this.container.tiles.length - 1);\n\n this._bounds = {\n up: {\n initial,\n from: last,\n to: 0,\n nextReset: 0,\n prevReset: this.container.maxTopOffset,\n },\n down: {\n initial,\n from: first,\n to: this.container.maxTopOffset,\n nextReset: 0,\n prevReset: this.container.maxTopOffset,\n },\n };\n }\n\n get bounds() {\n return this._bounds[this.options.direction];\n }\n\n get active() {\n return this._active;\n }\n\n set active(index: number) {\n if (index < 0 || index >= this.container.tiles.length || isNaN(index)) {\n index = 0;\n }\n\n this._active = index;\n }\n\n private get transition() {\n return this._transition;\n }\n\n private set transition(transition: string) {\n this._transition = transition || 'ease-in-out';\n }\n\n get _prevIndex() {\n const prevIndex = this.active - 1;\n\n return prevIndex < 0 ? this.container.tiles.length - 1 : prevIndex;\n }\n\n get _nextIndex() {\n const nextIndex = this.active + 1;\n\n return nextIndex < this.container.tiles.length ? nextIndex : 0;\n }\n\n get prevIndex() {\n return this.options.direction === 'up' ? this._nextIndex : this._prevIndex;\n }\n\n get nextIndex() {\n return this.options.direction === 'up' ? this._prevIndex : this._nextIndex;\n }\n\n set _animationFX(effect: TILE_FX) {\n const delay = this.options.delay / 4;\n\n raf(() => {\n this.container.tiles\n .map(({ element }) => element)\n .forEach((tile) => {\n tile.classList.remove(TILE_FX.FAST, TILE_FX.NORMAL, TILE_FX.SLOW, TILE_FX.TURTLE);\n if (effect !== TILE_FX.STOP) {\n tile.classList.add(effect);\n }\n });\n\n if (effect === TILE_FX.STOP) {\n this.container.element.classList.remove(CONTAINER_FX.GRADIENT);\n } else {\n this.container.element.classList.add(CONTAINER_FX.GRADIENT);\n }\n }, delay);\n }\n\n _changeTransition(delay = this.options.delay, transition = this.transition) {\n this.container.element.style.transition = `${delay / 1000}s ${transition}`;\n }\n\n _changeTransform(margin: number) {\n this.container.element.style.transform = `matrix(1, 0, 0, 1, 0, ${margin})`;\n }\n\n _isGoingBackward() {\n return !!(this.active === 0 && this.nextActive === this.container.tiles.length - 1);\n }\n\n _isGoingForward() {\n return !!(this.active === this.container.tiles.length - 1 && this.nextActive === 0);\n }\n\n _resetPosition(margin?: number) {\n this.container.element.classList.toggle(TILE_FX.NO_TRANSITION);\n this._changeTransform(margin !== undefined ? margin : this.bounds.initial);\n // Force reflow, flushing the CSS changes\n this.container.element.offsetHeight;\n this.container.element.classList.toggle(TILE_FX.NO_TRANSITION);\n }\n\n async next() {\n this.nextActive = this.nextIndex;\n this.running = true;\n await this.stop(0);\n\n return this.active;\n }\n\n async prev() {\n this.nextActive = this.prevIndex;\n this.running = true;\n await this.stop(0);\n\n return this.active;\n }\n\n _getDelayFromSpins(spins: number) {\n let delay = this.options.delay;\n this.transition = 'linear';\n\n switch (spins) {\n case 1:\n delay /= 0.5;\n this.transition = 'ease-out';\n this._animationFX = TILE_FX.TURTLE;\n break;\n case 2:\n delay /= 0.75;\n this._animationFX = TILE_FX.SLOW;\n break;\n case 3:\n delay /= 1;\n this._animationFX = TILE_FX.NORMAL;\n break;\n case 4:\n delay /= 1.25;\n this._animationFX = TILE_FX.NORMAL;\n break;\n default:\n delay /= 1.5;\n this._animationFX = TILE_FX.FAST;\n }\n\n return delay;\n }\n\n shuffle(spins: number) {\n if (this.running || this.stopping) {\n return;\n }\n\n this.nextActive = this.options.randomize(this.active, this.container.tiles.length);\n this.remainingSpins = spins;\n\n return this._shuffle();\n }\n\n private async _shuffle() {\n this.running = true;\n // Perform animation\n const delay = this._getDelayFromSpins(this.remainingSpins);\n this._changeTransition(delay);\n this._changeTransform(this.bounds.to);\n\n await timeout(delay);\n\n if (!this.stopping && this.running) {\n this.remainingSpins--;\n\n this._resetPosition(this.bounds.from);\n\n if (this.remainingSpins > 1) {\n // Repeat animation\n await this._shuffle();\n } else {\n await this.stop(0);\n }\n }\n }\n\n async stop(spins = 0) {\n if (!this.running || this.stopping) {\n return this.nextActive;\n }\n\n if (this.running && !this.stopping && spins) {\n this.remainingSpins = spins;\n return;\n }\n\n this.running = true;\n this.stopping = true;\n\n // Check direction to prevent jumping\n if (this._isGoingBackward()) {\n this._resetPosition(this.bounds.prevReset);\n } else if (this._isGoingForward()) {\n this._resetPosition(this.bounds.nextReset);\n }\n\n // Update last choosen element index\n this.active = this.nextActive as number;\n\n // Perform animation\n const delay = this._getDelayFromSpins(1);\n this._changeTransition(delay);\n this._animationFX = TILE_FX.STOP;\n this._changeTransform(this.container.getTileOffset(this.active));\n\n await timeout(delay);\n\n this.stopping = false;\n this.running = false;\n this.nextActive = undefined;\n }\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/dist/slotmachine.min.js b/dist/slotmachine.min.js index 380d31b..01cbed5 100644 --- a/dist/slotmachine.min.js +++ b/dist/slotmachine.min.js @@ -1,2 +1,2 @@ -!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define("SlotMachine",[],i):"object"==typeof exports?exports.SlotMachine=i():t.SlotMachine=i()}(self,(()=>(()=>{var t={75:function(t){(function(){var i,e,s,n,r,o;"undefined"!=typeof performance&&null!==performance&&performance.now?t.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(t.exports=function(){return(i()-r)/1e6},e=process.hrtime,n=(i=function(){var t;return 1e9*(t=e())[0]+t[1]})(),o=1e9*process.uptime(),r=n-o):Date.now?(t.exports=function(){return Date.now()-s},s=Date.now()):(t.exports=function(){return(new Date).getTime()-s},s=(new Date).getTime())}).call(this)},87:(t,i,e)=>{for(var s=e(75),n="undefined"==typeof window?e.g:window,r=["moz","webkit"],o="AnimationFrame",h=n["request"+o],a=n["cancel"+o]||n["cancelRequest"+o],l=0;!h&&l{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),e.o=(t,i)=>Object.prototype.hasOwnProperty.call(t,i);var s={};return(()=>{"use strict";e.d(s,{default:()=>a});var t=e(87),i=e.n(t);function n(t,e=0){setTimeout((()=>i()(t)),e)}class r{constructor(t,i){return this.cb=t,this.initialDelay=i,this.delay=i,this.running=!1,this.resume(),this}_start(){this.timer=setTimeout((()=>{this.running=!1,this.cb(this)}),this.delay)}cancel(){this.running=!1,clearTimeout(this.timer)}pause(){this.running&&(this.delay-=(new Date).getTime()-this.startTime,this.cancel())}resume(){this.running||(this.running=!0,this.startTime=(new Date).getTime(),this._start())}reset(){this.cancel(),this.delay=this.initialDelay,this._start()}add(t){this.pause(),this.delay+=t,this.resume()}}const o={active:0,delay:200,auto:!1,spins:5,randomize:void 0,onComplete:void 0,inViewport:!0,direction:"up",transition:"ease-in-out"};var h;!function(t){t.NO_TRANSITION="slotMachineNoTransition",t.FAST="slotMachineBlurFast",t.NORMAL="slotMachineBlurMedium",t.SLOW="slotMachineBlurSlow",t.TURTLE="slotMachineBlurTurtle",t.GRADIENT="slotMachineGradient",t.STOP="slotMachineGradient"}(h||(h={}));const a=class{constructor(t,i){this.element=t,this.tiles=[].slice.call(this.element.children),this.running=!1,this.stopping=!1,this.element.style.overflow="hidden",this._wrapTiles(),this._minTop=-this._fakeFirstTile.offsetHeight,this._maxTop=-this.tiles.reduce(((t,i)=>t+i.offsetHeight),0),this.changeSettings({...o,...i}),this._setBounds(),this._resetPosition(),this.auto&&this.run()}changeSettings(t){Object.keys(t).forEach((i=>{this[i]=t[i]}))}_wrapTiles(){this.container=document.createElement("div"),this.container.classList.add("slotMachineContainer"),this.container.style.transition="1s ease-in-out",this.element.appendChild(this.container),this._fakeFirstTile=this.tiles[this.tiles.length-1].cloneNode(!0),this.container.appendChild(this._fakeFirstTile),this.tiles.forEach((t=>{this.container.appendChild(t)})),this._fakeLastTile=this.tiles[0].cloneNode(!0),this.container.appendChild(this._fakeLastTile)}_setBounds(){const t=this.getTileOffset(this.active),i=this.getTileOffset(this.tiles.length),e=this.getTileOffset(this.tiles.length);this._bounds={up:{key:"up",initial:t,first:0,last:e,to:this._maxTop,firstToLast:e,lastToFirst:0},down:{key:"down",initial:t,first:i,last:0,to:this._minTop,firstToLast:e,lastToFirst:0}}}get active(){return this._active}set active(t){(t<0||t>=this.tiles.length||isNaN(t))&&(t=0),this._active=t}get direction(){return this._direction}set direction(t){this.running||(this._direction="down"===t?"down":"up")}get bounds(){return this._bounds[this._direction]}get transition(){return this._transition}set transition(t){this._transition=t||"ease-in-out"}get visibleTile(){const t=this.tiles[0].offsetHeight,i=this.container.style.transform||"",e=parseInt(i.replace(/^matrix\(-?\d+,\s?-?\d+,\s?-?\d+,\s?-?\d+,\s?-?\d+,\s?(-?\d+)\)$/,"$1"),10);return Math.abs(Math.round(e/t))-1}get random(){return Math.floor(Math.random()*this.tiles.length)}get custom(){let t=this.random;if(this.randomize){let i=this.randomize(this.active);(i<0||i>=this.tiles.length)&&(i=0),t=i}return t}get _prevIndex(){const t=this.active-1;return t<0?this.tiles.length-1:t}get _nextIndex(){const t=this.active+1;return t=0,n=t.left<=e&&t.left+t.width>=0;return s&&n}set _animationFX(t){n((()=>{[...this.tiles,this._fakeLastTile,this._fakeFirstTile].forEach((i=>{i.classList.remove(h.FAST,h.NORMAL,h.SLOW,h.TURTLE),t!==h.STOP&&i.classList.add(t)})),t===h.STOP?this.container.classList.remove(h.GRADIENT):this.container.classList.add(h.GRADIENT)}),this.delay/4)}_changeTransition(t=this.delay,i=this.transition){this.container.style.transition=`${t/1e3}s ${i}`}_changeTransform(t){this.container.style.transform=`matrix(1, 0, 0, 1, 0, ${t})`}_isGoingBackward(){return!(0!==this.active||this.nextActive!==this.tiles.length-1)}_isGoingForward(){return!(this.active!==this.tiles.length-1||0!==this.nextActive)}getTileOffset(t){let i=0;for(let e=0;e{if(!this.stopping&&this.running){const e=t-1;this._resetPosition(this.bounds.first),e>1?this.shuffle(e,i):this.stop(i)}}),e)}else this.stop(i);return this.nextActive}stop(t){if(!this.running||this.stopping)return this.nextActive;this.running=!0,this.stopping=!0,Number.isInteger(this.nextActive)||(this.nextActive=this.custom),this._isGoingBackward()?this._resetPosition(this.bounds.firstToLast):this._isGoingForward()&&this._resetPosition(this.bounds.lastToFirst),this.active=this.nextActive;const i=this._getDelayFromSpins(1);return this._changeTransition(i),this._animationFX=h.STOP,this._changeTransform(this.getTileOffset(this.active)),n((()=>{this.stopping=!1,this.running=!1,this.nextActive=void 0,"function"==typeof this.onComplete&&this.onComplete(this.active),"function"==typeof t&&t.apply(this,[this.active])}),i),this.active}run(){this.running||(this._timer=new r((()=>{this.visible||!0!==this.inViewport?this.shuffle(this.spins,(()=>{this._timer.reset()})):n((()=>{this._timer.reset()}),500)}),this.delay))}destroy(){this._fakeFirstTile.remove(),this._fakeLastTile.remove(),this.tiles.forEach((t=>{this.element.appendChild(t)})),this.container.remove()}}})(),s=s.default})())); +!function(t,i){"object"==typeof exports&&"object"==typeof module?module.exports=i():"function"==typeof define&&define.amd?define("SlotMachine",[],i):"object"==typeof exports?exports.SlotMachine=i():t.SlotMachine=i()}(self,(()=>(()=>{"use strict";var t={d:(i,e)=>{for(var s in e)t.o(e,s)&&!t.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:e[s]})},o:(t,i)=>Object.prototype.hasOwnProperty.call(t,i)},i={};t.d(i,{default:()=>h});class e{constructor(t){this.container=t,this.tiles=[],this.tileNodes=[];const i=[].slice.call(this.container.children);this.container.style.overflow="hidden",this.element=document.createElement("div"),this.element.classList.add("slot-machine__container"),this.element.style.transition="1s ease-in-out",this.container.appendChild(this.element),this.tiles=[...i].map((t=>new s(t))),this.tileNodes=[this.tiles[this.tiles.length-1].clone(),...this.tiles,this.tiles[0].clone()],this.wrapTiles()}wrapTiles(){this.tileNodes.forEach((t=>{this.element.appendChild(t.element)}))}get lastTileOffset(){return this.tiles[0].offset}getTileOffset(t){let i=0;for(let e=0;et+i),0)+this.lastTileOffset)}}class s{constructor(t){this.element=t,this.element.classList.add("slot-machine__tile")}clone(){const t=this.element.cloneNode(!0);return new s(t)}get offset(){return this.element.offsetHeight}}const n={active:0,delay:200,randomize:(t,i)=>function(t,i){return Math.floor(Math.random()*(i-t+1))+t}(0,i),direction:"up"};var o,a;!function(t){t.GRADIENT="slot-machine__container--gradient"}(o||(o={})),function(t){t.NO_TRANSITION="slot-machine__tile--no-transition",t.FAST="slot-machine__tile--blur-fast",t.NORMAL="slot-machine__tile--blur-medium",t.SLOW="slot-machine__tile--blur-slow",t.TURTLE="slot-machine__tile--blur-turtle",t.STOP="slot-machine__tile--gradient"}(a||(a={}));const r=t=>new Promise((i=>setTimeout(i,t)));class h{constructor(t,i){this.running=!1,this.stopping=!1,this.element=t,this.container=new e(this.element),this.setOptions(i),this.active=this.options.active,this.setupBounds(),this._resetPosition()}setOptions(t){this.options={...n,...t}}setupBounds(){const t=this.container.getTileOffset(this.active),i=this.container.getTileOffset(0),e=this.container.getTileOffset(this.container.tiles.length-1);this._bounds={up:{initial:t,from:e,to:0,nextReset:0,prevReset:this.container.maxTopOffset},down:{initial:t,from:i,to:this.container.maxTopOffset,nextReset:0,prevReset:this.container.maxTopOffset}}}get bounds(){return this._bounds[this.options.direction]}get active(){return this._active}set active(t){(t<0||t>=this.container.tiles.length||isNaN(t))&&(t=0),this._active=t}get transition(){return this._transition}set transition(t){this._transition=t||"ease-in-out"}get _prevIndex(){const t=this.active-1;return t<0?this.container.tiles.length-1:t}get _nextIndex(){const t=this.active+1;return trequestAnimationFrame(t)),i)}((()=>{this.container.tiles.map((({element:t})=>t)).forEach((i=>{i.classList.remove(a.FAST,a.NORMAL,a.SLOW,a.TURTLE),t!==a.STOP&&i.classList.add(t)})),t===a.STOP?this.container.element.classList.remove(o.GRADIENT):this.container.element.classList.add(o.GRADIENT)}),this.options.delay/4)}_changeTransition(t=this.options.delay,i=this.transition){this.container.element.style.transition=`${t/1e3}s ${i}`}_changeTransform(t){this.container.element.style.transform=`matrix(1, 0, 0, 1, 0, ${t})`}_isGoingBackward(){return!(0!==this.active||this.nextActive!==this.container.tiles.length-1)}_isGoingForward(){return!(this.active!==this.container.tiles.length-1||0!==this.nextActive)}_resetPosition(t){this.container.element.classList.toggle(a.NO_TRANSITION),this._changeTransform(void 0!==t?t:this.bounds.initial),this.container.element.offsetHeight,this.container.element.classList.toggle(a.NO_TRANSITION)}async next(){return this.nextActive=this.nextIndex,this.running=!0,await this.stop(0),this.active}async prev(){return this.nextActive=this.prevIndex,this.running=!0,await this.stop(0),this.active}_getDelayFromSpins(t){let i=this.options.delay;switch(this.transition="linear",t){case 1:i/=.5,this.transition="ease-out",this._animationFX=a.TURTLE;break;case 2:i/=.75,this._animationFX=a.SLOW;break;case 3:i/=1,this._animationFX=a.NORMAL;break;case 4:i/=1.25,this._animationFX=a.NORMAL;break;default:i/=1.5,this._animationFX=a.FAST}return i}shuffle(t){if(!this.running&&!this.stopping)return this.nextActive=this.options.randomize(this.active,this.container.tiles.length),this.remainingSpins=t,this._shuffle()}async _shuffle(){this.running=!0;const t=this._getDelayFromSpins(this.remainingSpins);this._changeTransition(t),this._changeTransform(this.bounds.to),await r(t),!this.stopping&&this.running&&(this.remainingSpins--,this._resetPosition(this.bounds.from),this.remainingSpins>1?await this._shuffle():await this.stop(0))}async stop(t=0){if(!this.running||this.stopping)return this.nextActive;if(this.running&&!this.stopping&&t)return void(this.remainingSpins=t);this.running=!0,this.stopping=!0,this._isGoingBackward()?this._resetPosition(this.bounds.prevReset):this._isGoingForward()&&this._resetPosition(this.bounds.nextReset),this.active=this.nextActive;const i=this._getDelayFromSpins(1);this._changeTransition(i),this._animationFX=a.STOP,this._changeTransform(this.container.getTileOffset(this.active)),await r(i),this.stopping=!1,this.running=!1,this.nextActive=void 0}}return i=i.default})())); //# sourceMappingURL=slotmachine.min.js.map \ No newline at end of file diff --git a/dist/slotmachine.min.js.map b/dist/slotmachine.min.js.map index 2ab8969..4267b7e 100644 --- a/dist/slotmachine.min.js.map +++ b/dist/slotmachine.min.js.map @@ -1 +1 @@ -{"version":3,"file":"slotmachine.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,MAAM,I,6BCRT,WACE,IAAIC,EAAgBC,EAAQC,EAAUC,EAAgBC,E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BAApBrC,KAAK8E,YACd9E,KAAK8E,WAAW9E,KAAK0E,QAGD,mBAAX0G,GACTA,EAAOzJ,MAAM3B,KAAM,CAACA,KAAK0E,Q,GAE1Bb,GAEI7D,KAAK0E,MACd,CAEA2B,MACMrG,KAAK+D,UAIT/D,KAAKuL,OAAS,IAAI5H,GAAM,KACjB3D,KAAK8I,UAA+B,IAApB9I,KAAK+E,WAKxB/E,KAAKmL,QAAQnL,KAAK4E,OAAO,KACvB5E,KAAKuL,OAAOjH,OAAO,IALrB,GAAI,KACFtE,KAAKuL,OAAOjH,OAAO,GAClB,I,GAMJtE,KAAK6D,OACV,CAEA2H,UACExL,KAAK4F,eAAeoE,SACpBhK,KAAK8G,cAAckD,SAInBhK,KAAKqF,MAAMkB,SAASN,IAClBjG,KAAKmF,QAAQyB,YAAYX,EAAK,IAGhCjG,KAAKwG,UAAUwD,QACjB,E","sources":["webpack://SlotMachine/webpack/universalModuleDefinition","webpack://SlotMachine/./node_modules/performance-now/lib/performance-now.js","webpack://SlotMachine/./node_modules/raf/index.js","webpack://SlotMachine/webpack/bootstrap","webpack://SlotMachine/webpack/runtime/compat get default export","webpack://SlotMachine/webpack/runtime/define property getters","webpack://SlotMachine/webpack/runtime/global","webpack://SlotMachine/webpack/runtime/hasOwnProperty shorthand","webpack://SlotMachine/./lib/raf.ts","webpack://SlotMachine/./lib/timer.ts","webpack://SlotMachine/./lib/slot-machine.ts","webpack://SlotMachine/./lib/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SlotMachine\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SlotMachine\"] = factory();\n\telse\n\t\troot[\"SlotMachine\"] = factory();\n})(self, () => {\nreturn ","// Generated by CoffeeScript 1.12.2\n(function() {\n var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;\n\n if ((typeof performance !== \"undefined\" && performance !== null) && performance.now) {\n module.exports = function() {\n return performance.now();\n };\n } else if ((typeof process !== \"undefined\" && process !== null) && process.hrtime) {\n module.exports = function() {\n return (getNanoSeconds() - nodeLoadTime) / 1e6;\n };\n hrtime = process.hrtime;\n getNanoSeconds = function() {\n var hr;\n hr = hrtime();\n return hr[0] * 1e9 + hr[1];\n };\n moduleLoadTime = getNanoSeconds();\n upTime = process.uptime() * 1e9;\n nodeLoadTime = moduleLoadTime - upTime;\n } else if (Date.now) {\n module.exports = function() {\n return Date.now() - loadTime;\n };\n loadTime = Date.now();\n } else {\n module.exports = function() {\n return new Date().getTime() - loadTime;\n };\n loadTime = new Date().getTime();\n }\n\n}).call(this);\n\n//# sourceMappingURL=performance-now.js.map\n","var now = require('performance-now')\n , root = typeof window === 'undefined' ? global : window\n , vendors = ['moz', 'webkit']\n , suffix = 'AnimationFrame'\n , raf = root['request' + suffix]\n , caf = root['cancel' + suffix] || root['cancelRequest' + suffix]\n\nfor(var i = 0; !raf && i < vendors.length; i++) {\n raf = root[vendors[i] + 'Request' + suffix]\n caf = root[vendors[i] + 'Cancel' + suffix]\n || root[vendors[i] + 'CancelRequest' + suffix]\n}\n\n// Some versions of FF have rAF but not cAF\nif(!raf || !caf) {\n var last = 0\n , id = 0\n , queue = []\n , frameDuration = 1000 / 60\n\n raf = function(callback) {\n if(queue.length === 0) {\n var _now = now()\n , next = Math.max(0, frameDuration - (_now - last))\n last = next + _now\n setTimeout(function() {\n var cp = queue.slice(0)\n // Clear queue here to prevent\n // callbacks from appending listeners\n // to the current frame's queue\n queue.length = 0\n for(var i = 0; i < cp.length; i++) {\n if(!cp[i].cancelled) {\n try{\n cp[i].callback(last)\n } catch(e) {\n setTimeout(function() { throw e }, 0)\n }\n }\n }\n }, Math.round(next))\n }\n queue.push({\n handle: ++id,\n callback: callback,\n cancelled: false\n })\n return id\n }\n\n caf = function(handle) {\n for(var i = 0; i < queue.length; i++) {\n if(queue[i].handle === handle) {\n queue[i].cancelled = true\n }\n }\n }\n}\n\nmodule.exports = function(fn) {\n // Wrap in a new function to prevent\n // `cancel` potentially being assigned\n // to the native rAF function\n return raf.call(root, fn)\n}\nmodule.exports.cancel = function() {\n caf.apply(root, arguments)\n}\nmodule.exports.polyfill = function(object) {\n if (!object) {\n object = root;\n }\n object.requestAnimationFrame = raf\n object.cancelAnimationFrame = caf\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import requestAnimationFrame from 'raf';\nimport { Callback } from './types';\n\nexport default function raf(cb: Callback, timeout = 0) {\n setTimeout(() => requestAnimationFrame(cb), timeout);\n}\n","import { Callback } from './types';\n\nexport default class Timer {\n cb: Callback;\n initialDelay: number;\n delay: number;\n startTime: number;\n timer: NodeJS.Timeout;\n running: boolean;\n\n constructor(cb: Callback, delay: number) {\n this.cb = cb;\n this.initialDelay = delay;\n this.delay = delay;\n this.running = false;\n\n this.resume();\n\n return this;\n }\n\n _start() {\n this.timer = setTimeout(() => {\n this.running = false;\n this.cb(this);\n }, this.delay);\n }\n\n cancel() {\n this.running = false;\n clearTimeout(this.timer);\n }\n\n pause() {\n if (this.running) {\n this.delay -= new Date().getTime() - this.startTime;\n this.cancel();\n }\n }\n\n resume() {\n if (!this.running) {\n this.running = true;\n this.startTime = new Date().getTime();\n\n this._start();\n }\n }\n\n reset() {\n this.cancel();\n this.delay = this.initialDelay;\n this._start();\n }\n\n add(extraDelay: number) {\n this.pause();\n this.delay += extraDelay;\n this.resume();\n }\n}\n","import raf from './raf';\nimport Timer from './timer';\n\nexport type RandomizeCallback = (active: number) => number;\nexport type OnCompleteCallback = (active: number) => any;\n\nexport type Direction = 'up' | 'down';\n\nexport type Bound = {\n key: Direction;\n initial: number;\n first: number;\n last: number;\n to: number;\n firstToLast: number;\n lastToFirst: number;\n};\n\nexport type Bounds = Record;\n\nexport type Options = {\n active?: number;\n delay?: number;\n auto?: boolean;\n spins?: number;\n randomize?: RandomizeCallback;\n onComplete?: OnCompleteCallback;\n inViewport?: boolean;\n direction?: Direction;\n transition?: string;\n};\n\nconst defaults: Options = {\n active: 0, // Active element [Number]\n delay: 200, // Animation time [Number]\n auto: false, // Repeat delay [false||Number]\n spins: 5, // Number of spins when auto [Number]\n randomize: undefined, // Randomize function, must return a number with the selected position\n onComplete: undefined, // Callback function(result)\n inViewport: true, // Stops animations if the element isn´t visible on the screen\n direction: 'up', // Animation direction ['up'||'down']\n transition: 'ease-in-out',\n};\n\nexport enum FX {\n NO_TRANSITION = 'slotMachineNoTransition',\n FAST = 'slotMachineBlurFast',\n NORMAL = 'slotMachineBlurMedium',\n SLOW = 'slotMachineBlurSlow',\n TURTLE = 'slotMachineBlurTurtle',\n GRADIENT = 'slotMachineGradient',\n STOP = 'slotMachineGradient',\n}\n\nexport default class SlotMachine implements Options {\n container: HTMLElement;\n element: HTMLElement;\n tiles: HTMLElement[];\n running: boolean;\n stopping: boolean;\n nextActive?: number;\n\n // options\n delay: number;\n auto: boolean;\n spins: number;\n randomize?: RandomizeCallback;\n onComplete?: OnCompleteCallback;\n inViewport: boolean;\n\n private _active: number;\n private _minTop: number;\n private _maxTop: number;\n private _fakeFirstTile: HTMLElement;\n private _fakeLastTile: HTMLElement;\n private _bounds: Bounds;\n private _direction: Direction;\n private _transition: string;\n private _timer: Timer;\n\n constructor(element: HTMLElement, options: Options) {\n this.element = element;\n // Slot Machine elements\n this.tiles = [].slice.call(this.element.children) as HTMLElement[];\n // Machine is running?\n this.running = false;\n // Machine is stopping?\n this.stopping = false;\n // Disable overflow\n this.element.style.overflow = 'hidden';\n // Wrap elements inside container\n this._wrapTiles();\n // Set min top offset\n this._minTop = -this._fakeFirstTile.offsetHeight;\n // Set max top offset\n this._maxTop = -this.tiles.reduce((acc, tile) => acc + tile.offsetHeight, 0);\n // Call setters if neccesary\n this.changeSettings({ ...defaults, ...options });\n // Initialize spin direction [up, down]\n this._setBounds();\n // Show active element\n this._resetPosition();\n // Start auto animation\n if (this.auto) {\n this.run();\n }\n }\n\n changeSettings(options: Options) {\n Object.keys(options).forEach((key) => {\n // Trigger setters\n this[key] = options[key]; /* @ts-ignore */\n });\n }\n\n _wrapTiles() {\n this.container = document.createElement('div');\n this.container.classList.add('slotMachineContainer');\n this.container.style.transition = '1s ease-in-out';\n this.element.appendChild(this.container);\n\n this._fakeFirstTile = this.tiles[this.tiles.length - 1].cloneNode(true) as HTMLElement;\n this.container.appendChild(this._fakeFirstTile);\n\n this.tiles.forEach((tile) => {\n this.container.appendChild(tile);\n });\n\n this._fakeLastTile = this.tiles[0].cloneNode(true) as HTMLElement;\n this.container.appendChild(this._fakeLastTile);\n }\n\n _setBounds() {\n const initial = this.getTileOffset(this.active);\n const first = this.getTileOffset(this.tiles.length);\n const last = this.getTileOffset(this.tiles.length);\n\n this._bounds = {\n up: {\n key: 'up',\n initial,\n first: 0,\n last,\n to: this._maxTop,\n firstToLast: last,\n lastToFirst: 0,\n },\n down: {\n key: 'down',\n initial,\n first,\n last: 0,\n to: this._minTop,\n firstToLast: last,\n lastToFirst: 0,\n },\n };\n }\n\n get active() {\n return this._active;\n }\n\n set active(index: number) {\n if (index < 0 || index >= this.tiles.length || isNaN(index)) {\n index = 0;\n }\n\n this._active = index;\n }\n\n get direction() {\n return this._direction;\n }\n\n set direction(direction: Direction) {\n if (this.running) {\n return;\n }\n\n this._direction = direction === 'down' ? 'down' : 'up';\n }\n\n get bounds() {\n return this._bounds[this._direction];\n }\n\n get transition() {\n return this._transition;\n }\n\n set transition(transition: string) {\n this._transition = transition || 'ease-in-out';\n }\n\n get visibleTile() {\n const firstTileHeight = this.tiles[0].offsetHeight;\n const rawContainerMargin = this.container.style.transform || '';\n const matrixRegExp = /^matrix\\(-?\\d+,\\s?-?\\d+,\\s?-?\\d+,\\s?-?\\d+,\\s?-?\\d+,\\s?(-?\\d+)\\)$/;\n const containerMargin = parseInt(rawContainerMargin.replace(matrixRegExp, '$1'), 10);\n\n return Math.abs(Math.round(containerMargin / firstTileHeight)) - 1;\n }\n\n get random() {\n return Math.floor(Math.random() * this.tiles.length);\n }\n\n get custom() {\n let choosen = this.random;\n\n if (this.randomize) {\n let index = this.randomize(this.active);\n if (index < 0 || index >= this.tiles.length) {\n index = 0;\n }\n choosen = index;\n }\n\n return choosen;\n }\n\n get _prevIndex() {\n const prevIndex = this.active - 1;\n\n return prevIndex < 0 ? this.tiles.length - 1 : prevIndex;\n }\n\n get _nextIndex() {\n const nextIndex = this.active + 1;\n\n return nextIndex < this.tiles.length ? nextIndex : 0;\n }\n\n get prevIndex() {\n return this.direction === 'up' ? this._nextIndex : this._prevIndex;\n }\n\n get nextIndex() {\n return this.direction === 'up' ? this._prevIndex : this._nextIndex;\n }\n\n get visible() {\n const rect = this.element.getBoundingClientRect();\n const windowHeight = window.innerHeight || document.documentElement.clientHeight;\n const windowWidth = window.innerWidth || document.documentElement.clientWidth;\n const vertInView = rect.top <= windowHeight && rect.top + rect.height >= 0;\n const horInView = rect.left <= windowWidth && rect.left + rect.width >= 0;\n\n return vertInView && horInView;\n }\n\n set _animationFX(effect: FX) {\n const delay = this.delay / 4;\n\n raf(() => {\n [...this.tiles, this._fakeLastTile, this._fakeFirstTile].forEach((tile) => {\n tile.classList.remove(FX.FAST, FX.NORMAL, FX.SLOW, FX.TURTLE);\n if (effect !== FX.STOP) {\n tile.classList.add(effect);\n }\n });\n\n if (effect === FX.STOP) {\n this.container.classList.remove(FX.GRADIENT);\n } else {\n this.container.classList.add(FX.GRADIENT);\n }\n }, delay);\n }\n\n _changeTransition(delay = this.delay, transition = this.transition) {\n this.container.style.transition = `${delay / 1000}s ${transition}`;\n }\n\n _changeTransform(margin: number) {\n this.container.style.transform = `matrix(1, 0, 0, 1, 0, ${margin})`;\n }\n\n _isGoingBackward() {\n return !!(\n this.active === 0 &&\n this.nextActive === this.tiles.length - 1\n );\n }\n\n _isGoingForward() {\n return !!(\n this.active === this.tiles.length - 1 &&\n this.nextActive === 0\n );\n }\n\n getTileOffset(index: number) {\n let offset = 0;\n\n for (let i = 0; i < index; i++) {\n offset += this.tiles[i].offsetHeight;\n }\n\n return this._minTop - offset;\n }\n\n _resetPosition(margin?: number) {\n this.container.classList.toggle(FX.NO_TRANSITION);\n this._changeTransform(margin !== undefined ? margin : this.bounds.initial);\n // Force reflow, flushing the CSS changes\n this.container.offsetHeight;\n this.container.classList.toggle(FX.NO_TRANSITION);\n }\n\n next() {\n this.direction = 'down';\n this.nextActive = this.nextIndex;\n this.running = true;\n this.stop();\n\n return this.nextActive;\n }\n\n prev() {\n this.direction = 'up';\n this.nextActive = this.nextIndex;\n this.running = true;\n this.stop();\n\n return this.nextActive;\n }\n\n _getDelayFromSpins(spins: number) {\n let delay = this.delay;\n this.transition = 'linear';\n\n switch (spins) {\n case 1:\n delay /= 0.5;\n this.transition = 'ease-out';\n this._animationFX = FX.TURTLE;\n break;\n case 2:\n delay /= 0.75;\n this._animationFX = FX.SLOW;\n break;\n case 3:\n delay /= 1;\n this._animationFX = FX.NORMAL;\n break;\n case 4:\n delay /= 1.25;\n this._animationFX = FX.NORMAL;\n break;\n default:\n delay /= 1.5;\n this._animationFX = FX.FAST;\n }\n\n return delay;\n }\n\n shuffle(spins: number, onComplete: OnCompleteCallback) {\n // Make spins optional\n if (typeof spins === 'function') {\n onComplete = spins;\n }\n this.running = true;\n // Perform animation\n if (!this.visible && this.inViewport === true) {\n this.stop(onComplete);\n } else {\n const delay = this._getDelayFromSpins(spins);\n // this.delay = delay;\n this._changeTransition(delay);\n this._changeTransform(this.bounds.to);\n raf(() => {\n if (!this.stopping && this.running) {\n const left = spins - 1;\n\n this._resetPosition(this.bounds.first);\n\n if (left > 1) {\n // Repeat animation\n this.shuffle(left, onComplete);\n } else {\n this.stop(onComplete);\n }\n }\n }, delay);\n }\n\n return this.nextActive;\n }\n\n stop(onStop?: OnCompleteCallback) {\n if (!this.running || this.stopping) {\n return this.nextActive;\n }\n\n this.running = true;\n this.stopping = true;\n\n if (!Number.isInteger(this.nextActive)) {\n // Get random or custom element\n this.nextActive = this.custom;\n }\n\n // Check direction to prevent jumping\n if (this._isGoingBackward()) {\n this._resetPosition(this.bounds.firstToLast);\n } else if (this._isGoingForward()) {\n this._resetPosition(this.bounds.lastToFirst);\n }\n\n // Update last choosen element index\n this.active = this.nextActive as number;\n\n // Perform animation\n const delay = this._getDelayFromSpins(1);\n // this.delay = delay;\n this._changeTransition(delay);\n this._animationFX = FX.STOP;\n this._changeTransform(this.getTileOffset(this.active));\n raf(() => {\n this.stopping = false;\n this.running = false;\n this.nextActive = undefined;\n\n if (typeof this.onComplete === 'function') {\n this.onComplete(this.active);\n }\n\n if (typeof onStop === 'function') {\n onStop.apply(this, [this.active]);\n }\n }, delay);\n\n return this.active;\n }\n\n run() {\n if (this.running) {\n return;\n }\n\n this._timer = new Timer(() => {\n if (!this.visible && this.inViewport === true) {\n raf(() => {\n this._timer.reset();\n }, 500);\n } else {\n this.shuffle(this.spins, () => {\n this._timer.reset();\n });\n }\n }, this.delay);\n }\n\n destroy() {\n this._fakeFirstTile.remove();\n this._fakeLastTile.remove();\n // this.$tiles.unwrap();\n\n // Unwrap tiles\n this.tiles.forEach((tile) => {\n this.element.appendChild(tile);\n });\n\n this.container.remove();\n }\n}\n","import SlotMachine from './slot-machine';\n\nexport default SlotMachine;\n"],"names":["root","factory","exports","module","define","amd","self","getNanoSeconds","hrtime","loadTime","moduleLoadTime","nodeLoadTime","upTime","performance","now","process","hr","uptime","Date","getTime","call","this","window","g","vendors","suffix","raf","caf","i","length","last","id","queue","callback","_now","next","Math","max","setTimeout","cp","slice","cancelled","e","round","push","handle","fn","cancel","apply","arguments","polyfill","object","requestAnimationFrame","cancelAnimationFrame","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","globalThis","Function","obj","prop","prototype","hasOwnProperty","cb","timeout","Timer","constructor","delay","initialDelay","running","resume","_start","timer","clearTimeout","pause","startTime","reset","add","extraDelay","defaults","active","auto","spins","randomize","onComplete","inViewport","direction","transition","FX","element","options","tiles","children","stopping","style","overflow","_wrapTiles","_minTop","_fakeFirstTile","offsetHeight","_maxTop","reduce","acc","tile","changeSettings","_setBounds","_resetPosition","run","keys","forEach","container","document","createElement","classList","appendChild","cloneNode","_fakeLastTile","initial","getTileOffset","first","_bounds","up","to","firstToLast","lastToFirst","down","_active","index","isNaN","_direction","bounds","_transition","visibleTile","firstTileHeight","rawContainerMargin","transform","containerMargin","parseInt","replace","abs","random","floor","custom","choosen","_prevIndex","prevIndex","_nextIndex","nextIndex","visible","rect","getBoundingClientRect","windowHeight","innerHeight","documentElement","clientHeight","windowWidth","innerWidth","clientWidth","vertInView","top","height","horInView","left","width","_animationFX","effect","remove","FAST","NORMAL","SLOW","TURTLE","STOP","GRADIENT","_changeTransition","_changeTransform","margin","_isGoingBackward","nextActive","_isGoingForward","offset","toggle","NO_TRANSITION","stop","prev","_getDelayFromSpins","shuffle","onStop","Number","isInteger","_timer","destroy"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"slotmachine.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,GACvB,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,I,4BCA3E,MAAMI,EAKXC,YAAmBC,GAAA,KAAAA,UAAAA,EAHnB,KAAAC,MAAgB,GAChB,KAAAC,UAAoB,GAGlB,MAAMC,EAAe,GAAGC,MAAMP,KAAKQ,KAAKL,UAAUM,UAElDD,KAAKL,UAAUO,MAAMC,SAAW,SAChCH,KAAKI,QAAUC,SAASC,cAAc,OACtCN,KAAKI,QAAQG,UAAUC,IAAI,2BAC3BR,KAAKI,QAAQF,MAAMO,WAAa,iBAChCT,KAAKL,UAAUe,YAAYV,KAAKI,SAChCJ,KAAKJ,MAAQ,IAAIE,GAAca,KAAKP,GAAY,IAAIQ,EAAKR,KACzDJ,KAAKH,UAAY,CACfG,KAAKJ,MAAMI,KAAKJ,MAAMiB,OAAS,GAAGC,WAC/Bd,KAAKJ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Gd,GAAIxF,KAAKgD,UAAYhD,KAAKiD,UAAY+C,EAEpC,YADAhG,KAAKkG,eAAiBF,GAIxBhG,KAAKgD,SAAU,EACfhD,KAAKiD,UAAW,EAGZjD,KAAKuF,mBACPvF,KAAKoD,eAAepD,KAAK+D,OAAOF,WACvB7D,KAAKyF,mBACdzF,KAAKoD,eAAepD,KAAK+D,OAAOH,WAIlC5D,KAAK6B,OAAS7B,KAAKwF,WAGnB,MAAM1D,EAAQ9B,KAAK+F,mBAAmB,GACtC/F,KAAKmF,kBAAkBrD,GACvB9B,KAAKuE,aAAe9B,EAAQwC,KAC5BjF,KAAKoF,iBAAiBpF,KAAKL,UAAUyB,cAAcpB,KAAK6B,eAElDa,EAAQZ,GAEd9B,KAAKiD,UAAW,EAChBjD,KAAKgD,SAAU,EACfhD,KAAKwF,gBAAaI,CACpB,E","sources":["webpack://SlotMachine/webpack/universalModuleDefinition","webpack://SlotMachine/webpack/bootstrap","webpack://SlotMachine/webpack/runtime/define property getters","webpack://SlotMachine/webpack/runtime/hasOwnProperty shorthand","webpack://SlotMachine/./lib/dom.ts","webpack://SlotMachine/./lib/constants.ts","webpack://SlotMachine/./lib/index.ts","webpack://SlotMachine/./lib/raf.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"SlotMachine\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"SlotMachine\"] = factory();\n\telse\n\t\troot[\"SlotMachine\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export class Container {\n element: HTMLElement;\n tiles: Tile[] = [];\n tileNodes: Tile[] = [];\n\n constructor(public container: HTMLElement) {\n const tileElements = [].slice.call(this.container.children) as HTMLElement[];\n\n this.container.style.overflow = 'hidden';\n this.element = document.createElement('div');\n this.element.classList.add('slot-machine__container');\n this.element.style.transition = '1s ease-in-out';\n this.container.appendChild(this.element);\n this.tiles = [...tileElements].map((element) => new Tile(element));\n this.tileNodes = [\n this.tiles[this.tiles.length - 1].clone(),\n ...this.tiles,\n this.tiles[0].clone(),\n ];\n this.wrapTiles();\n }\n\n private wrapTiles() {\n this.tileNodes.forEach((tile) => {\n this.element.appendChild(tile.element);\n });\n }\n\n private get lastTileOffset() {\n return this.tiles[0].offset;\n }\n\n getTileOffset(index: number) {\n let offset = 0;\n\n for (let i = 0; i < index; i++) {\n offset += this.tiles[i].offset;\n }\n\n return -this.lastTileOffset - offset;\n }\n\n get maxTopOffset() {\n return -1 * (this.tiles.reduce((acc, { offset }) => acc + offset, 0) + this.lastTileOffset);\n }\n}\n\nexport class Tile {\n constructor(public element: HTMLElement) {\n this.element.classList.add('slot-machine__tile');\n }\n\n clone() {\n const element = this.element.cloneNode(true) as HTMLElement;\n\n return new Tile(element);\n }\n\n get offset() {\n return this.element.offsetHeight;\n }\n}\n","import { Options } from './types';\n\nfunction randomInteger(min: number, max: number) {\n return Math.floor(Math.random() * (max - min + 1)) + min;\n}\n\nexport const DEFAULTS: Required = {\n active: 0, // Active element [Number]\n delay: 200, // Animation time [Number]\n randomize: (_, max) => randomInteger(0, max), // Randomize function, must return a number with the selected position\n direction: 'up', // Animation direction ['up'||'down']\n};\n\nexport enum CONTAINER_FX {\n GRADIENT = 'slot-machine__container--gradient',\n}\n\nexport enum TILE_FX {\n NO_TRANSITION = 'slot-machine__tile--no-transition',\n FAST = 'slot-machine__tile--blur-fast',\n NORMAL = 'slot-machine__tile--blur-medium',\n SLOW = 'slot-machine__tile--blur-slow',\n TURTLE = 'slot-machine__tile--blur-turtle',\n STOP = 'slot-machine__tile--gradient',\n}\n","import raf from './raf';\nimport { Container } from './dom';\nimport type { Bounds, Options } from './types';\nimport { DEFAULTS, TILE_FX, CONTAINER_FX } from './constants';\n\nconst timeout = (delay: number) => new Promise((res) => setTimeout(res, delay));\n\nexport default class SlotMachine {\n container: Container;\n element: HTMLElement;\n running = false;\n stopping = false;\n nextActive?: number;\n\n private remainingSpins: number;\n private options: Required;\n private _active: number;\n private _bounds: Bounds;\n private _transition: string;\n\n constructor(element: HTMLElement, options: Options) {\n this.element = element;\n // Setup DOM\n this.container = new Container(this.element);\n // Set plugin options\n this.setOptions(options);\n this.active = this.options.active;\n this.setupBounds();\n // Show active element\n this._resetPosition();\n }\n\n setOptions(options: Options) {\n this.options = { ...DEFAULTS, ...options };\n }\n\n private setupBounds() {\n const initial = this.container.getTileOffset(this.active);\n const first = this.container.getTileOffset(0);\n const last = this.container.getTileOffset(this.container.tiles.length - 1);\n\n this._bounds = {\n up: {\n initial,\n from: last,\n to: 0,\n nextReset: 0,\n prevReset: this.container.maxTopOffset,\n },\n down: {\n initial,\n from: first,\n to: this.container.maxTopOffset,\n nextReset: 0,\n prevReset: this.container.maxTopOffset,\n },\n };\n }\n\n get bounds() {\n return this._bounds[this.options.direction];\n }\n\n get active() {\n return this._active;\n }\n\n set active(index: number) {\n if (index < 0 || index >= this.container.tiles.length || isNaN(index)) {\n index = 0;\n }\n\n this._active = index;\n }\n\n private get transition() {\n return this._transition;\n }\n\n private set transition(transition: string) {\n this._transition = transition || 'ease-in-out';\n }\n\n get _prevIndex() {\n const prevIndex = this.active - 1;\n\n return prevIndex < 0 ? this.container.tiles.length - 1 : prevIndex;\n }\n\n get _nextIndex() {\n const nextIndex = this.active + 1;\n\n return nextIndex < this.container.tiles.length ? nextIndex : 0;\n }\n\n get prevIndex() {\n return this.options.direction === 'up' ? this._nextIndex : this._prevIndex;\n }\n\n get nextIndex() {\n return this.options.direction === 'up' ? this._prevIndex : this._nextIndex;\n }\n\n set _animationFX(effect: TILE_FX) {\n const delay = this.options.delay / 4;\n\n raf(() => {\n this.container.tiles\n .map(({ element }) => element)\n .forEach((tile) => {\n tile.classList.remove(TILE_FX.FAST, TILE_FX.NORMAL, TILE_FX.SLOW, TILE_FX.TURTLE);\n if (effect !== TILE_FX.STOP) {\n tile.classList.add(effect);\n }\n });\n\n if (effect === TILE_FX.STOP) {\n this.container.element.classList.remove(CONTAINER_FX.GRADIENT);\n } else {\n this.container.element.classList.add(CONTAINER_FX.GRADIENT);\n }\n }, delay);\n }\n\n _changeTransition(delay = this.options.delay, transition = this.transition) {\n this.container.element.style.transition = `${delay / 1000}s ${transition}`;\n }\n\n _changeTransform(margin: number) {\n this.container.element.style.transform = `matrix(1, 0, 0, 1, 0, ${margin})`;\n }\n\n _isGoingBackward() {\n return !!(this.active === 0 && this.nextActive === this.container.tiles.length - 1);\n }\n\n _isGoingForward() {\n return !!(this.active === this.container.tiles.length - 1 && this.nextActive === 0);\n }\n\n _resetPosition(margin?: number) {\n this.container.element.classList.toggle(TILE_FX.NO_TRANSITION);\n this._changeTransform(margin !== undefined ? margin : this.bounds.initial);\n // Force reflow, flushing the CSS changes\n this.container.element.offsetHeight;\n this.container.element.classList.toggle(TILE_FX.NO_TRANSITION);\n }\n\n async next() {\n this.nextActive = this.nextIndex;\n this.running = true;\n await this.stop(0);\n\n return this.active;\n }\n\n async prev() {\n this.nextActive = this.prevIndex;\n this.running = true;\n await this.stop(0);\n\n return this.active;\n }\n\n _getDelayFromSpins(spins: number) {\n let delay = this.options.delay;\n this.transition = 'linear';\n\n switch (spins) {\n case 1:\n delay /= 0.5;\n this.transition = 'ease-out';\n this._animationFX = TILE_FX.TURTLE;\n break;\n case 2:\n delay /= 0.75;\n this._animationFX = TILE_FX.SLOW;\n break;\n case 3:\n delay /= 1;\n this._animationFX = TILE_FX.NORMAL;\n break;\n case 4:\n delay /= 1.25;\n this._animationFX = TILE_FX.NORMAL;\n break;\n default:\n delay /= 1.5;\n this._animationFX = TILE_FX.FAST;\n }\n\n return delay;\n }\n\n shuffle(spins: number) {\n if (this.running || this.stopping) {\n return;\n }\n\n this.nextActive = this.options.randomize(this.active, this.container.tiles.length);\n this.remainingSpins = spins;\n\n return this._shuffle();\n }\n\n private async _shuffle() {\n this.running = true;\n // Perform animation\n const delay = this._getDelayFromSpins(this.remainingSpins);\n this._changeTransition(delay);\n this._changeTransform(this.bounds.to);\n\n await timeout(delay);\n\n if (!this.stopping && this.running) {\n this.remainingSpins--;\n\n this._resetPosition(this.bounds.from);\n\n if (this.remainingSpins > 1) {\n // Repeat animation\n await this._shuffle();\n } else {\n await this.stop(0);\n }\n }\n }\n\n async stop(spins = 0) {\n if (!this.running || this.stopping) {\n return this.nextActive;\n }\n\n if (this.running && !this.stopping && spins) {\n this.remainingSpins = spins;\n return;\n }\n\n this.running = true;\n this.stopping = true;\n\n // Check direction to prevent jumping\n if (this._isGoingBackward()) {\n this._resetPosition(this.bounds.prevReset);\n } else if (this._isGoingForward()) {\n this._resetPosition(this.bounds.nextReset);\n }\n\n // Update last choosen element index\n this.active = this.nextActive as number;\n\n // Perform animation\n const delay = this._getDelayFromSpins(1);\n this._changeTransition(delay);\n this._animationFX = TILE_FX.STOP;\n this._changeTransform(this.container.getTileOffset(this.active));\n\n await timeout(delay);\n\n this.stopping = false;\n this.running = false;\n this.nextActive = undefined;\n }\n}\n","import { Callback } from './types';\n\nexport default function raf(cb: Callback, timeout = 0) {\n setTimeout(() => requestAnimationFrame(cb), timeout);\n}\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Container","constructor","container","tiles","tileNodes","tileElements","slice","this","children","style","overflow","element","document","createElement","classList","add","transition","appendChild","map","Tile","length","clone","wrapTiles","forEach","tile","lastTileOffset","offset","getTileOffset","index","i","maxTopOffset","reduce","acc","cloneNode","offsetHeight","DEFAULTS","active","delay","randomize","_","max","min","Math","floor","random","randomInteger","direction","CONTAINER_FX","TILE_FX","timeout","Promise","res","setTimeout","SlotMachine","options","running","stopping","setOptions","setupBounds","_resetPosition","initial","first","last","_bounds","up","from","to","nextReset","prevReset","down","bounds","_active","isNaN","_transition","_prevIndex","prevIndex","_nextIndex","nextIndex","_animationFX","effect","cb","requestAnimationFrame","raf","remove","FAST","NORMAL","SLOW","TURTLE","STOP","GRADIENT","_changeTransition","_changeTransform","margin","transform","_isGoingBackward","nextActive","_isGoingForward","toggle","NO_TRANSITION","undefined","async","stop","_getDelayFromSpins","spins","shuffle","remainingSpins","_shuffle"],"sourceRoot":""} \ No newline at end of file