File Manager

Current Directory: /home/astoriaah/www/templates/yootheme/vendor/assets/uikit/dist/js/components
Viewing File: /home/astoriaah/www/templates/yootheme/vendor/assets/uikit/dist/js/components/slideshow.js
/*! UIkit 3.0.0-rc.8 | http://www.getuikit.com | (c) 2014 - 2017 YOOtheme | MIT License */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('uikit-util')) : typeof define === 'function' && define.amd ? define('uikitslideshow', ['uikit-util'], factory) : (global.UIkitSlideshow = factory(global.UIkit.util)); }(this, (function (uikitUtil) { 'use strict'; var Class = { connected: function() { uikitUtil.addClass(this.$el, this.$name); } }; var Animations = { slide: { show: function(dir) { return [ {transform: translate(dir * -100)}, {transform: translate()} ]; }, percent: function(current) { return translated(current); }, translate: function(percent, dir) { return [ {transform: translate(dir * -100 * percent)}, {transform: translate(dir * 100 * (1 - percent))} ]; } } }; function translated(el) { return Math.abs(uikitUtil.css(el, 'transform').split(',')[4] / el.offsetWidth) || 0; } function translate(value, unit) { if ( value === void 0 ) value = 0; if ( unit === void 0 ) unit = '%'; return ("translateX(" + value + (value ? unit : '') + ")"); // currently not translate3d to support IE, translate3d within translate3d does not work while transitioning } function scale3d(value) { return ("scale3d(" + value + ", " + value + ", 1)"); } function Transitioner(prev, next, dir, ref) { var animation = ref.animation; var easing = ref.easing; var percent = animation.percent; var translate = animation.translate; var show = animation.show; if ( show === void 0 ) show = uikitUtil.noop; var props = show(dir); var deferred = new uikitUtil.Deferred(); return { dir: dir, show: function(duration, percent, linear) { var this$1 = this; if ( percent === void 0 ) percent = 0; var timing = linear ? 'linear' : easing; duration -= Math.round(duration * uikitUtil.clamp(percent, -1, 1)); this.translate(percent); triggerUpdate(next, 'itemin', {percent: percent, duration: duration, timing: timing, dir: dir}); triggerUpdate(prev, 'itemout', {percent: 1 - percent, duration: duration, timing: timing, dir: dir}); uikitUtil.Promise.all([ uikitUtil.Transition.start(next, props[1], duration, timing), uikitUtil.Transition.start(prev, props[0], duration, timing) ]).then(function () { this$1.reset(); deferred.resolve(); }, uikitUtil.noop); return deferred.promise; }, stop: function() { return uikitUtil.Transition.stop([next, prev]); }, cancel: function() { uikitUtil.Transition.cancel([next, prev]); }, reset: function() { for (var prop in props[0]) { uikitUtil.css([next, prev], prop, ''); } }, forward: function(duration, percent) { if ( percent === void 0 ) percent = this.percent(); uikitUtil.Transition.cancel([next, prev]); return this.show(duration, percent, true); }, translate: function(percent) { this.reset(); var props = translate(percent, dir); uikitUtil.css(next, props[1]); uikitUtil.css(prev, props[0]); triggerUpdate(next, 'itemtranslatein', {percent: percent, dir: dir}); triggerUpdate(prev, 'itemtranslateout', {percent: 1 - percent, dir: dir}); }, percent: function() { return percent(prev || next, next, dir); }, getDistance: function() { return prev.offsetWidth; } }; } function triggerUpdate(el, type, data$$1) { uikitUtil.trigger(el, uikitUtil.createEvent(type, false, false, data$$1)); } var SliderAutoplay = { props: { autoplay: Boolean, autoplayInterval: Number, pauseOnHover: Boolean }, data: { autoplay: false, autoplayInterval: 7000, pauseOnHover: true }, connected: function() { this.startAutoplay(); }, disconnected: function() { this.stopAutoplay(); }, events: [ { name: 'visibilitychange', el: document, handler: function() { if (document.hidden) { this.stopAutoplay(); } else { this.startAutoplay(); } } }, { name: uikitUtil.pointerDown, handler: 'stopAutoplay' }, { name: 'mouseenter', filter: function() { return this.autoplay; }, handler: function() { this.isHovering = true; } }, { name: 'mouseleave', filter: function() { return this.autoplay; }, handler: function() { this.isHovering = false; } } ], methods: { startAutoplay: function() { var this$1 = this; this.stopAutoplay(); if (this.autoplay) { this.interval = setInterval( function () { return !(this$1.isHovering && this$1.pauseOnHover) && !this$1.stack.length && this$1.show('next'); }, this.autoplayInterval ); } }, stopAutoplay: function() { if (this.interval) { clearInterval(this.interval); } } } }; var SliderDrag = { data: { threshold: 10, preventCatch: false }, init: function() { var this$1 = this; ['start', 'move', 'end'].forEach(function (key) { var fn = this$1[key]; this$1[key] = function (e) { var pos = uikitUtil.getPos(e).x * (uikitUtil.isRtl ? -1 : 1); this$1.prevPos = pos !== this$1.pos ? this$1.pos : this$1.prevPos; this$1.pos = pos; fn(e); }; }); }, events: [ { name: uikitUtil.pointerDown, delegate: function() { return this.slidesSelector; }, handler: function(e) { if (!uikitUtil.isTouch(e) && hasTextNodesOnly(e.target) || e.button > 0 || this.length < 2 || this.preventCatch ) { return; } this.start(e); } }, { name: 'dragstart', handler: function(e) { e.preventDefault(); } } ], methods: { start: function() { this.drag = this.pos; if (this._transitioner) { this.percent = this._transitioner.percent(); this.drag += this._transitioner.getDistance() * this.percent * this.dir; this._transitioner.translate(this.percent); this._transitioner.cancel(); this.dragging = true; this.stack = []; } else { this.prevIndex = this.index; } this.unbindMove = uikitUtil.on(document, uikitUtil.pointerMove, this.move, {capture: true, passive: false}); uikitUtil.on(window, 'scroll', this.unbindMove); uikitUtil.on(document, uikitUtil.pointerUp, this.end, true); }, move: function(e) { var this$1 = this; var distance = this.pos - this.drag; if (distance === 0 || this.prevPos === this.pos || !this.dragging && Math.abs(distance) < this.threshold) { return; } e.cancelable && e.preventDefault(); this.dragging = true; this.dir = (distance < 0 ? 1 : -1); var ref = this; var slides = ref.slides; var ref$1 = this; var prevIndex = ref$1.prevIndex; var dis = Math.abs(distance); var nextIndex = this.getIndex(prevIndex + this.dir, prevIndex); var width = this._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth; while (nextIndex !== prevIndex && dis > width) { this$1.drag -= width * this$1.dir; prevIndex = nextIndex; dis -= width; nextIndex = this$1.getIndex(prevIndex + this$1.dir, prevIndex); width = this$1._getDistance(prevIndex, nextIndex) || slides[prevIndex].offsetWidth; } this.percent = dis / width; var prev = slides[prevIndex]; var next = slides[nextIndex]; var changed = this.index !== nextIndex; var edge = prevIndex === nextIndex; var itemShown; [this.index, this.prevIndex].filter(function (i) { return !uikitUtil.includes([nextIndex, prevIndex], i); }).forEach(function (i) { uikitUtil.trigger(slides[i], 'itemhidden', [this$1]); if (edge) { itemShown = true; this$1.prevIndex = prevIndex; } }); if (this.index === prevIndex && this.prevIndex !== prevIndex || itemShown) { uikitUtil.trigger(slides[this.index], 'itemshown', [this]); } if (changed) { this.prevIndex = prevIndex; this.index = nextIndex; !edge && uikitUtil.trigger(prev, 'beforeitemhide', [this]); uikitUtil.trigger(next, 'beforeitemshow', [this]); } this._transitioner = this._translate(Math.abs(this.percent), prev, !edge && next); if (changed) { !edge && uikitUtil.trigger(prev, 'itemhide', [this]); uikitUtil.trigger(next, 'itemshow', [this]); } }, end: function() { uikitUtil.off(window, 'scroll', this.unbindMove); this.unbindMove(); uikitUtil.off(document, uikitUtil.pointerUp, this.end, true); if (this.dragging) { this.dragging = null; if (this.index === this.prevIndex) { this.percent = 1 - this.percent; this.dir *= -1; this._show(false, this.index, true); this._transitioner = null; } else { var dirChange = (uikitUtil.isRtl ? this.dir * (uikitUtil.isRtl ? 1 : -1) : this.dir) < 0 === this.prevPos > this.pos; this.index = dirChange ? this.index : this.prevIndex; if (dirChange) { this.percent = 1 - this.percent; } this.show(this.dir > 0 && !dirChange || this.dir < 0 && dirChange ? 'next' : 'previous', true); } uikitUtil.preventClick(); } this.drag = this.percent = null; } } }; function hasTextNodesOnly(el) { return !el.children.length && el.childNodes.length; } var SliderNav = { data: { selNav: false }, computed: { nav: function(ref, $el) { var selNav = ref.selNav; return uikitUtil.$(selNav, $el); }, navItemSelector: function(ref) { var attrItem = ref.attrItem; return ("[" + attrItem + "],[data-" + attrItem + "]"); }, navItems: function(_, $el) { return uikitUtil.$$(this.navItemSelector, $el); } }, update: [ { write: function() { var this$1 = this; if (this.nav && this.length !== this.nav.children.length) { uikitUtil.html(this.nav, this.slides.map(function (_, i) { return ("<li " + (this$1.attrItem) + "=\"" + i + "\"><a href=\"#\"></a></li>"); }).join('')); } uikitUtil.toggleClass(uikitUtil.$$(this.navItemSelector, this.$el).concat(this.nav), 'uk-hidden', !this.maxIndex); this.updateNav(); }, events: ['load', 'resize'] } ], events: [ { name: 'click', delegate: function() { return this.navItemSelector; }, handler: function(e) { e.preventDefault(); e.current.blur(); this.show(uikitUtil.data(e.current, this.attrItem)); } }, { name: 'itemshow', handler: 'updateNav' } ], methods: { updateNav: function() { var this$1 = this; var i = this.getValidIndex(); this.navItems.forEach(function (el) { var cmd = uikitUtil.data(el, this$1.attrItem); uikitUtil.toggleClass(el, this$1.clsActive, uikitUtil.toNumber(cmd) === i); uikitUtil.toggleClass(el, 'uk-invisible', this$1.finite && (cmd === 'previous' && i === 0 || cmd === 'next' && i >= this$1.maxIndex)); }); } } }; var Slider = { attrs: true, mixins: [SliderAutoplay, SliderDrag, SliderNav], props: { clsActivated: Boolean, easing: String, index: Number, finite: Boolean, velocity: Number }, data: function () { return ({ easing: 'ease', finite: false, velocity: 1, index: 0, stack: [], percent: 0, clsActive: 'uk-active', clsActivated: false, Transitioner: false, transitionOptions: {} }); }, computed: { duration: function(ref, $el) { var velocity = ref.velocity; return speedUp($el.offsetWidth / velocity); }, length: function() { return this.slides.length; }, list: function(ref, $el) { var selList = ref.selList; return uikitUtil.$(selList, $el); }, maxIndex: function() { return this.length - 1; }, slidesSelector: function(ref) { var selList = ref.selList; return (selList + " > *"); }, slides: function() { return uikitUtil.toNodes(this.list.children); } }, events: { itemshown: function() { this.$update(this.list); } }, methods: { show: function(index, force) { var this$1 = this; if ( force === void 0 ) force = false; if (this.dragging || !this.length) { return; } var ref = this; var stack = ref.stack; var queueIndex = force ? 0 : stack.length; var reset = function () { stack.splice(queueIndex, 1); if (stack.length) { this$1.show(stack.shift(), true); } }; stack[force ? 'unshift' : 'push'](index); if (!force && stack.length > 1) { if (stack.length === 2) { this._transitioner.forward(Math.min(this.duration, 200)); } return; } var prevIndex = this.index; var prev = uikitUtil.hasClass(this.slides, this.clsActive) && this.slides[prevIndex]; var nextIndex = this.getIndex(index, this.index); var next = this.slides[nextIndex]; if (prev === next) { reset(); return; } this.dir = getDirection(index, prevIndex); this.prevIndex = prevIndex; this.index = nextIndex; prev && uikitUtil.trigger(prev, 'beforeitemhide', [this]); if (!uikitUtil.trigger(next, 'beforeitemshow', [this, prev])) { this.index = this.prevIndex; reset(); return; } var promise = this._show(prev, next, force).then(function () { prev && uikitUtil.trigger(prev, 'itemhidden', [this$1]); uikitUtil.trigger(next, 'itemshown', [this$1]); return new uikitUtil.Promise(function (resolve) { uikitUtil.fastdom.write(function () { stack.shift(); if (stack.length) { this$1.show(stack.shift(), true); } else { this$1._transitioner = null; } resolve(); }); }); }); prev && uikitUtil.trigger(prev, 'itemhide', [this]); uikitUtil.trigger(next, 'itemshow', [this]); return promise; }, getIndex: function(index, prev) { if ( index === void 0 ) index = this.index; if ( prev === void 0 ) prev = this.index; return uikitUtil.clamp(uikitUtil.getIndex(index, this.slides, prev, this.finite), 0, this.maxIndex); }, getValidIndex: function(index, prevIndex) { if ( index === void 0 ) index = this.index; if ( prevIndex === void 0 ) prevIndex = this.prevIndex; return this.getIndex(index, prevIndex); }, _show: function(prev, next, force) { this._transitioner = this._getTransitioner( prev, next, this.dir, uikitUtil.assign({ easing: force ? next.offsetWidth < 600 ? 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' /* easeOutQuad */ : 'cubic-bezier(0.165, 0.84, 0.44, 1)' /* easeOutQuart */ : this.easing }, this.transitionOptions) ); if (!force && !prev) { this._transitioner.translate(1); return uikitUtil.Promise.resolve(); } var ref = this.stack; var length = ref.length; return this._transitioner[length > 1 ? 'forward' : 'show'](length > 1 ? Math.min(this.duration, 75 + 75 / (length - 1)) : this.duration, this.percent); }, _getDistance: function(prev, next) { return new this._getTransitioner(prev, prev !== next && next).getDistance(); }, _translate: function(percent, prev, next) { if ( prev === void 0 ) prev = this.prevIndex; if ( next === void 0 ) next = this.index; var transitioner = this._getTransitioner(prev !== next ? prev : false, next); transitioner.translate(percent); return transitioner; }, _getTransitioner: function(prev, next, dir, options) { if ( prev === void 0 ) prev = this.prevIndex; if ( next === void 0 ) next = this.index; if ( dir === void 0 ) dir = this.dir || 1; if ( options === void 0 ) options = this.transitionOptions; return new this.Transitioner( uikitUtil.isNumber(prev) ? this.slides[prev] : prev, uikitUtil.isNumber(next) ? this.slides[next] : next, dir * (uikitUtil.isRtl ? -1 : 1), options ); } } }; function getDirection(index, prevIndex) { return index === 'next' ? 1 : index === 'previous' ? -1 : index < prevIndex ? -1 : 1; } function speedUp(x) { return .5 * x + 300; // parabola through (400,500; 600,600; 1800,1200) } var Slideshow = { mixins: [Slider], props: { animation: String }, data: { animation: 'slide', clsActivated: 'uk-transition-active', Animations: Animations, Transitioner: Transitioner }, computed: { animation: function(ref) { var animation = ref.animation; var Animations$$1 = ref.Animations; return uikitUtil.assign(animation in Animations$$1 ? Animations$$1[animation] : Animations$$1.slide, {name: animation}); }, transitionOptions: function() { return {animation: this.animation}; } }, events: { 'itemshow itemhide itemshown itemhidden': function(ref) { var target = ref.target; this.$update(target); }, itemshow: function() { uikitUtil.isNumber(this.prevIndex) && uikitUtil.fastdom.flush(); // iOS 10+ will honor the video.play only if called from a gesture handler }, beforeitemshow: function(ref) { var target = ref.target; uikitUtil.addClass(target, this.clsActive); }, itemshown: function(ref) { var target = ref.target; uikitUtil.addClass(target, this.clsActivated); }, itemhidden: function(ref) { var target = ref.target; uikitUtil.removeClass(target, this.clsActive, this.clsActivated); } } }; var Animations$1 = uikitUtil.assign({}, Animations, { fade: { show: function() { return [ {opacity: 0, zIndex: 0}, {zIndex: -1} ]; }, percent: function(current) { return 1 - uikitUtil.css(current, 'opacity'); }, translate: function(percent) { return [ {opacity: 1 - percent, zIndex: 0}, {zIndex: -1} ]; } }, scale: { show: function() { return [ {opacity: 0, transform: scale3d(1 + .5), zIndex: 0}, {zIndex: -1} ]; }, percent: function(current) { return 1 - uikitUtil.css(current, 'opacity'); }, translate: function(percent) { return [ {opacity: 1 - percent, transform: scale3d(1 + .5 * percent), zIndex: 0}, {zIndex: -1} ]; } }, pull: { show: function(dir) { return dir < 0 ? [ {transform: translate(30), zIndex: -1}, {transform: translate(), zIndex: 0} ] : [ {transform: translate(-100), zIndex: 0}, {transform: translate(), zIndex: -1} ]; }, percent: function(current, next, dir) { return dir < 0 ? 1 - translated(next) : translated(current); }, translate: function(percent, dir) { return dir < 0 ? [ {transform: translate(30 * percent), zIndex: -1}, {transform: translate(-100 * (1 - percent)), zIndex: 0} ] : [ {transform: translate(-percent * 100), zIndex: 0}, {transform: translate(30 * (1 - percent)), zIndex: -1} ]; } }, push: { show: function(dir) { return dir < 0 ? [ {transform: translate(100), zIndex: 0}, {transform: translate(), zIndex: -1} ] : [ {transform: translate(-30), zIndex: -1}, {transform: translate(), zIndex: 0} ]; }, percent: function(current, next, dir) { return dir > 0 ? 1 - translated(next) : translated(current); }, translate: function(percent, dir) { return dir < 0 ? [ {transform: translate(percent * 100), zIndex: 0}, {transform: translate(-30 * (1 - percent)), zIndex: -1} ] : [ {transform: translate(-30 * percent), zIndex: -1}, {transform: translate(100 * (1 - percent)), zIndex: 0} ]; } } }); var SliderReactive = { update: [ { write: function() { if (this.stack.length || this.dragging) { return; } var index = this.getValidIndex(); delete this.index; uikitUtil.removeClass(this.slides, this.clsActive, this.clsActivated); this.show(index); }, events: ['load', 'resize'] } ] }; var Component$1 = { mixins: [Class, Slideshow, SliderReactive], props: { ratio: String, minHeight: Boolean, maxHeight: Boolean, }, data: { ratio: '16:9', minHeight: false, maxHeight: false, selList: '.uk-slideshow-items', attrItem: 'uk-slideshow-item', selNav: '.uk-slideshow-nav', Animations: Animations$1 }, update: { read: function() { var ref = this.ratio.split(':').map(Number); var width = ref[0]; var height$$1 = ref[1]; height$$1 = height$$1 * this.$el.offsetWidth / width; if (this.minHeight) { height$$1 = Math.max(this.minHeight, height$$1); } if (this.maxHeight) { height$$1 = Math.min(this.maxHeight, height$$1); } return {height: height$$1}; }, write: function(ref) { var hgt = ref.height; uikitUtil.height(this.list, Math.floor(hgt)); }, events: ['load', 'resize'] } }; /* global UIkit, 'slideshow' */ if (typeof window !== 'undefined' && window.UIkit) { window.UIkit.component('slideshow', Component$1); } return Component$1; })));