This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
mystic/themes/hueman/source/libs/lightgallery/js/lg-autoplay.min.js
2018-09-03 17:41:16 +10:00

7 lines
4.2 KiB
JavaScript

/**!
* lg-autoplay.js | 0.0.1 | August 1st 2016
* http://sachinchoolur.github.io/lg-autoplay.js
* Copyright (c) 2016 Sachin N;
* @license Apache 2.0
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.LgAutoplay=e()}}(function(){var e,t,o;return function e(t,o,r){function s(n,u){if(!o[n]){if(!t[n]){var i="function"==typeof require&&require;if(!u&&i)return i(n,!0);if(l)return l(n,!0);var c=new Error("Cannot find module '"+n+"'");throw c.code="MODULE_NOT_FOUND",c}var a=o[n]={exports:{}};t[n][0].call(a.exports,function(e){var o=t[n][1][e];return s(o?o:e)},a,a.exports,e,t,o,r)}return o[n].exports}for(var l="function"==typeof require&&require,n=0;n<r.length;n++)s(r[n]);return s}({1:[function(t,o,r){!function(t,o){if("function"==typeof e&&e.amd)e([],o);else if("undefined"!=typeof r)o();else{var s={exports:{}};o(),t.lgAutoplay=s.exports}}(this,function(){"use strict";var e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},t={autoplay:!1,pause:5e3,progressBar:!0,fourceAutoplay:!1,autoplayControls:!0,appendAutoplayControlsTo:".lg-toolbar"},o=function o(r){return this.el=r,this.core=window.lgData[this.el.getAttribute("lg-uid")],!(this.core.items.length<2)&&(this.core.s=e({},t,this.core.s),this.interval=!1,this.fromAuto=!0,this.canceledOnTouch=!1,this.fourceAutoplayTemp=this.core.s.fourceAutoplay,this.core.doCss()||(this.core.s.progressBar=!1),this.init(),this)};o.prototype.init=function(){var e=this;e.core.s.autoplayControls&&e.controls(),e.core.s.progressBar&&e.core.outer.querySelector(".lg").insertAdjacentHTML("beforeend",'<div class="lg-progress-bar"><div class="lg-progress"></div></div>'),e.progress(),e.core.s.autoplay&&e.startlAuto(),utils.on(e.el,"onDragstart.lgtm touchstart.lgtm",function(){e.interval&&(e.cancelAuto(),e.canceledOnTouch=!0)}),utils.on(e.el,"onDragend.lgtm touchend.lgtm onSlideClick.lgtm",function(){!e.interval&&e.canceledOnTouch&&(e.startlAuto(),e.canceledOnTouch=!1)})},o.prototype.progress=function(){var e=this,t,o;utils.on(e.el,"onBeforeSlide.lgtm",function(){e.core.s.progressBar&&e.fromAuto&&(t=e.core.outer.querySelector(".lg-progress-bar"),o=e.core.outer.querySelector(".lg-progress"),e.interval&&(o.removeAttribute("style"),utils.removeClass(t,"lg-start"),setTimeout(function(){utils.setVendor(o,"Transition","width "+(e.core.s.speed+e.core.s.pause)+"ms ease 0s"),utils.addClass(t,"lg-start")},20))),e.fromAuto||e.core.s.fourceAutoplay||e.cancelAuto(),e.fromAuto=!1})},o.prototype.controls=function(){var e=this,t='<span class="lg-autoplay-button lg-icon"></span>';e.core.outer.querySelector(this.core.s.appendAutoplayControlsTo).insertAdjacentHTML("beforeend",t),utils.on(e.core.outer.querySelector(".lg-autoplay-button"),"click.lg",function(){utils.hasClass(e.core.outer,"lg-show-autoplay")?(e.cancelAuto(),e.core.s.fourceAutoplay=!1):e.interval||(e.startlAuto(),e.core.s.fourceAutoplay=e.fourceAutoplayTemp)})},o.prototype.startlAuto=function(){var e=this;utils.setVendor(e.core.outer.querySelector(".lg-progress"),"Transition","width "+(e.core.s.speed+e.core.s.pause)+"ms ease 0s"),utils.addClass(e.core.outer,"lg-show-autoplay"),utils.addClass(e.core.outer.querySelector(".lg-progress-bar"),"lg-start"),e.interval=setInterval(function(){e.core.index+1<e.core.items.length?e.core.index++:e.core.index=0,e.fromAuto=!0,e.core.slide(e.core.index,!1,!1)},e.core.s.speed+e.core.s.pause)},o.prototype.cancelAuto=function(){clearInterval(this.interval),this.interval=!1,this.core.outer.querySelector(".lg-progress")&&this.core.outer.querySelector(".lg-progress").removeAttribute("style"),utils.removeClass(this.core.outer,"lg-show-autoplay"),utils.removeClass(this.core.outer.querySelector(".lg-progress-bar"),"lg-start")},o.prototype.destroy=function(){this.cancelAuto(),this.core.outer.querySelector(".lg-progress-bar")&&this.core.outer.querySelector(".lg-progress-bar").parentNode.removeChild(this.core.outer.querySelector(".lg-progress-bar"))},window.lgModules.autoplay=o})},{}]},{},[1])(1)});