PageSourceSearch

https://www.dinkelsbuehl.de/fileadmin/templates/js/upgrade/libs/li…/plugins/autoplay/lg-autoplay.es5.js

js dinkelsbuehl.de collected 2026-10-02 10:46:45 UTC 9,251 bytes, 250 lines download raw bytes

1/*!
2 * lightgallery | 2.5.0-beta.5 | May 11th 2022
3 * http://www.lightgalleryjs.com/
4 * Copyright (c) 2020 Sachin Neravath;
5 * @license GPLv3
6 */
7
8/*! *****************************************************************************
9Copyright (c) Microsoft Corporation.
10
11Permission to use, copy, modify, and/or distribute this software for any
12purpose with or without fee is hereby granted.
13
14THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20PERFORMANCE OF THIS SOFTWARE.
21***************************************************************************** */
22
23var __assign = function() {
24    __assign = Object.assign || function __assign(t) {
25        for (var s, i = 1, n = arguments.length; i < n; i++) {
26            s = arguments[i];
27            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
28        }
29        return t;
30    };
31    return __assign.apply(this, arguments);
32};
33
34/**
35 * List of lightGallery events
36 * All events should be documented here
37 * Below interfaces are used to build the website documentations
38 * */
39var lGEvents = {
40    afterAppendSlide: 'lgAfterAppendSlide',
41    init: 'lgInit',
42    hasVideo: 'lgHasVideo',
43    containerResize: 'lgContainerResize',
44    updateSlides: 'lgUpdateSlides',
45    afterAppendSubHtml: 'lgAfterAppendSubHtml',
46    beforeOpen: 'lgBeforeOpen',
47    afterOpen: 'lgAfterOpen',
48    slideItemLoad: 'lgSlideItemLoad',
49    beforeSlide: 'lgBeforeSlide',
50    afterSlide: 'lgAfterSlide',
51    posterClick: 'lgPosterClick',
52    dragStart: 'lgDragStart',
53    dragMove: 'lgDragMove',
54    dragEnd: 'lgDragEnd',
55    beforeNextSlide: 'lgBeforeNextSlide',
56    beforePrevSlide: 'lgBeforePrevSlide',
57    beforeClose: 'lgBeforeClose',
58    afterClose: 'lgAfterClose',
59    rotateLeft: 'lgRotateLeft',
60    rotateRight: 'lgRotateRight',
61    flipHorizontal: 'lgFlipHorizontal',
62    flipVertical: 'lgFlipVertical',
63    autoplay: 'lgAutoplay',
64    autoplayStart: 'lgAutoplayStart',
65    autoplayStop: 'lgAutoplayStop',
66};
67
68var autoplaySettings = {
69    autoplay: true,
70    slideShowAutoplay: false,
71    slideShowInterval: 5000,
72    progressBar: true,
73    forceSlideShowAutoplay: false,
74    autoplayControls: true,
75    appendAutoplayControlsTo: '.lg-toolbar',
76    autoplayPluginStrings: {
77        toggleAutoplay: 'Toggle Autoplay',
78    },
79};
80
81/**
82 * Creates the autoplay plugin.
83 * @param {object} element - lightGallery element
84 */
85var Autoplay = /** @class */ (function () {
86    function Autoplay(instance) {
87        this.core = instance;
88        // extend module default settings with lightGallery core settings
89        this.settings = __assign(__assign({}, autoplaySettings), this.core.settings);
90        return this;
91    }
92    Autoplay.prototype.init = function () {
93        var _this = this;
94        if (!this.settings.autoplay) {
95            return;
96        }
97        this.interval = false;
98        // Identify if slide happened from autoplay
99        this.fromAuto = true;
100        // Identify if autoplay canceled from touch/drag
101        this.pausedOnTouchDrag = false;
102        this.pausedOnSlideChange = false;
103        // append autoplay controls
104        if (this.settings.autoplayControls) {
105            this.controls();
106        }
107        // Create progress bar
108        if (this.settings.progressBar) {
109            this.core.outer.append('<div class="lg-progress-bar"><div class="lg-progress"></div></div>');
110        }
111        // Start autoplay
112        if (this.settings.slideShowAutoplay) {
113            this.core.LGel.once(lGEvents.slideItemLoad + ".autoplay", function () {
114                _this.startAutoPlay();
115            });
116        }
117        // cancel interval on touchstart and dragstart
118        this.core.LGel.on(lGEvents.dragStart + ".autoplay touchstart.lg.autoplay", function () {
119            if (_this.interval) {
120                _this.stopAutoPlay();
121                _this.pausedOnTouchDrag = true;
122            }
123        });
124        // restore autoplay if autoplay canceled from touchstart / dragstart
125        this.core.LGel.on(lGEvents.dragEnd + ".autoplay touchend.lg.autoplay", function () {
126            if (!_this.interval && _this.pausedOnTouchDrag) {
127                _this.startAutoPlay();
128                _this.pausedOnTouchDrag = false;
129            }
130        });
131        this.core.LGel.on(lGEvents.beforeSlide + ".autoplay", function () {
132            _this.showProgressBar();
133            if (!_this.fromAuto && _this.interval) {
134                _this.stopAutoPlay();
135                _this.pausedOnSlideChange = true;
136            }
137            else {
138                _this.pausedOnSlideChange = false;
139            }
140            _this.fromAuto = false;
141        });
142        // restore autoplay if autoplay canceled from touchstart / dragstart
143        this.core.LGel.on(lGEvents.afterSlide + ".autoplay", function () {
144            if (_this.pausedOnSlideChange &&
145                !_this.interval &&
146                _this.settings.forceSlideShowAutoplay) {
147                _this.startAutoPlay();
148                _this.pausedOnSlideChange = false;
149            }
150        });
151        // set progress
152        this.showProgressBar();
153    };
154    Autoplay.prototype.showProgressBar = function () {
155        var _this = this;
156        if (this.settings.progressBar && this.fromAuto) {
157            var _$progressBar_1 = this.core.outer.find('.lg-progress-bar');
158            var _$progress_1 = this.core.outer.find('.lg-progress');
159            if (this.interval) {
160                _$progress_1.removeAttr('style');
161                _$progressBar_1.removeClass('lg-start');
162                setTimeout(function () {
163                    _$progress_1.css('transition', 'width ' +
164                        (_this.core.settings.speed +
165                            _this.settings.slideShowInterval) +
166                        'ms ease 0s');
167                    _$progressBar_1.addClass('lg-start');
168                }, 20);
169            }
170        }
171    };
172    // Manage autoplay via play/stop buttons
173    Autoplay.prototype.controls = function () {
174        var _this = this;
175        var _html = "<button aria-label=\"" + this.settings.autoplayPluginStrings['toggleAutoplay'] + "\" type=\"button\" class=\"lg-autoplay-button lg-icon\"></button>";
176        // Append autoplay controls
177        this.core.outer
178            .find(this.settings.appendAutoplayControlsTo)
179            .append(_html);
180        this.core.outer
181            .find('.lg-autoplay-button')
182            .first()
183            .on('click.lg.autoplay', function () {
184            if (_this.core.outer.hasClass('lg-show-autoplay')) {
185                _this.stopAutoPlay();
186            }
187            else {
188                if (!_this.interval) {
189                    _this.startAutoPlay();
190                }
191            }
192        });
193    };
194    // Autostart gallery
195    Autoplay.prototype.startAutoPlay = function () {
196        var _this = this;
197        this.core.outer
198            .find('.lg-progress')
199            .css('transition', 'width ' +
200            (this.core.settings.speed +
201                this.settings.slideShowInterval) +
202            'ms ease 0s');
203        this.core.outer.addClass('lg-show-autoplay');
204        this.core.outer.find('.lg-progress-bar').addClass('lg-start');
205        this.core.LGel.trigger(lGEvents.autoplayStart, {
206            index: this.core.index,
207        });
208        this.interval = setInterval(function () {
209            if (_this.core.index + 1 < _this.core.galleryItems.length) {
210                _this.core.index++;
211            }
212            else {
213                _this.core.index = 0;
214            }
215            _this.core.LGel.trigger(lGEvents.autoplay, {
216                index: _this.core.index,
217            });
218            _this.fromAuto = true;
219            _this.core.slide(_this.core.index, false, false, 'next');
220        }, this.core.settings.speed + this.settings.slideShowInterval);
221    };
222    // cancel Autostart
223    Autoplay.prototype.stopAutoPlay = function () {
224        if (this.interval) {
225            this.core.LGel.trigger(lGEvents.autoplayStop, {
226                index: this.core.index,
227            });
228            this.core.outer.find('.lg-progress').removeAttr('style');
229            this.core.outer.removeClass('lg-show-autoplay');
230            this.core.outer.find('.lg-progress-bar').removeClass('lg-start');
231        }
232        clearInterval(this.interval);
233        this.interval = false;
234    };
235    Autoplay.prototype.closeGallery = function () {
236        this.stopAutoPlay();
237    };
238    Autoplay.prototype.destroy = function () {
239        if (this.settings.autoplay) {
240            this.core.outer.find('.lg-progress-bar').remove();
241        }
242        // Remove all event listeners added by autoplay plugin
243        this.core.LGel.off('.lg.autoplay');
244        this.core.LGel.off('.autoplay');
245    };
246    return Autoplay;
247}());
248
249export default Autoplay;
250//# sourceMappingURL=lg-autoplay.es5.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.