/**! * 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(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.lgautoplay = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new error("cannot find module '"+o+"'");throw f.code="module_not_found",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
'); } // set progress _this.progress(); // start autoplay if (_this.core.s.autoplay) { _this.startlauto(); } // cancel interval on touchstart and dragstart utils.on(_this.el, 'ondragstart.lgtm touchstart.lgtm', function () { if (_this.interval) { _this.cancelauto(); _this.canceledontouch = true; } }); // restore autoplay if autoplay canceled from touchstart / dragstart utils.on(_this.el, 'ondragend.lgtm touchend.lgtm onslideclick.lgtm', function () { if (!_this.interval && _this.canceledontouch) { _this.startlauto(); _this.canceledontouch = false; } }); }; autoplay.prototype.progress = function () { var _this = this; var _progressbar; var _progress; utils.on(_this.el, 'onbeforeslide.lgtm', function () { // start progress bar animation if (_this.core.s.progressbar && _this.fromauto) { _progressbar = _this.core.outer.queryselector('.lg-progress-bar'); _progress = _this.core.outer.queryselector('.lg-progress'); if (_this.interval) { _progress.removeattribute('style'); utils.removeclass(_progressbar, 'lg-start'); settimeout(function () { utils.setvendor(_progress, 'transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s'); utils.addclass(_progressbar, 'lg-start'); }, 20); } } // remove setinterval if slide is triggered manually and fourceautoplay is false if (!_this.fromauto && !_this.core.s.fourceautoplay) { _this.cancelauto(); } _this.fromauto = false; }); }; // manage autoplay via play/stop buttons autoplay.prototype.controls = function () { var _this = this; var _html = ''; // append autoplay controls _this.core.outer.queryselector(this.core.s.appendautoplaycontrolsto).insertadjacenthtml('beforeend', _html); utils.on(_this.core.outer.queryselector('.lg-autoplay-button'), 'click.lg', function () { if (utils.hasclass(_this.core.outer, 'lg-show-autoplay')) { _this.cancelauto(); _this.core.s.fourceautoplay = false; } else { if (!_this.interval) { _this.startlauto(); _this.core.s.fourceautoplay = _this.fourceautoplaytemp; } } }); }; // autostart gallery autoplay.prototype.startlauto = function () { var _this = this; utils.setvendor(_this.core.outer.queryselector('.lg-progress'), 'transition', 'width ' + (_this.core.s.speed + _this.core.s.pause) + 'ms ease 0s'); utils.addclass(_this.core.outer, 'lg-show-autoplay'); utils.addclass(_this.core.outer.queryselector('.lg-progress-bar'), 'lg-start'); _this.interval = setinterval(function () { if (_this.core.index + 1 < _this.core.items.length) { _this.core.index++; } else { _this.core.index = 0; } _this.fromauto = true; _this.core.slide(_this.core.index, false, false); }, _this.core.s.speed + _this.core.s.pause); }; // cancel autostart autoplay.prototype.cancelauto = function () { clearinterval(this.interval); this.interval = false; if (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'); }; autoplay.prototype.destroy = function () { this.cancelauto(); if (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 = autoplay; }); },{}]},{},[1])(1) });