mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
upLG
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
export interface AutoplayStrings {
|
||||
toggleAutoplay: string;
|
||||
}
|
||||
export interface AutoplaySettings {
|
||||
/**
|
||||
* Enable autoplay plugin
|
||||
*/
|
||||
autoplay: boolean;
|
||||
/**
|
||||
* Enable slideshow autoplay
|
||||
*/
|
||||
slideShowAutoplay: boolean;
|
||||
/**
|
||||
* The time (in ms) between each auto transition.
|
||||
*/
|
||||
slideShowInterval: number;
|
||||
/**
|
||||
* Show autoplay progressBar
|
||||
*/
|
||||
progressBar: boolean;
|
||||
/**
|
||||
* If false autoplay will be stopped after first user action
|
||||
*/
|
||||
forceSlideShowAutoplay: boolean;
|
||||
/**
|
||||
* Show/hide autoplay controls.
|
||||
*/
|
||||
autoplayControls: boolean;
|
||||
/**
|
||||
* Specify where the autoplay controls should be appended.
|
||||
*/
|
||||
appendAutoplayControlsTo: string;
|
||||
/**
|
||||
* Custom translation strings for aria-labels
|
||||
*/
|
||||
autoplayPluginStrings: AutoplayStrings;
|
||||
}
|
||||
export declare const autoplaySettings: AutoplaySettings;
|
||||
@@ -0,0 +1,22 @@
|
||||
import { LightGallery } from '../../lightgallery';
|
||||
import { AutoplaySettings } from './lg-autoplay-settings';
|
||||
/**
|
||||
* Creates the autoplay plugin.
|
||||
* @param {object} element - lightGallery element
|
||||
*/
|
||||
export default class Autoplay {
|
||||
core: LightGallery;
|
||||
settings: AutoplaySettings;
|
||||
interval: any;
|
||||
fromAuto: boolean;
|
||||
pausedOnTouchDrag: boolean;
|
||||
pausedOnSlideChange: boolean;
|
||||
constructor(instance: LightGallery);
|
||||
init(): void;
|
||||
private showProgressBar;
|
||||
private controls;
|
||||
startAutoPlay(): void;
|
||||
stopAutoPlay(): void;
|
||||
closeGallery(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/*!
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* List of lightGallery events
|
||||
* All events should be documented here
|
||||
* Below interfaces are used to build the website documentations
|
||||
* */
|
||||
var lGEvents = {
|
||||
afterAppendSlide: 'lgAfterAppendSlide',
|
||||
init: 'lgInit',
|
||||
hasVideo: 'lgHasVideo',
|
||||
containerResize: 'lgContainerResize',
|
||||
updateSlides: 'lgUpdateSlides',
|
||||
afterAppendSubHtml: 'lgAfterAppendSubHtml',
|
||||
beforeOpen: 'lgBeforeOpen',
|
||||
afterOpen: 'lgAfterOpen',
|
||||
slideItemLoad: 'lgSlideItemLoad',
|
||||
beforeSlide: 'lgBeforeSlide',
|
||||
afterSlide: 'lgAfterSlide',
|
||||
posterClick: 'lgPosterClick',
|
||||
dragStart: 'lgDragStart',
|
||||
dragMove: 'lgDragMove',
|
||||
dragEnd: 'lgDragEnd',
|
||||
beforeNextSlide: 'lgBeforeNextSlide',
|
||||
beforePrevSlide: 'lgBeforePrevSlide',
|
||||
beforeClose: 'lgBeforeClose',
|
||||
afterClose: 'lgAfterClose',
|
||||
rotateLeft: 'lgRotateLeft',
|
||||
rotateRight: 'lgRotateRight',
|
||||
flipHorizontal: 'lgFlipHorizontal',
|
||||
flipVertical: 'lgFlipVertical',
|
||||
autoplay: 'lgAutoplay',
|
||||
autoplayStart: 'lgAutoplayStart',
|
||||
autoplayStop: 'lgAutoplayStop',
|
||||
};
|
||||
|
||||
var autoplaySettings = {
|
||||
autoplay: true,
|
||||
slideShowAutoplay: false,
|
||||
slideShowInterval: 5000,
|
||||
progressBar: true,
|
||||
forceSlideShowAutoplay: false,
|
||||
autoplayControls: true,
|
||||
appendAutoplayControlsTo: '.lg-toolbar',
|
||||
autoplayPluginStrings: {
|
||||
toggleAutoplay: 'Toggle Autoplay',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the autoplay plugin.
|
||||
* @param {object} element - lightGallery element
|
||||
*/
|
||||
var Autoplay = /** @class */ (function () {
|
||||
function Autoplay(instance) {
|
||||
this.core = instance;
|
||||
// extend module default settings with lightGallery core settings
|
||||
this.settings = __assign(__assign({}, autoplaySettings), this.core.settings);
|
||||
return this;
|
||||
}
|
||||
Autoplay.prototype.init = function () {
|
||||
var _this = this;
|
||||
if (!this.settings.autoplay) {
|
||||
return;
|
||||
}
|
||||
this.interval = false;
|
||||
// Identify if slide happened from autoplay
|
||||
this.fromAuto = true;
|
||||
// Identify if autoplay canceled from touch/drag
|
||||
this.pausedOnTouchDrag = false;
|
||||
this.pausedOnSlideChange = false;
|
||||
// append autoplay controls
|
||||
if (this.settings.autoplayControls) {
|
||||
this.controls();
|
||||
}
|
||||
// Create progress bar
|
||||
if (this.settings.progressBar) {
|
||||
this.core.outer.append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
|
||||
}
|
||||
// Start autoplay
|
||||
if (this.settings.slideShowAutoplay) {
|
||||
this.core.LGel.once(lGEvents.slideItemLoad + ".autoplay", function () {
|
||||
_this.startAutoPlay();
|
||||
});
|
||||
}
|
||||
// cancel interval on touchstart and dragstart
|
||||
this.core.LGel.on(lGEvents.dragStart + ".autoplay touchstart.lg.autoplay", function () {
|
||||
if (_this.interval) {
|
||||
_this.stopAutoPlay();
|
||||
_this.pausedOnTouchDrag = true;
|
||||
}
|
||||
});
|
||||
// restore autoplay if autoplay canceled from touchstart / dragstart
|
||||
this.core.LGel.on(lGEvents.dragEnd + ".autoplay touchend.lg.autoplay", function () {
|
||||
if (!_this.interval && _this.pausedOnTouchDrag) {
|
||||
_this.startAutoPlay();
|
||||
_this.pausedOnTouchDrag = false;
|
||||
}
|
||||
});
|
||||
this.core.LGel.on(lGEvents.beforeSlide + ".autoplay", function () {
|
||||
_this.showProgressBar();
|
||||
if (!_this.fromAuto && _this.interval) {
|
||||
_this.stopAutoPlay();
|
||||
_this.pausedOnSlideChange = true;
|
||||
}
|
||||
else {
|
||||
_this.pausedOnSlideChange = false;
|
||||
}
|
||||
_this.fromAuto = false;
|
||||
});
|
||||
// restore autoplay if autoplay canceled from touchstart / dragstart
|
||||
this.core.LGel.on(lGEvents.afterSlide + ".autoplay", function () {
|
||||
if (_this.pausedOnSlideChange &&
|
||||
!_this.interval &&
|
||||
_this.settings.forceSlideShowAutoplay) {
|
||||
_this.startAutoPlay();
|
||||
_this.pausedOnSlideChange = false;
|
||||
}
|
||||
});
|
||||
// set progress
|
||||
this.showProgressBar();
|
||||
};
|
||||
Autoplay.prototype.showProgressBar = function () {
|
||||
var _this = this;
|
||||
if (this.settings.progressBar && this.fromAuto) {
|
||||
var _$progressBar_1 = this.core.outer.find('.lg-progress-bar');
|
||||
var _$progress_1 = this.core.outer.find('.lg-progress');
|
||||
if (this.interval) {
|
||||
_$progress_1.removeAttr('style');
|
||||
_$progressBar_1.removeClass('lg-start');
|
||||
setTimeout(function () {
|
||||
_$progress_1.css('transition', 'width ' +
|
||||
(_this.core.settings.speed +
|
||||
_this.settings.slideShowInterval) +
|
||||
'ms ease 0s');
|
||||
_$progressBar_1.addClass('lg-start');
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Manage autoplay via play/stop buttons
|
||||
Autoplay.prototype.controls = function () {
|
||||
var _this = this;
|
||||
var _html = "<button aria-label=\"" + this.settings.autoplayPluginStrings['toggleAutoplay'] + "\" type=\"button\" class=\"lg-autoplay-button lg-icon\"></button>";
|
||||
// Append autoplay controls
|
||||
this.core.outer
|
||||
.find(this.settings.appendAutoplayControlsTo)
|
||||
.append(_html);
|
||||
this.core.outer
|
||||
.find('.lg-autoplay-button')
|
||||
.first()
|
||||
.on('click.lg.autoplay', function () {
|
||||
if (_this.core.outer.hasClass('lg-show-autoplay')) {
|
||||
_this.stopAutoPlay();
|
||||
}
|
||||
else {
|
||||
if (!_this.interval) {
|
||||
_this.startAutoPlay();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
// Autostart gallery
|
||||
Autoplay.prototype.startAutoPlay = function () {
|
||||
var _this = this;
|
||||
this.core.outer
|
||||
.find('.lg-progress')
|
||||
.css('transition', 'width ' +
|
||||
(this.core.settings.speed +
|
||||
this.settings.slideShowInterval) +
|
||||
'ms ease 0s');
|
||||
this.core.outer.addClass('lg-show-autoplay');
|
||||
this.core.outer.find('.lg-progress-bar').addClass('lg-start');
|
||||
this.core.LGel.trigger(lGEvents.autoplayStart, {
|
||||
index: this.core.index,
|
||||
});
|
||||
this.interval = setInterval(function () {
|
||||
if (_this.core.index + 1 < _this.core.galleryItems.length) {
|
||||
_this.core.index++;
|
||||
}
|
||||
else {
|
||||
_this.core.index = 0;
|
||||
}
|
||||
_this.core.LGel.trigger(lGEvents.autoplay, {
|
||||
index: _this.core.index,
|
||||
});
|
||||
_this.fromAuto = true;
|
||||
_this.core.slide(_this.core.index, false, false, 'next');
|
||||
}, this.core.settings.speed + this.settings.slideShowInterval);
|
||||
};
|
||||
// cancel Autostart
|
||||
Autoplay.prototype.stopAutoPlay = function () {
|
||||
if (this.interval) {
|
||||
this.core.LGel.trigger(lGEvents.autoplayStop, {
|
||||
index: this.core.index,
|
||||
});
|
||||
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');
|
||||
}
|
||||
clearInterval(this.interval);
|
||||
this.interval = false;
|
||||
};
|
||||
Autoplay.prototype.closeGallery = function () {
|
||||
this.stopAutoPlay();
|
||||
};
|
||||
Autoplay.prototype.destroy = function () {
|
||||
if (this.settings.autoplay) {
|
||||
this.core.outer.find('.lg-progress-bar').remove();
|
||||
}
|
||||
// Remove all event listeners added by autoplay plugin
|
||||
this.core.LGel.off('.lg.autoplay');
|
||||
this.core.LGel.off('.autoplay');
|
||||
};
|
||||
return Autoplay;
|
||||
}());
|
||||
|
||||
export default Autoplay;
|
||||
//# sourceMappingURL=lg-autoplay.es5.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(t="undefined"!=typeof globalThis?globalThis:t||self).lgAutoplay=o()}(this,(function(){"use strict";var t=function(){return(t=Object.assign||function(t){for(var o,e=1,s=arguments.length;e<s;e++)for(var r in o=arguments[e])Object.prototype.hasOwnProperty.call(o,r)&&(t[r]=o[r]);return t}).apply(this,arguments)},o="lgSlideItemLoad",e="lgBeforeSlide",s="lgAfterSlide",r="lgDragStart",i="lgDragEnd",a="lgAutoplay",l="lgAutoplayStart",n="lgAutoplayStop",u={autoplay:!0,slideShowAutoplay:!1,slideShowInterval:5e3,progressBar:!0,forceSlideShowAutoplay:!1,autoplayControls:!0,appendAutoplayControlsTo:".lg-toolbar",autoplayPluginStrings:{toggleAutoplay:"Toggle Autoplay"}};return function(){function p(o){return this.core=o,this.settings=t(t({},u),this.core.settings),this}return p.prototype.init=function(){var t=this;this.settings.autoplay&&(this.interval=!1,this.fromAuto=!0,this.pausedOnTouchDrag=!1,this.pausedOnSlideChange=!1,this.settings.autoplayControls&&this.controls(),this.settings.progressBar&&this.core.outer.append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>'),this.settings.slideShowAutoplay&&this.core.LGel.once(o+".autoplay",(function(){t.startAutoPlay()})),this.core.LGel.on(r+".autoplay touchstart.lg.autoplay",(function(){t.interval&&(t.stopAutoPlay(),t.pausedOnTouchDrag=!0)})),this.core.LGel.on(i+".autoplay touchend.lg.autoplay",(function(){!t.interval&&t.pausedOnTouchDrag&&(t.startAutoPlay(),t.pausedOnTouchDrag=!1)})),this.core.LGel.on(e+".autoplay",(function(){t.showProgressBar(),!t.fromAuto&&t.interval?(t.stopAutoPlay(),t.pausedOnSlideChange=!0):t.pausedOnSlideChange=!1,t.fromAuto=!1})),this.core.LGel.on(s+".autoplay",(function(){t.pausedOnSlideChange&&!t.interval&&t.settings.forceSlideShowAutoplay&&(t.startAutoPlay(),t.pausedOnSlideChange=!1)})),this.showProgressBar())},p.prototype.showProgressBar=function(){var t=this;if(this.settings.progressBar&&this.fromAuto){var o=this.core.outer.find(".lg-progress-bar"),e=this.core.outer.find(".lg-progress");this.interval&&(e.removeAttr("style"),o.removeClass("lg-start"),setTimeout((function(){e.css("transition","width "+(t.core.settings.speed+t.settings.slideShowInterval)+"ms ease 0s"),o.addClass("lg-start")}),20))}},p.prototype.controls=function(){var t=this,o='<button aria-label="'+this.settings.autoplayPluginStrings.toggleAutoplay+'" type="button" class="lg-autoplay-button lg-icon"></button>';this.core.outer.find(this.settings.appendAutoplayControlsTo).append(o),this.core.outer.find(".lg-autoplay-button").first().on("click.lg.autoplay",(function(){t.core.outer.hasClass("lg-show-autoplay")?t.stopAutoPlay():t.interval||t.startAutoPlay()}))},p.prototype.startAutoPlay=function(){var t=this;this.core.outer.find(".lg-progress").css("transition","width "+(this.core.settings.speed+this.settings.slideShowInterval)+"ms ease 0s"),this.core.outer.addClass("lg-show-autoplay"),this.core.outer.find(".lg-progress-bar").addClass("lg-start"),this.core.LGel.trigger(l,{index:this.core.index}),this.interval=setInterval((function(){t.core.index+1<t.core.galleryItems.length?t.core.index++:t.core.index=0,t.core.LGel.trigger(a,{index:t.core.index}),t.fromAuto=!0,t.core.slide(t.core.index,!1,!1,"next")}),this.core.settings.speed+this.settings.slideShowInterval)},p.prototype.stopAutoPlay=function(){this.interval&&(this.core.LGel.trigger(n,{index:this.core.index}),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")),clearInterval(this.interval),this.interval=!1},p.prototype.closeGallery=function(){this.stopAutoPlay()},p.prototype.destroy=function(){this.settings.autoplay&&this.core.outer.find(".lg-progress-bar").remove(),this.core.LGel.off(".lg.autoplay"),this.core.LGel.off(".autoplay")},p}()}));
|
||||
@@ -0,0 +1,258 @@
|
||||
/*!
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgAutoplay = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* List of lightGallery events
|
||||
* All events should be documented here
|
||||
* Below interfaces are used to build the website documentations
|
||||
* */
|
||||
var lGEvents = {
|
||||
afterAppendSlide: 'lgAfterAppendSlide',
|
||||
init: 'lgInit',
|
||||
hasVideo: 'lgHasVideo',
|
||||
containerResize: 'lgContainerResize',
|
||||
updateSlides: 'lgUpdateSlides',
|
||||
afterAppendSubHtml: 'lgAfterAppendSubHtml',
|
||||
beforeOpen: 'lgBeforeOpen',
|
||||
afterOpen: 'lgAfterOpen',
|
||||
slideItemLoad: 'lgSlideItemLoad',
|
||||
beforeSlide: 'lgBeforeSlide',
|
||||
afterSlide: 'lgAfterSlide',
|
||||
posterClick: 'lgPosterClick',
|
||||
dragStart: 'lgDragStart',
|
||||
dragMove: 'lgDragMove',
|
||||
dragEnd: 'lgDragEnd',
|
||||
beforeNextSlide: 'lgBeforeNextSlide',
|
||||
beforePrevSlide: 'lgBeforePrevSlide',
|
||||
beforeClose: 'lgBeforeClose',
|
||||
afterClose: 'lgAfterClose',
|
||||
rotateLeft: 'lgRotateLeft',
|
||||
rotateRight: 'lgRotateRight',
|
||||
flipHorizontal: 'lgFlipHorizontal',
|
||||
flipVertical: 'lgFlipVertical',
|
||||
autoplay: 'lgAutoplay',
|
||||
autoplayStart: 'lgAutoplayStart',
|
||||
autoplayStop: 'lgAutoplayStop',
|
||||
};
|
||||
|
||||
var autoplaySettings = {
|
||||
autoplay: true,
|
||||
slideShowAutoplay: false,
|
||||
slideShowInterval: 5000,
|
||||
progressBar: true,
|
||||
forceSlideShowAutoplay: false,
|
||||
autoplayControls: true,
|
||||
appendAutoplayControlsTo: '.lg-toolbar',
|
||||
autoplayPluginStrings: {
|
||||
toggleAutoplay: 'Toggle Autoplay',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the autoplay plugin.
|
||||
* @param {object} element - lightGallery element
|
||||
*/
|
||||
var Autoplay = /** @class */ (function () {
|
||||
function Autoplay(instance) {
|
||||
this.core = instance;
|
||||
// extend module default settings with lightGallery core settings
|
||||
this.settings = __assign(__assign({}, autoplaySettings), this.core.settings);
|
||||
return this;
|
||||
}
|
||||
Autoplay.prototype.init = function () {
|
||||
var _this = this;
|
||||
if (!this.settings.autoplay) {
|
||||
return;
|
||||
}
|
||||
this.interval = false;
|
||||
// Identify if slide happened from autoplay
|
||||
this.fromAuto = true;
|
||||
// Identify if autoplay canceled from touch/drag
|
||||
this.pausedOnTouchDrag = false;
|
||||
this.pausedOnSlideChange = false;
|
||||
// append autoplay controls
|
||||
if (this.settings.autoplayControls) {
|
||||
this.controls();
|
||||
}
|
||||
// Create progress bar
|
||||
if (this.settings.progressBar) {
|
||||
this.core.outer.append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
|
||||
}
|
||||
// Start autoplay
|
||||
if (this.settings.slideShowAutoplay) {
|
||||
this.core.LGel.once(lGEvents.slideItemLoad + ".autoplay", function () {
|
||||
_this.startAutoPlay();
|
||||
});
|
||||
}
|
||||
// cancel interval on touchstart and dragstart
|
||||
this.core.LGel.on(lGEvents.dragStart + ".autoplay touchstart.lg.autoplay", function () {
|
||||
if (_this.interval) {
|
||||
_this.stopAutoPlay();
|
||||
_this.pausedOnTouchDrag = true;
|
||||
}
|
||||
});
|
||||
// restore autoplay if autoplay canceled from touchstart / dragstart
|
||||
this.core.LGel.on(lGEvents.dragEnd + ".autoplay touchend.lg.autoplay", function () {
|
||||
if (!_this.interval && _this.pausedOnTouchDrag) {
|
||||
_this.startAutoPlay();
|
||||
_this.pausedOnTouchDrag = false;
|
||||
}
|
||||
});
|
||||
this.core.LGel.on(lGEvents.beforeSlide + ".autoplay", function () {
|
||||
_this.showProgressBar();
|
||||
if (!_this.fromAuto && _this.interval) {
|
||||
_this.stopAutoPlay();
|
||||
_this.pausedOnSlideChange = true;
|
||||
}
|
||||
else {
|
||||
_this.pausedOnSlideChange = false;
|
||||
}
|
||||
_this.fromAuto = false;
|
||||
});
|
||||
// restore autoplay if autoplay canceled from touchstart / dragstart
|
||||
this.core.LGel.on(lGEvents.afterSlide + ".autoplay", function () {
|
||||
if (_this.pausedOnSlideChange &&
|
||||
!_this.interval &&
|
||||
_this.settings.forceSlideShowAutoplay) {
|
||||
_this.startAutoPlay();
|
||||
_this.pausedOnSlideChange = false;
|
||||
}
|
||||
});
|
||||
// set progress
|
||||
this.showProgressBar();
|
||||
};
|
||||
Autoplay.prototype.showProgressBar = function () {
|
||||
var _this = this;
|
||||
if (this.settings.progressBar && this.fromAuto) {
|
||||
var _$progressBar_1 = this.core.outer.find('.lg-progress-bar');
|
||||
var _$progress_1 = this.core.outer.find('.lg-progress');
|
||||
if (this.interval) {
|
||||
_$progress_1.removeAttr('style');
|
||||
_$progressBar_1.removeClass('lg-start');
|
||||
setTimeout(function () {
|
||||
_$progress_1.css('transition', 'width ' +
|
||||
(_this.core.settings.speed +
|
||||
_this.settings.slideShowInterval) +
|
||||
'ms ease 0s');
|
||||
_$progressBar_1.addClass('lg-start');
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Manage autoplay via play/stop buttons
|
||||
Autoplay.prototype.controls = function () {
|
||||
var _this = this;
|
||||
var _html = "<button aria-label=\"" + this.settings.autoplayPluginStrings['toggleAutoplay'] + "\" type=\"button\" class=\"lg-autoplay-button lg-icon\"></button>";
|
||||
// Append autoplay controls
|
||||
this.core.outer
|
||||
.find(this.settings.appendAutoplayControlsTo)
|
||||
.append(_html);
|
||||
this.core.outer
|
||||
.find('.lg-autoplay-button')
|
||||
.first()
|
||||
.on('click.lg.autoplay', function () {
|
||||
if (_this.core.outer.hasClass('lg-show-autoplay')) {
|
||||
_this.stopAutoPlay();
|
||||
}
|
||||
else {
|
||||
if (!_this.interval) {
|
||||
_this.startAutoPlay();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
// Autostart gallery
|
||||
Autoplay.prototype.startAutoPlay = function () {
|
||||
var _this = this;
|
||||
this.core.outer
|
||||
.find('.lg-progress')
|
||||
.css('transition', 'width ' +
|
||||
(this.core.settings.speed +
|
||||
this.settings.slideShowInterval) +
|
||||
'ms ease 0s');
|
||||
this.core.outer.addClass('lg-show-autoplay');
|
||||
this.core.outer.find('.lg-progress-bar').addClass('lg-start');
|
||||
this.core.LGel.trigger(lGEvents.autoplayStart, {
|
||||
index: this.core.index,
|
||||
});
|
||||
this.interval = setInterval(function () {
|
||||
if (_this.core.index + 1 < _this.core.galleryItems.length) {
|
||||
_this.core.index++;
|
||||
}
|
||||
else {
|
||||
_this.core.index = 0;
|
||||
}
|
||||
_this.core.LGel.trigger(lGEvents.autoplay, {
|
||||
index: _this.core.index,
|
||||
});
|
||||
_this.fromAuto = true;
|
||||
_this.core.slide(_this.core.index, false, false, 'next');
|
||||
}, this.core.settings.speed + this.settings.slideShowInterval);
|
||||
};
|
||||
// cancel Autostart
|
||||
Autoplay.prototype.stopAutoPlay = function () {
|
||||
if (this.interval) {
|
||||
this.core.LGel.trigger(lGEvents.autoplayStop, {
|
||||
index: this.core.index,
|
||||
});
|
||||
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');
|
||||
}
|
||||
clearInterval(this.interval);
|
||||
this.interval = false;
|
||||
};
|
||||
Autoplay.prototype.closeGallery = function () {
|
||||
this.stopAutoPlay();
|
||||
};
|
||||
Autoplay.prototype.destroy = function () {
|
||||
if (this.settings.autoplay) {
|
||||
this.core.outer.find('.lg-progress-bar').remove();
|
||||
}
|
||||
// Remove all event listeners added by autoplay plugin
|
||||
this.core.LGel.off('.lg.autoplay');
|
||||
this.core.LGel.off('.autoplay');
|
||||
};
|
||||
return Autoplay;
|
||||
}());
|
||||
|
||||
return Autoplay;
|
||||
|
||||
})));
|
||||
//# sourceMappingURL=lg-autoplay.umd.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "lightgallery/plugins/autoplay",
|
||||
"private": true,
|
||||
"main": "lg-autoplay.umd.js",
|
||||
"module": "lg-autoplay.es5.js",
|
||||
"typings": "lg-autoplay.d.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user