snappymail/vendors/lightgallery/dist/js/lg-autoplay.min.js
djmaze f5a444aa14 Removed opentip
Cleanup lightgallery
2020-08-13 13:16:08 +02:00

4 lines
2.6 KiB
JavaScript

/*! lightgallery - v1.2.21 - 2016-06-28
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2016 Sachin N; Licensed Apache 2.0 */
(e=>{"use strict";var o={autoplay:!1,pause:5e3,progressBar:!0,fourceAutoplay:!1,autoplayControls:!0,appendAutoplayControlsTo:".lg-toolbar"};e.fn.lightGallery.modules.autoplay=class{constructor(r){return this.core=e(r).data("lightGallery"),this.$el=e(r),!(this.core.$items.length<2)&&(this.core.s=e.extend({},o,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)}init(){var e=this;e.core.s.autoplayControls&&e.controls(),e.core.s.progressBar&&e.core.$outer.find(".lg").append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>'),e.progress(),e.core.s.autoplay&&e.startlAuto(),e.$el.on("onDragstart.lg.tm touchstart.lg.tm",()=>{e.interval&&(e.cancelAuto(),e.canceledOnTouch=!0)}),e.$el.on("onDragend.lg.tm touchend.lg.tm onSlideClick.lg.tm",()=>{!e.interval&&e.canceledOnTouch&&(e.startlAuto(),e.canceledOnTouch=!1)})}progress(){var e,o,r=this;r.$el.on("onBeforeSlide.lg.tm",()=>{r.core.s.progressBar&&r.fromAuto&&(e=r.core.$outer.find(".lg-progress-bar"),o=r.core.$outer.find(".lg-progress"),r.interval&&(o.removeAttr("style"),e.removeClass("lg-start"),setTimeout(()=>{o.css("transition","width "+(r.core.s.speed+r.core.s.pause)+"ms ease 0s"),e.addClass("lg-start")},20))),r.fromAuto||r.core.s.fourceAutoplay||r.cancelAuto(),r.fromAuto=!1})}controls(){var o=this;e(this.core.s.appendAutoplayControlsTo).append('<span class="lg-autoplay-button lg-icon"></span>'),o.core.$outer.find(".lg-autoplay-button").on("click.lg",()=>{e(o.core.$outer).hasClass("lg-show-autoplay")?(o.cancelAuto(),o.core.s.fourceAutoplay=!1):o.interval||(o.startlAuto(),o.core.s.fourceAutoplay=o.fourceAutoplayTemp)})}startlAuto(){var e=this;e.core.$outer.find(".lg-progress").css("transition","width "+(e.core.s.speed+e.core.s.pause)+"ms ease 0s"),e.core.$outer.addClass("lg-show-autoplay"),e.core.$outer.find(".lg-progress-bar").addClass("lg-start"),e.interval=setInterval(()=>{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)}cancelAuto(){clearInterval(this.interval),this.interval=!1,this.core.$outer.find(".lg-progress").removeAttr("style"),this.core.$outer.removeClass("lg-show-autoplay"),this.core.$outer.find(".lg-progress-bar").removeClass("lg-start")}destroy(){this.cancelAuto(),this.core.$outer.find(".lg-progress-bar").remove()}}})(jQuery);