(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(typeof self !== 'undefined' ? self : this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 8); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { var g; // This works in non-strict mode g = (function() { return this; })(); try { // This works if eval is allowed (see CSP) g = g || Function("return this")() || (1,eval)("this"); } catch(e) { // This works if the window reference is available if(typeof window === "object") g = window; } // g can still be undefined, but nothing to do about it... // We return undefined, instead of nothing here, so it's // easier to handle this case. if(!global) { ...} module.exports = g; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* globals jQuery */ exports.lory = lory; var _detectPrefixes = __webpack_require__(2); var _detectPrefixes2 = _interopRequireDefault(_detectPrefixes); var _detectSupportsPassive = __webpack_require__(3); var _detectSupportsPassive2 = _interopRequireDefault(_detectSupportsPassive); var _dispatchEvent = __webpack_require__(4); var _dispatchEvent2 = _interopRequireDefault(_dispatchEvent); var _defaults = __webpack_require__(6); var _defaults2 = _interopRequireDefault(_defaults); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var slice = Array.prototype.slice; function lory(slider, opts) { var position = void 0; var slidesWidth = void 0; var frameWidth = void 0; var slides = void 0; /** * slider DOM elements */ var frame = void 0; var slideContainer = void 0; var prevCtrl = void 0; var nextCtrl = void 0; var prefixes = void 0; var transitionEndCallback = void 0; var index = 0; var options = {}; var touchEventParams = (0, _detectSupportsPassive2.default)() ? { passive: true } : false; /** * if object is jQuery convert to native DOM element */ if (typeof jQuery !== 'undefined' && slider instanceof jQuery) { slider = slider[0]; } /** * private * set active class to element which is the current slide */ function setActiveElement(slides, currentIndex) { var _options = options, classNameActiveSlide = _options.classNameActiveSlide; slides.forEach(function (element, index) { if (element.classList.contains(classNameActiveSlide)) { element.classList.remove(classNameActiveSlide); } }); slides[currentIndex].classList.add(classNameActiveSlide); } /** * private * setupInfinite: function to setup if infinite is set * * @param {array} slideArray * @return {array} array of updated slideContainer elements */ function setupInfinite(slideArray) { var _options2 = options, infinite = _options2.infinite; var front = slideArray.slice(0, infinite); var back = slideArray.slice(slideArray.length - infinite, slideArray.length); front.forEach(function (element) { var cloned = element.cloneNode(true); slideContainer.appendChild(cloned); }); back.reverse().forEach(function (element) { var cloned = element.cloneNode(true); slideContainer.insertBefore(cloned, slideContainer.firstChild); }); slideContainer.addEventListener(prefixes.transitionEnd, onTransitionEnd); return slice.call(slideContainer.children); } /** * [dispatchSliderEvent description] * @return {[type]} [description] */ function dispatchSliderEvent(phase, type, detail) { (0, _dispatchEvent2.default)(slider, phase + '.lory.' + type, detail); } /** * translates to a given position in a given time in milliseconds * * @to {number} number in pixels where to translate to * @duration {number} time in milliseconds for the transistion * @ease {string} easing css property */ function translate(to, duration, ease) { var style = slideContainer && slideContainer.style; if (style) { style[prefixes.transition + 'TimingFunction'] = ease; style[prefixes.transition + 'Duration'] = duration + 'ms'; if (prefixes.hasTranslate3d) { style[prefixes.transform] = 'translate3d(' + to + 'px, 0, 0)'; } else { style[prefixes.transform] = 'translate(' + to + 'px, 0)'; } } } /** * returns an element's width */ function elementWidth(element) { return element.getBoundingClientRect().width || element.offsetWidth; } /** * slidefunction called by prev, next & touchend * * determine nextIndex and slide to next postion * under restrictions of the defined options * * @direction {boolean} */ function slide(nextIndex, direction) { var _options3 = options, slideSpeed = _options3.slideSpeed, slidesToScroll = _options3.slidesToScroll, infinite = _options3.infinite, rewind = _options3.rewind, rewindSpeed = _options3.rewindSpeed, ease = _options3.ease, classNameActiveSlide = _options3.classNameActiveSlide; var duration = slideSpeed; var nextSlide = direction ? index + 1 : index - 1; var maxOffset = Math.round(slidesWidth - frameWidth); dispatchSliderEvent('before', 'slide', { index: index, nextSlide: nextSlide }); /** * Reset control classes */ if (prevCtrl) { prevCtrl.classList.remove('disabled'); } if (nextCtrl) { nextCtrl.classList.remove('disabled'); } if (typeof nextIndex !== 'number') { if (direction) { if (infinite && index + infinite * 2 !== slides.length) { nextIndex = index + (infinite - index % infinite); } else { nextIndex = index + slidesToScroll; } } else { if (infinite && index % infinite !== 0) { nextIndex = index - index % infinite; } else { nextIndex = index - slidesToScroll; } } } nextIndex = Math.min(Math.max(nextIndex, 0), slides.length - 1); if (infinite && direction === undefined) { nextIndex += infinite; } var nextOffset = Math.min(Math.max(slides[nextIndex].offsetLeft * -1, maxOffset * -1), 0); if (rewind && Math.abs(position.x) === maxOffset && direction) { nextOffset = 0; nextIndex = 0; duration = rewindSpeed; } /** * translate to the nextOffset by a defined duration and ease function */ translate(nextOffset, duration, ease); /** * update the position with the next position */ position.x = nextOffset; /** * update the index with the nextIndex only if * the offset of the nextIndex is in the range of the maxOffset */ if (slides[nextIndex].offsetLeft <= maxOffset) { index = nextIndex; } if (infinite && (nextIndex === slides.length - infinite || nextIndex === slides.length - slides.length % infinite || nextIndex === 0)) { if (direction) { index = infinite; } if (!direction) { index = slides.length - infinite * 2; } position.x = slides[index].offsetLeft * -1; transitionEndCallback = function transitionEndCallback() { translate(slides[index].offsetLeft * -1, 0, undefined); }; } if (classNameActiveSlide) { setActiveElement(slice.call(slides), index); } /** * update classes for next and prev arrows * based on user settings */ if (prevCtrl && !infinite && nextIndex === 0) { prevCtrl.classList.add('disabled'); } if (nextCtrl && !infinite && !rewind && nextIndex + 1 === slides.length) { nextCtrl.classList.add('disabled'); } dispatchSliderEvent('after', 'slide', { currentSlide: index }); } /** * public * setup function */ function setup() { dispatchSliderEvent('before', 'init'); prefixes = (0, _detectPrefixes2.default)(); options = _extends({}, _defaults2.default, opts); var _options4 = options, classNameFrame = _options4.classNameFrame, classNameSlideContainer = _options4.classNameSlideContainer, classNamePrevCtrl = _options4.classNamePrevCtrl, classNameNextCtrl = _options4.classNameNextCtrl, enableMouseEvents = _options4.enableMouseEvents, classNameActiveSlide = _options4.classNameActiveSlide, initialIndex = _options4.initialIndex; index = initialIndex; frame = slider.getElementsByClassName(classNameFrame)[0]; slideContainer = frame.getElementsByClassName(classNameSlideContainer)[0]; prevCtrl = slider.getElementsByClassName(classNamePrevCtrl)[0]; nextCtrl = slider.getElementsByClassName(classNameNextCtrl)[0]; position = { x: slideContainer.offsetLeft, y: slideContainer.offsetTop }; if (options.infinite) { slides = setupInfinite(slice.call(slideContainer.children)); } else { slides = slice.call(slideContainer.children); if (prevCtrl) { prevCtrl.classList.add('disabled'); } if (nextCtrl && slides.length === 1 && !options.rewind) { nextCtrl.classList.add('disabled'); } } reset(); if (classNameActiveSlide) { setActiveElement(slides, index); } if (prevCtrl && nextCtrl) { prevCtrl.addEventListener('click', prev); nextCtrl.addEventListener('click', next); } frame.addEventListener('touchstart', onTouchstart, touchEventParams); if (enableMouseEvents) { frame.addEventListener('mousedown', onTouchstart); frame.addEventListener('click', onClick); } options.window.addEventListener('resize', onResize); dispatchSliderEvent('after', 'init'); } /** * public * reset function: called on resize */ function reset() { var _options5 = options, infinite = _options5.infinite, ease = _options5.ease, rewindSpeed = _options5.rewindSpeed, rewindOnResize = _options5.rewindOnResize, classNameActiveSlide = _options5.classNameActiveSlide, initialIndex = _options5.initialIndex; slidesWidth = elementWidth(slideContainer); frameWidth = elementWidth(frame); if (frameWidth === slidesWidth) { slidesWidth = slides.reduce(function (previousValue, slide) { return previousValue + elementWidth(slide); }, 0); } if (rewindOnResize) { index = initialIndex; } else { ease = null; rewindSpeed = 0; } if (infinite) { translate(slides[index + infinite].offsetLeft * -1, 0, null); index = index + infinite; position.x = slides[index].offsetLeft * -1; } else { translate(slides[index].offsetLeft * -1, rewindSpeed, ease); position.x = slides[index].offsetLeft * -1; } if (classNameActiveSlide) { setActiveElement(slice.call(slides), index); } } /** * public * slideTo: called on clickhandler */ function slideTo(index) { slide(index); } /** * public * returnIndex function: called on clickhandler */ function returnIndex() { return index - options.infinite || 0; } /** * public * prev function: called on clickhandler */ function prev() { slide(false, false); } /** * public * next function: called on clickhandler */ function next() { slide(false, true); } /** * public * destroy function: called to gracefully destroy the lory instance */ function destroy() { dispatchSliderEvent('before', 'destroy'); // remove event listeners frame.removeEventListener(prefixes.transitionEnd, onTransitionEnd); frame.removeEventListener('touchstart', onTouchstart, touchEventParams); frame.removeEventListener('touchmove', onTouchmove, touchEventParams); frame.removeEventListener('touchend', onTouchend); frame.removeEventListener('mousemove', onTouchmove); frame.removeEventListener('mousedown', onTouchstart); frame.removeEventListener('mouseup', onTouchend); frame.removeEventListener('mouseleave', onTouchend); frame.removeEventListener('click', onClick); options.window.removeEventListener('resize', onResize); if (prevCtrl) { prevCtrl.removeEventListener('click', prev); } if (nextCtrl) { nextCtrl.removeEventListener('click', next); } // remove cloned slides if infinite is set if (options.infinite) { Array.apply(null, Array(options.infinite)).forEach(function () { slideContainer.removeChild(slideContainer.firstChild); slideContainer.removeChild(slideContainer.lastChild); }); } dispatchSliderEvent('after', 'destroy'); } // event handling var touchOffset = void 0; var delta = void 0; var isScrolling = void 0; function onTransitionEnd() { if (transitionEndCallback) { transitionEndCallback(); transitionEndCallback = undefined; } } function onTouchstart(event) { var _options6 = options, enableMouseEvents = _options6.enableMouseEvents; var touches = event.touches ? event.touches[0] : event; if (enableMouseEvents) { frame.addEventListener('mousemove', onTouchmove); frame.addEventListener('mouseup', onTouchend); frame.addEventListener('mouseleave', onTouchend); } frame.addEventListener('touchmove', onTouchmove, touchEventParams); frame.addEventListener('touchend', onTouchend); var pageX = touches.pageX, pageY = touches.pageY; touchOffset = { x: pageX, y: pageY, time: Date.now() }; isScrolling = undefined; delta = {}; dispatchSliderEvent('on', 'touchstart', { event: event }); } function onTouchmove(event) { var touches = event.touches ? event.touches[0] : event; var pageX = touches.pageX, pageY = touches.pageY; delta = { x: pageX - touchOffset.x, y: pageY - touchOffset.y }; if (typeof isScrolling === 'undefined') { isScrolling = !!(isScrolling || Math.abs(delta.x) < Math.abs(delta.y)); } if (!isScrolling && touchOffset) { translate(position.x + delta.x, 0, null); } // may be dispatchSliderEvent('on', 'touchmove', { event: event }); } function onTouchend(event) { /** * time between touchstart and touchend in milliseconds * @duration {number} */ var duration = touchOffset ? Date.now() - touchOffset.time : undefined; /** * is valid if: * * -> swipe attempt time is over 300 ms * and * -> swipe distance is greater than 25px * or * -> swipe distance is more then a third of the swipe area * * @isValidSlide {Boolean} */ var isValid = Number(duration) < 300 && Math.abs(delta.x) > 25 || Math.abs(delta.x) > frameWidth / 3; /** * is out of bounds if: * * -> index is 0 and delta x is greater than 0 * or * -> index is the last slide and delta is smaller than 0 * * @isOutOfBounds {Boolean} */ var isOutOfBounds = !index && delta.x > 0 || index === slides.length - 1 && delta.x < 0; var direction = delta.x < 0; if (!isScrolling) { if (isValid && !isOutOfBounds) { slide(false, direction); } else { translate(position.x, options.snapBackSpeed); } } touchOffset = undefined; /** * remove eventlisteners after swipe attempt */ frame.removeEventListener('touchmove', onTouchmove); frame.removeEventListener('touchend', onTouchend); frame.removeEventListener('mousemove', onTouchmove); frame.removeEventListener('mouseup', onTouchend); frame.removeEventListener('mouseleave', onTouchend); dispatchSliderEvent('on', 'touchend', { event: event }); } function onClick(event) { if (delta.x) { event.preventDefault(); } } function onResize(event) { if (frameWidth !== elementWidth(frame)) { reset(); dispatchSliderEvent('on', 'resize', { event: event }); } } // trigger initial setup setup(); // expose public api return { setup: setup, reset: reset, slideTo: slideTo, returnIndex: returnIndex, prev: prev, next: next, destroy: destroy }; } /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(global) { Object.defineProperty(exports, "__esModule", { value: true }); exports.default = detectPrefixes; /** * Detecting prefixes for saving time and bytes */ function detectPrefixes() { var transform = void 0; var transition = void 0; var transitionEnd = void 0; var hasTranslate3d = void 0; (function () { var el = document.createElement('_'); var style = el.style; var prop = void 0; if (style[prop = 'webkitTransition'] === '') { transitionEnd = 'webkitTransitionEnd'; transition = prop; } if (style[prop = 'transition'] === '') { transitionEnd = 'transitionend'; transition = prop; } if (style[prop = 'webkitTransform'] === '') { transform = prop; } if (style[prop = 'msTransform'] === '') { transform = prop; } if (style[prop = 'transform'] === '') { transform = prop; } document.body.insertBefore(el, null); style[transform] = 'translate3d(0, 0, 0)'; hasTranslate3d = !!global.getComputedStyle(el).getPropertyValue(transform); document.body.removeChild(el); })(); return { transform: transform, transition: transition, transitionEnd: transitionEnd, hasTranslate3d: hasTranslate3d }; } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = detectSupportsPassive; function detectSupportsPassive() { var supportsPassive = false; try { var opts = Object.defineProperty({}, 'passive', { get: function get() { supportsPassive = true; } }); window.addEventListener('testPassive', null, opts); window.removeEventListener('testPassive', null, opts); } catch (e) {} return supportsPassive; } /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = dispatchEvent; var _customEvent = __webpack_require__(5); var _customEvent2 = _interopRequireDefault(_customEvent); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * dispatch custom events * * @param {element} el slideshow element * @param {string} type custom event name * @param {object} detail custom detail information */ function dispatchEvent(target, type, detail) { var event = new _customEvent2.default(type, { bubbles: true, cancelable: true, detail: detail }); target.dispatchEvent(event); } /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global) { var NativeCustomEvent = global.CustomEvent; function useNative () { try { var p = new NativeCustomEvent('cat', { detail: { foo: 'bar' } }); return 'cat' === p.type && 'bar' === p.detail.foo; } catch (e) { } return false; } /** * Cross-browser `CustomEvent` constructor. * * https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent * * @public */ module.exports = useNative() ? NativeCustomEvent : // IE >= 9 'undefined' !== typeof document && 'function' === typeof document.createEvent ? function CustomEvent (type, params) { var e = document.createEvent('CustomEvent'); if (params) { e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail); } else { e.initCustomEvent(type, false, false, void 0); } return e; } : // IE <= 8 function CustomEvent (type, params) { var e = document.createEventObject(); e.type = type; if (params) { e.bubbles = Boolean(params.bubbles); e.cancelable = Boolean(params.cancelable); e.detail = params.detail; } else { e.bubbles = false; e.cancelable = false; e.detail = void 0; } return e; } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = { /** * slides scrolled at once * @slidesToScroll {Number} */ slidesToScroll: 1, /** * time in milliseconds for the animation of a valid slide attempt * @slideSpeed {Number} */ slideSpeed: 300, /** * time in milliseconds for the animation of the rewind after the last slide * @rewindSpeed {Number} */ rewindSpeed: 600, /** * time for the snapBack of the slider if the slide attempt was not valid * @snapBackSpeed {Number} */ snapBackSpeed: 200, /** * Basic easing functions: https://developer.mozilla.org/de/docs/Web/CSS/transition-timing-function * cubic bezier easing functions: http://easings.net/de * @ease {String} */ ease: 'ease', /** * if slider reached the last slide, with next click the slider goes back to the startindex. * use infinite or rewind, not both * @rewind {Boolean} */ rewind: false, /** * number of visible slides or false * use infinite or rewind, not both * @infinite {number} */ infinite: false, /** * the slide index to show when the slider is initialized. * @initialIndex {number} */ initialIndex: 0, /** * class name for slider frame * @classNameFrame {string} */ classNameFrame: 'js_frame', /** * class name for slides container * @classNameSlideContainer {string} */ classNameSlideContainer: 'js_slides', /** * class name for slider prev control * @classNamePrevCtrl {string} */ classNamePrevCtrl: 'js_prev', /** * class name for slider next control * @classNameNextCtrl {string} */ classNameNextCtrl: 'js_next', /** * class name for current active slide * if emptyString then no class is set * @classNameActiveSlide {string} */ classNameActiveSlide: 'active', /** * enables mouse events for swiping on desktop devices * @enableMouseEvents {boolean} */ enableMouseEvents: false, /** * window instance * @window {object} */ window: typeof window !== 'undefined' ? window : null, /** * If false, slides lory to the first slide on window resize. * @rewindOnResize {boolean} */ rewindOnResize: true }; /***/ }), /* 7 */, /* 8 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _lory = __webpack_require__(1); function init($) { $.fn.lory = function (options) { return this.each(function () { var instanceOptions; if (!$.data(this, 'lory')) { instanceOptions = $.extend({}, options, $(this).data()); $.data(this, 'lory', (0, _lory.lory)(this, instanceOptions)); } }); }; } /* globals jQuery */ ; if (typeof jQuery !== 'undefined') { init(jQuery); } /***/ }) /******/ ]); });