lightgallery.umd.js 120 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738
  1. /*!
  2. * lightgallery | 2.7.1 | January 11th 2023
  3. * http://www.lightgalleryjs.com/
  4. * Copyright (c) 2020 Sachin Neravath;
  5. * @license GPLv3
  6. */
  7. (function (global, factory) {
  8. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  9. typeof define === 'function' && define.amd ? define(factory) :
  10. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lightGallery = factory());
  11. }(this, (function () { 'use strict';
  12. /*! *****************************************************************************
  13. Copyright (c) Microsoft Corporation.
  14. Permission to use, copy, modify, and/or distribute this software for any
  15. purpose with or without fee is hereby granted.
  16. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  17. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  18. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  19. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  20. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  21. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  22. PERFORMANCE OF THIS SOFTWARE.
  23. ***************************************************************************** */
  24. var __assign = function() {
  25. __assign = Object.assign || function __assign(t) {
  26. for (var s, i = 1, n = arguments.length; i < n; i++) {
  27. s = arguments[i];
  28. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  29. }
  30. return t;
  31. };
  32. return __assign.apply(this, arguments);
  33. };
  34. function __spreadArrays() {
  35. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  36. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  37. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  38. r[k] = a[j];
  39. return r;
  40. }
  41. /**
  42. * List of lightGallery events
  43. * All events should be documented here
  44. * Below interfaces are used to build the website documentations
  45. * */
  46. var lGEvents = {
  47. afterAppendSlide: 'lgAfterAppendSlide',
  48. init: 'lgInit',
  49. hasVideo: 'lgHasVideo',
  50. containerResize: 'lgContainerResize',
  51. updateSlides: 'lgUpdateSlides',
  52. afterAppendSubHtml: 'lgAfterAppendSubHtml',
  53. beforeOpen: 'lgBeforeOpen',
  54. afterOpen: 'lgAfterOpen',
  55. slideItemLoad: 'lgSlideItemLoad',
  56. beforeSlide: 'lgBeforeSlide',
  57. afterSlide: 'lgAfterSlide',
  58. posterClick: 'lgPosterClick',
  59. dragStart: 'lgDragStart',
  60. dragMove: 'lgDragMove',
  61. dragEnd: 'lgDragEnd',
  62. beforeNextSlide: 'lgBeforeNextSlide',
  63. beforePrevSlide: 'lgBeforePrevSlide',
  64. beforeClose: 'lgBeforeClose',
  65. afterClose: 'lgAfterClose',
  66. rotateLeft: 'lgRotateLeft',
  67. rotateRight: 'lgRotateRight',
  68. flipHorizontal: 'lgFlipHorizontal',
  69. flipVertical: 'lgFlipVertical',
  70. autoplay: 'lgAutoplay',
  71. autoplayStart: 'lgAutoplayStart',
  72. autoplayStop: 'lgAutoplayStop',
  73. };
  74. var lightGalleryCoreSettings = {
  75. mode: 'lg-slide',
  76. easing: 'ease',
  77. speed: 400,
  78. licenseKey: '0000-0000-000-0000',
  79. height: '100%',
  80. width: '100%',
  81. addClass: '',
  82. startClass: 'lg-start-zoom',
  83. backdropDuration: 300,
  84. container: '',
  85. startAnimationDuration: 400,
  86. zoomFromOrigin: true,
  87. hideBarsDelay: 0,
  88. showBarsAfter: 10000,
  89. slideDelay: 0,
  90. supportLegacyBrowser: true,
  91. allowMediaOverlap: false,
  92. videoMaxSize: '1280-720',
  93. loadYouTubePoster: true,
  94. defaultCaptionHeight: 0,
  95. ariaLabelledby: '',
  96. ariaDescribedby: '',
  97. resetScrollPosition: true,
  98. hideScrollbar: false,
  99. closable: true,
  100. swipeToClose: true,
  101. closeOnTap: true,
  102. showCloseIcon: true,
  103. showMaximizeIcon: false,
  104. loop: true,
  105. escKey: true,
  106. keyPress: true,
  107. trapFocus: true,
  108. controls: true,
  109. slideEndAnimation: true,
  110. hideControlOnEnd: false,
  111. mousewheel: false,
  112. getCaptionFromTitleOrAlt: true,
  113. appendSubHtmlTo: '.lg-sub-html',
  114. subHtmlSelectorRelative: false,
  115. preload: 2,
  116. numberOfSlideItemsInDom: 10,
  117. selector: '',
  118. selectWithin: '',
  119. nextHtml: '',
  120. prevHtml: '',
  121. index: 0,
  122. iframeWidth: '100%',
  123. iframeHeight: '100%',
  124. iframeMaxWidth: '100%',
  125. iframeMaxHeight: '100%',
  126. download: true,
  127. counter: true,
  128. appendCounterTo: '.lg-toolbar',
  129. swipeThreshold: 50,
  130. enableSwipe: true,
  131. enableDrag: true,
  132. dynamic: false,
  133. dynamicEl: [],
  134. extraProps: [],
  135. exThumbImage: '',
  136. isMobile: undefined,
  137. mobileSettings: {
  138. controls: false,
  139. showCloseIcon: false,
  140. download: false,
  141. },
  142. plugins: [],
  143. strings: {
  144. closeGallery: 'Close gallery',
  145. toggleMaximize: 'Toggle maximize',
  146. previousSlide: 'Previous slide',
  147. nextSlide: 'Next slide',
  148. download: 'Download',
  149. playVideo: 'Play video',
  150. },
  151. };
  152. function initLgPolyfills() {
  153. (function () {
  154. if (typeof window.CustomEvent === 'function')
  155. return false;
  156. function CustomEvent(event, params) {
  157. params = params || {
  158. bubbles: false,
  159. cancelable: false,
  160. detail: null,
  161. };
  162. var evt = document.createEvent('CustomEvent');
  163. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  164. return evt;
  165. }
  166. window.CustomEvent = CustomEvent;
  167. })();
  168. (function () {
  169. if (!Element.prototype.matches) {
  170. Element.prototype.matches =
  171. Element.prototype.msMatchesSelector ||
  172. Element.prototype.webkitMatchesSelector;
  173. }
  174. })();
  175. }
  176. var lgQuery = /** @class */ (function () {
  177. function lgQuery(selector) {
  178. this.cssVenderPrefixes = [
  179. 'TransitionDuration',
  180. 'TransitionTimingFunction',
  181. 'Transform',
  182. 'Transition',
  183. ];
  184. this.selector = this._getSelector(selector);
  185. this.firstElement = this._getFirstEl();
  186. return this;
  187. }
  188. lgQuery.generateUUID = function () {
  189. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  190. var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
  191. return v.toString(16);
  192. });
  193. };
  194. lgQuery.prototype._getSelector = function (selector, context) {
  195. if (context === void 0) { context = document; }
  196. if (typeof selector !== 'string') {
  197. return selector;
  198. }
  199. context = context || document;
  200. var fl = selector.substring(0, 1);
  201. if (fl === '#') {
  202. return context.querySelector(selector);
  203. }
  204. else {
  205. return context.querySelectorAll(selector);
  206. }
  207. };
  208. lgQuery.prototype._each = function (func) {
  209. if (!this.selector) {
  210. return this;
  211. }
  212. if (this.selector.length !== undefined) {
  213. [].forEach.call(this.selector, func);
  214. }
  215. else {
  216. func(this.selector, 0);
  217. }
  218. return this;
  219. };
  220. lgQuery.prototype._setCssVendorPrefix = function (el, cssProperty, value) {
  221. // prettier-ignore
  222. var property = cssProperty.replace(/-([a-z])/gi, function (s, group1) {
  223. return group1.toUpperCase();
  224. });
  225. if (this.cssVenderPrefixes.indexOf(property) !== -1) {
  226. el.style[property.charAt(0).toLowerCase() + property.slice(1)] = value;
  227. el.style['webkit' + property] = value;
  228. el.style['moz' + property] = value;
  229. el.style['ms' + property] = value;
  230. el.style['o' + property] = value;
  231. }
  232. else {
  233. el.style[property] = value;
  234. }
  235. };
  236. lgQuery.prototype._getFirstEl = function () {
  237. if (this.selector && this.selector.length !== undefined) {
  238. return this.selector[0];
  239. }
  240. else {
  241. return this.selector;
  242. }
  243. };
  244. lgQuery.prototype.isEventMatched = function (event, eventName) {
  245. var eventNamespace = eventName.split('.');
  246. return event
  247. .split('.')
  248. .filter(function (e) { return e; })
  249. .every(function (e) {
  250. return eventNamespace.indexOf(e) !== -1;
  251. });
  252. };
  253. lgQuery.prototype.attr = function (attr, value) {
  254. if (value === undefined) {
  255. if (!this.firstElement) {
  256. return '';
  257. }
  258. return this.firstElement.getAttribute(attr);
  259. }
  260. this._each(function (el) {
  261. el.setAttribute(attr, value);
  262. });
  263. return this;
  264. };
  265. lgQuery.prototype.find = function (selector) {
  266. return $LG(this._getSelector(selector, this.selector));
  267. };
  268. lgQuery.prototype.first = function () {
  269. if (this.selector && this.selector.length !== undefined) {
  270. return $LG(this.selector[0]);
  271. }
  272. else {
  273. return $LG(this.selector);
  274. }
  275. };
  276. lgQuery.prototype.eq = function (index) {
  277. return $LG(this.selector[index]);
  278. };
  279. lgQuery.prototype.parent = function () {
  280. return $LG(this.selector.parentElement);
  281. };
  282. lgQuery.prototype.get = function () {
  283. return this._getFirstEl();
  284. };
  285. lgQuery.prototype.removeAttr = function (attributes) {
  286. var attrs = attributes.split(' ');
  287. this._each(function (el) {
  288. attrs.forEach(function (attr) { return el.removeAttribute(attr); });
  289. });
  290. return this;
  291. };
  292. lgQuery.prototype.wrap = function (className) {
  293. if (!this.firstElement) {
  294. return this;
  295. }
  296. var wrapper = document.createElement('div');
  297. wrapper.className = className;
  298. this.firstElement.parentNode.insertBefore(wrapper, this.firstElement);
  299. this.firstElement.parentNode.removeChild(this.firstElement);
  300. wrapper.appendChild(this.firstElement);
  301. return this;
  302. };
  303. lgQuery.prototype.addClass = function (classNames) {
  304. if (classNames === void 0) { classNames = ''; }
  305. this._each(function (el) {
  306. // IE doesn't support multiple arguments
  307. classNames.split(' ').forEach(function (className) {
  308. if (className) {
  309. el.classList.add(className);
  310. }
  311. });
  312. });
  313. return this;
  314. };
  315. lgQuery.prototype.removeClass = function (classNames) {
  316. this._each(function (el) {
  317. // IE doesn't support multiple arguments
  318. classNames.split(' ').forEach(function (className) {
  319. if (className) {
  320. el.classList.remove(className);
  321. }
  322. });
  323. });
  324. return this;
  325. };
  326. lgQuery.prototype.hasClass = function (className) {
  327. if (!this.firstElement) {
  328. return false;
  329. }
  330. return this.firstElement.classList.contains(className);
  331. };
  332. lgQuery.prototype.hasAttribute = function (attribute) {
  333. if (!this.firstElement) {
  334. return false;
  335. }
  336. return this.firstElement.hasAttribute(attribute);
  337. };
  338. lgQuery.prototype.toggleClass = function (className) {
  339. if (!this.firstElement) {
  340. return this;
  341. }
  342. if (this.hasClass(className)) {
  343. this.removeClass(className);
  344. }
  345. else {
  346. this.addClass(className);
  347. }
  348. return this;
  349. };
  350. lgQuery.prototype.css = function (property, value) {
  351. var _this = this;
  352. this._each(function (el) {
  353. _this._setCssVendorPrefix(el, property, value);
  354. });
  355. return this;
  356. };
  357. // Need to pass separate namespaces for separate elements
  358. lgQuery.prototype.on = function (events, listener) {
  359. var _this = this;
  360. if (!this.selector) {
  361. return this;
  362. }
  363. events.split(' ').forEach(function (event) {
  364. if (!Array.isArray(lgQuery.eventListeners[event])) {
  365. lgQuery.eventListeners[event] = [];
  366. }
  367. lgQuery.eventListeners[event].push(listener);
  368. _this.selector.addEventListener(event.split('.')[0], listener);
  369. });
  370. return this;
  371. };
  372. // @todo - test this
  373. lgQuery.prototype.once = function (event, listener) {
  374. var _this = this;
  375. this.on(event, function () {
  376. _this.off(event);
  377. listener(event);
  378. });
  379. return this;
  380. };
  381. lgQuery.prototype.off = function (event) {
  382. var _this = this;
  383. if (!this.selector) {
  384. return this;
  385. }
  386. Object.keys(lgQuery.eventListeners).forEach(function (eventName) {
  387. if (_this.isEventMatched(event, eventName)) {
  388. lgQuery.eventListeners[eventName].forEach(function (listener) {
  389. _this.selector.removeEventListener(eventName.split('.')[0], listener);
  390. });
  391. lgQuery.eventListeners[eventName] = [];
  392. }
  393. });
  394. return this;
  395. };
  396. lgQuery.prototype.trigger = function (event, detail) {
  397. if (!this.firstElement) {
  398. return this;
  399. }
  400. var customEvent = new CustomEvent(event.split('.')[0], {
  401. detail: detail || null,
  402. });
  403. this.firstElement.dispatchEvent(customEvent);
  404. return this;
  405. };
  406. // Does not support IE
  407. lgQuery.prototype.load = function (url) {
  408. var _this = this;
  409. fetch(url)
  410. .then(function (res) { return res.text(); })
  411. .then(function (html) {
  412. _this.selector.innerHTML = html;
  413. });
  414. return this;
  415. };
  416. lgQuery.prototype.html = function (html) {
  417. if (html === undefined) {
  418. if (!this.firstElement) {
  419. return '';
  420. }
  421. return this.firstElement.innerHTML;
  422. }
  423. this._each(function (el) {
  424. el.innerHTML = html;
  425. });
  426. return this;
  427. };
  428. lgQuery.prototype.append = function (html) {
  429. this._each(function (el) {
  430. if (typeof html === 'string') {
  431. el.insertAdjacentHTML('beforeend', html);
  432. }
  433. else {
  434. el.appendChild(html);
  435. }
  436. });
  437. return this;
  438. };
  439. lgQuery.prototype.prepend = function (html) {
  440. this._each(function (el) {
  441. el.insertAdjacentHTML('afterbegin', html);
  442. });
  443. return this;
  444. };
  445. lgQuery.prototype.remove = function () {
  446. this._each(function (el) {
  447. el.parentNode.removeChild(el);
  448. });
  449. return this;
  450. };
  451. lgQuery.prototype.empty = function () {
  452. this._each(function (el) {
  453. el.innerHTML = '';
  454. });
  455. return this;
  456. };
  457. lgQuery.prototype.scrollTop = function (scrollTop) {
  458. if (scrollTop !== undefined) {
  459. document.body.scrollTop = scrollTop;
  460. document.documentElement.scrollTop = scrollTop;
  461. return this;
  462. }
  463. else {
  464. return (window.pageYOffset ||
  465. document.documentElement.scrollTop ||
  466. document.body.scrollTop ||
  467. 0);
  468. }
  469. };
  470. lgQuery.prototype.scrollLeft = function (scrollLeft) {
  471. if (scrollLeft !== undefined) {
  472. document.body.scrollLeft = scrollLeft;
  473. document.documentElement.scrollLeft = scrollLeft;
  474. return this;
  475. }
  476. else {
  477. return (window.pageXOffset ||
  478. document.documentElement.scrollLeft ||
  479. document.body.scrollLeft ||
  480. 0);
  481. }
  482. };
  483. lgQuery.prototype.offset = function () {
  484. if (!this.firstElement) {
  485. return {
  486. left: 0,
  487. top: 0,
  488. };
  489. }
  490. var rect = this.firstElement.getBoundingClientRect();
  491. var bodyMarginLeft = $LG('body').style().marginLeft;
  492. // Minus body margin - https://stackoverflow.com/questions/30711548/is-getboundingclientrect-left-returning-a-wrong-value
  493. return {
  494. left: rect.left - parseFloat(bodyMarginLeft) + this.scrollLeft(),
  495. top: rect.top + this.scrollTop(),
  496. };
  497. };
  498. lgQuery.prototype.style = function () {
  499. if (!this.firstElement) {
  500. return {};
  501. }
  502. return (this.firstElement.currentStyle ||
  503. window.getComputedStyle(this.firstElement));
  504. };
  505. // Width without padding and border even if box-sizing is used.
  506. lgQuery.prototype.width = function () {
  507. var style = this.style();
  508. return (this.firstElement.clientWidth -
  509. parseFloat(style.paddingLeft) -
  510. parseFloat(style.paddingRight));
  511. };
  512. // Height without padding and border even if box-sizing is used.
  513. lgQuery.prototype.height = function () {
  514. var style = this.style();
  515. return (this.firstElement.clientHeight -
  516. parseFloat(style.paddingTop) -
  517. parseFloat(style.paddingBottom));
  518. };
  519. lgQuery.eventListeners = {};
  520. return lgQuery;
  521. }());
  522. function $LG(selector) {
  523. initLgPolyfills();
  524. return new lgQuery(selector);
  525. }
  526. var defaultDynamicOptions = [
  527. 'src',
  528. 'sources',
  529. 'subHtml',
  530. 'subHtmlUrl',
  531. 'html',
  532. 'video',
  533. 'poster',
  534. 'slideName',
  535. 'responsive',
  536. 'srcset',
  537. 'sizes',
  538. 'iframe',
  539. 'downloadUrl',
  540. 'download',
  541. 'width',
  542. 'facebookShareUrl',
  543. 'tweetText',
  544. 'iframeTitle',
  545. 'twitterShareUrl',
  546. 'pinterestShareUrl',
  547. 'pinterestText',
  548. 'fbHtml',
  549. 'disqusIdentifier',
  550. 'disqusUrl',
  551. ];
  552. // Convert html data-attribute to camalcase
  553. function convertToData(attr) {
  554. // FInd a way for lgsize
  555. if (attr === 'href') {
  556. return 'src';
  557. }
  558. attr = attr.replace('data-', '');
  559. attr = attr.charAt(0).toLowerCase() + attr.slice(1);
  560. attr = attr.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
  561. return attr;
  562. }
  563. var utils = {
  564. /**
  565. * get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
  566. */
  567. getSize: function (el, container, spacing, defaultLgSize) {
  568. if (spacing === void 0) { spacing = 0; }
  569. var LGel = $LG(el);
  570. var lgSize = LGel.attr('data-lg-size') || defaultLgSize;
  571. if (!lgSize) {
  572. return;
  573. }
  574. var isResponsiveSizes = lgSize.split(',');
  575. // if at-least two viewport sizes are available
  576. if (isResponsiveSizes[1]) {
  577. var wWidth = window.innerWidth;
  578. for (var i = 0; i < isResponsiveSizes.length; i++) {
  579. var size_1 = isResponsiveSizes[i];
  580. var responsiveWidth = parseInt(size_1.split('-')[2], 10);
  581. if (responsiveWidth > wWidth) {
  582. lgSize = size_1;
  583. break;
  584. }
  585. // take last item as last option
  586. if (i === isResponsiveSizes.length - 1) {
  587. lgSize = size_1;
  588. }
  589. }
  590. }
  591. var size = lgSize.split('-');
  592. var width = parseInt(size[0], 10);
  593. var height = parseInt(size[1], 10);
  594. var cWidth = container.width();
  595. var cHeight = container.height() - spacing;
  596. var maxWidth = Math.min(cWidth, width);
  597. var maxHeight = Math.min(cHeight, height);
  598. var ratio = Math.min(maxWidth / width, maxHeight / height);
  599. return { width: width * ratio, height: height * ratio };
  600. },
  601. /**
  602. * @desc Get transform value based on the imageSize. Used for ZoomFromOrigin option
  603. * @param {jQuery Element}
  604. * @returns {String} Transform CSS string
  605. */
  606. getTransform: function (el, container, top, bottom, imageSize) {
  607. if (!imageSize) {
  608. return;
  609. }
  610. var LGel = $LG(el).find('img').first();
  611. if (!LGel.get()) {
  612. return;
  613. }
  614. var containerRect = container.get().getBoundingClientRect();
  615. var wWidth = containerRect.width;
  616. // using innerWidth to include mobile safari bottom bar
  617. var wHeight = container.height() - (top + bottom);
  618. var elWidth = LGel.width();
  619. var elHeight = LGel.height();
  620. var elStyle = LGel.style();
  621. var x = (wWidth - elWidth) / 2 -
  622. LGel.offset().left +
  623. (parseFloat(elStyle.paddingLeft) || 0) +
  624. (parseFloat(elStyle.borderLeft) || 0) +
  625. $LG(window).scrollLeft() +
  626. containerRect.left;
  627. var y = (wHeight - elHeight) / 2 -
  628. LGel.offset().top +
  629. (parseFloat(elStyle.paddingTop) || 0) +
  630. (parseFloat(elStyle.borderTop) || 0) +
  631. $LG(window).scrollTop() +
  632. top;
  633. var scX = elWidth / imageSize.width;
  634. var scY = elHeight / imageSize.height;
  635. var transform = 'translate3d(' +
  636. (x *= -1) +
  637. 'px, ' +
  638. (y *= -1) +
  639. 'px, 0) scale3d(' +
  640. scX +
  641. ', ' +
  642. scY +
  643. ', 1)';
  644. return transform;
  645. },
  646. getIframeMarkup: function (iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
  647. var title = iframeTitle ? 'title="' + iframeTitle + '"' : '';
  648. return "<div class=\"lg-video-cont lg-has-iframe\" style=\"width:" + iframeWidth + "; max-width:" + iframeMaxWidth + "; height: " + iframeHeight + "; max-height:" + iframeMaxHeight + "\">\n <iframe class=\"lg-object\" frameborder=\"0\" " + title + " src=\"" + src + "\" allowfullscreen=\"true\"></iframe>\n </div>";
  649. },
  650. getImgMarkup: function (index, src, altAttr, srcset, sizes, sources) {
  651. var srcsetAttr = srcset ? "srcset=\"" + srcset + "\"" : '';
  652. var sizesAttr = sizes ? "sizes=\"" + sizes + "\"" : '';
  653. var imgMarkup = "<img " + altAttr + " " + srcsetAttr + " " + sizesAttr + " class=\"lg-object lg-image\" data-index=\"" + index + "\" src=\"" + src + "\" />";
  654. var sourceTag = '';
  655. if (sources) {
  656. var sourceObj = typeof sources === 'string' ? JSON.parse(sources) : sources;
  657. sourceTag = sourceObj.map(function (source) {
  658. var attrs = '';
  659. Object.keys(source).forEach(function (key) {
  660. // Do not remove the first space as it is required to separate the attributes
  661. attrs += " " + key + "=\"" + source[key] + "\"";
  662. });
  663. return "<source " + attrs + "></source>";
  664. });
  665. }
  666. return "" + sourceTag + imgMarkup;
  667. },
  668. // Get src from responsive src
  669. getResponsiveSrc: function (srcItms) {
  670. var rsWidth = [];
  671. var rsSrc = [];
  672. var src = '';
  673. for (var i = 0; i < srcItms.length; i++) {
  674. var _src = srcItms[i].split(' ');
  675. // Manage empty space
  676. if (_src[0] === '') {
  677. _src.splice(0, 1);
  678. }
  679. rsSrc.push(_src[0]);
  680. rsWidth.push(_src[1]);
  681. }
  682. var wWidth = window.innerWidth;
  683. for (var j = 0; j < rsWidth.length; j++) {
  684. if (parseInt(rsWidth[j], 10) > wWidth) {
  685. src = rsSrc[j];
  686. break;
  687. }
  688. }
  689. return src;
  690. },
  691. isImageLoaded: function (img) {
  692. if (!img)
  693. return false;
  694. // During the onload event, IE correctly identifies any images that
  695. // weren’t downloaded as not complete. Others should too. Gecko-based
  696. // browsers act like NS4 in that they report this incorrectly.
  697. if (!img.complete) {
  698. return false;
  699. }
  700. // However, they do have two very useful properties: naturalWidth and
  701. // naturalHeight. These give the true size of the image. If it failed
  702. // to load, either of these should be zero.
  703. if (img.naturalWidth === 0) {
  704. return false;
  705. }
  706. // No other way of checking: assume it’s ok.
  707. return true;
  708. },
  709. getVideoPosterMarkup: function (_poster, dummyImg, videoContStyle, playVideoString, _isVideo) {
  710. var videoClass = '';
  711. if (_isVideo && _isVideo.youtube) {
  712. videoClass = 'lg-has-youtube';
  713. }
  714. else if (_isVideo && _isVideo.vimeo) {
  715. videoClass = 'lg-has-vimeo';
  716. }
  717. else {
  718. videoClass = 'lg-has-html5';
  719. }
  720. return "<div class=\"lg-video-cont " + videoClass + "\" style=\"" + videoContStyle + "\">\n <div class=\"lg-video-play-button\">\n <svg\n viewBox=\"0 0 20 20\"\n preserveAspectRatio=\"xMidYMid\"\n focusable=\"false\"\n aria-labelledby=\"" + playVideoString + "\"\n role=\"img\"\n class=\"lg-video-play-icon\"\n >\n <title>" + playVideoString + "</title>\n <polygon class=\"lg-video-play-icon-inner\" points=\"1,0 20,10 1,20\"></polygon>\n </svg>\n <svg class=\"lg-video-play-icon-bg\" viewBox=\"0 0 50 50\" focusable=\"false\">\n <circle cx=\"50%\" cy=\"50%\" r=\"20\"></circle></svg>\n <svg class=\"lg-video-play-icon-circle\" viewBox=\"0 0 50 50\" focusable=\"false\">\n <circle cx=\"50%\" cy=\"50%\" r=\"20\"></circle>\n </svg>\n </div>\n " + (dummyImg || '') + "\n <img class=\"lg-object lg-video-poster\" src=\"" + _poster + "\" />\n </div>";
  721. },
  722. getFocusableElements: function (container) {
  723. var elements = container.querySelectorAll('a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])');
  724. var visibleElements = [].filter.call(elements, function (element) {
  725. var style = window.getComputedStyle(element);
  726. return style.display !== 'none' && style.visibility !== 'hidden';
  727. });
  728. return visibleElements;
  729. },
  730. /**
  731. * @desc Create dynamic elements array from gallery items when dynamic option is false
  732. * It helps to avoid frequent DOM interaction
  733. * and avoid multiple checks for dynamic elments
  734. *
  735. * @returns {Array} dynamicEl
  736. */
  737. getDynamicOptions: function (items, extraProps, getCaptionFromTitleOrAlt, exThumbImage) {
  738. var dynamicElements = [];
  739. var availableDynamicOptions = __spreadArrays(defaultDynamicOptions, extraProps);
  740. [].forEach.call(items, function (item) {
  741. var dynamicEl = {};
  742. for (var i = 0; i < item.attributes.length; i++) {
  743. var attr = item.attributes[i];
  744. if (attr.specified) {
  745. var dynamicAttr = convertToData(attr.name);
  746. var label = '';
  747. if (availableDynamicOptions.indexOf(dynamicAttr) > -1) {
  748. label = dynamicAttr;
  749. }
  750. if (label) {
  751. dynamicEl[label] = attr.value;
  752. }
  753. }
  754. }
  755. var currentItem = $LG(item);
  756. var alt = currentItem.find('img').first().attr('alt');
  757. var title = currentItem.attr('title');
  758. var thumb = exThumbImage
  759. ? currentItem.attr(exThumbImage)
  760. : currentItem.find('img').first().attr('src');
  761. dynamicEl.thumb = thumb;
  762. if (getCaptionFromTitleOrAlt && !dynamicEl.subHtml) {
  763. dynamicEl.subHtml = title || alt || '';
  764. }
  765. dynamicEl.alt = alt || title || '';
  766. dynamicElements.push(dynamicEl);
  767. });
  768. return dynamicElements;
  769. },
  770. isMobile: function () {
  771. return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
  772. },
  773. /**
  774. * @desc Check the given src is video
  775. * @param {String} src
  776. * @return {Object} video type
  777. * Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
  778. *
  779. * @todo - this information can be moved to dynamicEl to avoid frequent calls
  780. */
  781. isVideo: function (src, isHTML5VIdeo, index) {
  782. if (!src) {
  783. if (isHTML5VIdeo) {
  784. return {
  785. html5: true,
  786. };
  787. }
  788. else {
  789. console.error('lightGallery :- data-src is not provided on slide item ' +
  790. (index + 1) +
  791. '. Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/');
  792. return;
  793. }
  794. }
  795. var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)([\&|?][\S]*)*/i);
  796. var vimeo = src.match(/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i);
  797. var wistia = src.match(/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/);
  798. if (youtube) {
  799. return {
  800. youtube: youtube,
  801. };
  802. }
  803. else if (vimeo) {
  804. return {
  805. vimeo: vimeo,
  806. };
  807. }
  808. else if (wistia) {
  809. return {
  810. wistia: wistia,
  811. };
  812. }
  813. },
  814. };
  815. // @ref - https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
  816. // @ref - https://2ality.com/2017/04/setting-up-multi-platform-packages.html
  817. // Unique id for each gallery
  818. var lgId = 0;
  819. var LightGallery = /** @class */ (function () {
  820. function LightGallery(element, options) {
  821. this.lgOpened = false;
  822. this.index = 0;
  823. // lightGallery modules
  824. this.plugins = [];
  825. // false when lightGallery load first slide content;
  826. this.lGalleryOn = false;
  827. // True when a slide animation is in progress
  828. this.lgBusy = false;
  829. this.currentItemsInDom = [];
  830. // Scroll top value before lightGallery is opened
  831. this.prevScrollTop = 0;
  832. this.bodyPaddingRight = 0;
  833. this.isDummyImageRemoved = false;
  834. this.dragOrSwipeEnabled = false;
  835. this.mediaContainerPosition = {
  836. top: 0,
  837. bottom: 0,
  838. };
  839. if (!element) {
  840. return this;
  841. }
  842. lgId++;
  843. this.lgId = lgId;
  844. this.el = element;
  845. this.LGel = $LG(element);
  846. this.generateSettings(options);
  847. this.buildModules();
  848. // When using dynamic mode, ensure dynamicEl is an array
  849. if (this.settings.dynamic &&
  850. this.settings.dynamicEl !== undefined &&
  851. !Array.isArray(this.settings.dynamicEl)) {
  852. throw 'When using dynamic mode, you must also define dynamicEl as an Array.';
  853. }
  854. this.galleryItems = this.getItems();
  855. this.normalizeSettings();
  856. // Gallery items
  857. this.init();
  858. this.validateLicense();
  859. return this;
  860. }
  861. LightGallery.prototype.generateSettings = function (options) {
  862. // lightGallery settings
  863. this.settings = __assign(__assign({}, lightGalleryCoreSettings), options);
  864. if (this.settings.isMobile &&
  865. typeof this.settings.isMobile === 'function'
  866. ? this.settings.isMobile()
  867. : utils.isMobile()) {
  868. var mobileSettings = __assign(__assign({}, this.settings.mobileSettings), this.settings.mobileSettings);
  869. this.settings = __assign(__assign({}, this.settings), mobileSettings);
  870. }
  871. };
  872. LightGallery.prototype.normalizeSettings = function () {
  873. if (this.settings.slideEndAnimation) {
  874. this.settings.hideControlOnEnd = false;
  875. }
  876. if (!this.settings.closable) {
  877. this.settings.swipeToClose = false;
  878. }
  879. // And reset it on close to get the correct value next time
  880. this.zoomFromOrigin = this.settings.zoomFromOrigin;
  881. // At the moment, Zoom from image doesn't support dynamic options
  882. // @todo add zoomFromOrigin support for dynamic images
  883. if (this.settings.dynamic) {
  884. this.zoomFromOrigin = false;
  885. }
  886. if (!this.settings.container) {
  887. this.settings.container = document.body;
  888. }
  889. // settings.preload should not be grater than $item.length
  890. this.settings.preload = Math.min(this.settings.preload, this.galleryItems.length);
  891. };
  892. LightGallery.prototype.init = function () {
  893. var _this = this;
  894. this.addSlideVideoInfo(this.galleryItems);
  895. this.buildStructure();
  896. this.LGel.trigger(lGEvents.init, {
  897. instance: this,
  898. });
  899. if (this.settings.keyPress) {
  900. this.keyPress();
  901. }
  902. setTimeout(function () {
  903. _this.enableDrag();
  904. _this.enableSwipe();
  905. _this.triggerPosterClick();
  906. }, 50);
  907. this.arrow();
  908. if (this.settings.mousewheel) {
  909. this.mousewheel();
  910. }
  911. if (!this.settings.dynamic) {
  912. this.openGalleryOnItemClick();
  913. }
  914. };
  915. LightGallery.prototype.openGalleryOnItemClick = function () {
  916. var _this = this;
  917. var _loop_1 = function (index) {
  918. var element = this_1.items[index];
  919. var $element = $LG(element);
  920. // Using different namespace for click because click event should not unbind if selector is same object('this')
  921. // @todo manage all event listners - should have namespace that represent element
  922. var uuid = lgQuery.generateUUID();
  923. $element
  924. .attr('data-lg-id', uuid)
  925. .on("click.lgcustom-item-" + uuid, function (e) {
  926. e.preventDefault();
  927. var currentItemIndex = _this.settings.index || index;
  928. _this.openGallery(currentItemIndex, element);
  929. });
  930. };
  931. var this_1 = this;
  932. // Using for loop instead of using bubbling as the items can be any html element.
  933. for (var index = 0; index < this.items.length; index++) {
  934. _loop_1(index);
  935. }
  936. };
  937. /**
  938. * Module constructor
  939. * Modules are build incrementally.
  940. * Gallery should be opened only once all the modules are initialized.
  941. * use moduleBuildTimeout to make sure this
  942. */
  943. LightGallery.prototype.buildModules = function () {
  944. var _this = this;
  945. this.settings.plugins.forEach(function (plugin) {
  946. _this.plugins.push(new plugin(_this, $LG));
  947. });
  948. };
  949. LightGallery.prototype.validateLicense = function () {
  950. if (!this.settings.licenseKey) {
  951. console.error('Please provide a valid license key');
  952. }
  953. else if (this.settings.licenseKey === '0000-0000-000-0000') {
  954. console.warn("lightGallery: " + this.settings.licenseKey + " license key is not valid for production use");
  955. }
  956. };
  957. LightGallery.prototype.getSlideItem = function (index) {
  958. return $LG(this.getSlideItemId(index));
  959. };
  960. LightGallery.prototype.getSlideItemId = function (index) {
  961. return "#lg-item-" + this.lgId + "-" + index;
  962. };
  963. LightGallery.prototype.getIdName = function (id) {
  964. return id + "-" + this.lgId;
  965. };
  966. LightGallery.prototype.getElementById = function (id) {
  967. return $LG("#" + this.getIdName(id));
  968. };
  969. LightGallery.prototype.manageSingleSlideClassName = function () {
  970. if (this.galleryItems.length < 2) {
  971. this.outer.addClass('lg-single-item');
  972. }
  973. else {
  974. this.outer.removeClass('lg-single-item');
  975. }
  976. };
  977. LightGallery.prototype.buildStructure = function () {
  978. var _this = this;
  979. var container = this.$container && this.$container.get();
  980. if (container) {
  981. return;
  982. }
  983. var controls = '';
  984. var subHtmlCont = '';
  985. // Create controls
  986. if (this.settings.controls) {
  987. controls = "<button type=\"button\" id=\"" + this.getIdName('lg-prev') + "\" aria-label=\"" + this.settings.strings['previousSlide'] + "\" class=\"lg-prev lg-icon\"> " + this.settings.prevHtml + " </button>\n <button type=\"button\" id=\"" + this.getIdName('lg-next') + "\" aria-label=\"" + this.settings.strings['nextSlide'] + "\" class=\"lg-next lg-icon\"> " + this.settings.nextHtml + " </button>";
  988. }
  989. if (this.settings.appendSubHtmlTo !== '.lg-item') {
  990. subHtmlCont =
  991. '<div class="lg-sub-html" role="status" aria-live="polite"></div>';
  992. }
  993. var addClasses = '';
  994. if (this.settings.allowMediaOverlap) {
  995. // Do not remove space before last single quote
  996. addClasses += 'lg-media-overlap ';
  997. }
  998. var ariaLabelledby = this.settings.ariaLabelledby
  999. ? 'aria-labelledby="' + this.settings.ariaLabelledby + '"'
  1000. : '';
  1001. var ariaDescribedby = this.settings.ariaDescribedby
  1002. ? 'aria-describedby="' + this.settings.ariaDescribedby + '"'
  1003. : '';
  1004. var containerClassName = "lg-container " + this.settings.addClass + " " + (document.body !== this.settings.container ? 'lg-inline' : '');
  1005. var closeIcon = this.settings.closable && this.settings.showCloseIcon
  1006. ? "<button type=\"button\" aria-label=\"" + this.settings.strings['closeGallery'] + "\" id=\"" + this.getIdName('lg-close') + "\" class=\"lg-close lg-icon\"></button>"
  1007. : '';
  1008. var maximizeIcon = this.settings.showMaximizeIcon
  1009. ? "<button type=\"button\" aria-label=\"" + this.settings.strings['toggleMaximize'] + "\" id=\"" + this.getIdName('lg-maximize') + "\" class=\"lg-maximize lg-icon\"></button>"
  1010. : '';
  1011. var template = "\n <div class=\"" + containerClassName + "\" id=\"" + this.getIdName('lg-container') + "\" tabindex=\"-1\" aria-modal=\"true\" " + ariaLabelledby + " " + ariaDescribedby + " role=\"dialog\"\n >\n <div id=\"" + this.getIdName('lg-backdrop') + "\" class=\"lg-backdrop\"></div>\n\n <div id=\"" + this.getIdName('lg-outer') + "\" class=\"lg-outer lg-use-css3 lg-css3 lg-hide-items " + addClasses + " \">\n\n <div id=\"" + this.getIdName('lg-content') + "\" class=\"lg-content\">\n <div id=\"" + this.getIdName('lg-inner') + "\" class=\"lg-inner\">\n </div>\n " + controls + "\n </div>\n <div id=\"" + this.getIdName('lg-toolbar') + "\" class=\"lg-toolbar lg-group\">\n " + maximizeIcon + "\n " + closeIcon + "\n </div>\n " + (this.settings.appendSubHtmlTo === '.lg-outer'
  1012. ? subHtmlCont
  1013. : '') + "\n <div id=\"" + this.getIdName('lg-components') + "\" class=\"lg-components\">\n " + (this.settings.appendSubHtmlTo === '.lg-sub-html'
  1014. ? subHtmlCont
  1015. : '') + "\n </div>\n </div>\n </div>\n ";
  1016. $LG(this.settings.container).append(template);
  1017. if (document.body !== this.settings.container) {
  1018. $LG(this.settings.container).css('position', 'relative');
  1019. }
  1020. this.outer = this.getElementById('lg-outer');
  1021. this.$lgComponents = this.getElementById('lg-components');
  1022. this.$backdrop = this.getElementById('lg-backdrop');
  1023. this.$container = this.getElementById('lg-container');
  1024. this.$inner = this.getElementById('lg-inner');
  1025. this.$content = this.getElementById('lg-content');
  1026. this.$toolbar = this.getElementById('lg-toolbar');
  1027. this.$backdrop.css('transition-duration', this.settings.backdropDuration + 'ms');
  1028. var outerClassNames = this.settings.mode + " ";
  1029. this.manageSingleSlideClassName();
  1030. if (this.settings.enableDrag) {
  1031. outerClassNames += 'lg-grab ';
  1032. }
  1033. this.outer.addClass(outerClassNames);
  1034. this.$inner.css('transition-timing-function', this.settings.easing);
  1035. this.$inner.css('transition-duration', this.settings.speed + 'ms');
  1036. if (this.settings.download) {
  1037. this.$toolbar.append("<a id=\"" + this.getIdName('lg-download') + "\" target=\"_blank\" rel=\"noopener\" aria-label=\"" + this.settings.strings['download'] + "\" download class=\"lg-download lg-icon\"></a>");
  1038. }
  1039. this.counter();
  1040. $LG(window).on("resize.lg.global" + this.lgId + " orientationchange.lg.global" + this.lgId, function () {
  1041. _this.refreshOnResize();
  1042. });
  1043. this.hideBars();
  1044. this.manageCloseGallery();
  1045. this.toggleMaximize();
  1046. this.initModules();
  1047. };
  1048. LightGallery.prototype.refreshOnResize = function () {
  1049. if (this.lgOpened) {
  1050. var currentGalleryItem = this.galleryItems[this.index];
  1051. var __slideVideoInfo = currentGalleryItem.__slideVideoInfo;
  1052. this.mediaContainerPosition = this.getMediaContainerPosition();
  1053. var _a = this.mediaContainerPosition, top_1 = _a.top, bottom = _a.bottom;
  1054. this.currentImageSize = utils.getSize(this.items[this.index], this.outer, top_1 + bottom, __slideVideoInfo && this.settings.videoMaxSize);
  1055. if (__slideVideoInfo) {
  1056. this.resizeVideoSlide(this.index, this.currentImageSize);
  1057. }
  1058. if (this.zoomFromOrigin && !this.isDummyImageRemoved) {
  1059. var imgStyle = this.getDummyImgStyles(this.currentImageSize);
  1060. this.outer
  1061. .find('.lg-current .lg-dummy-img')
  1062. .first()
  1063. .attr('style', imgStyle);
  1064. }
  1065. this.LGel.trigger(lGEvents.containerResize);
  1066. }
  1067. };
  1068. LightGallery.prototype.resizeVideoSlide = function (index, imageSize) {
  1069. var lgVideoStyle = this.getVideoContStyle(imageSize);
  1070. var currentSlide = this.getSlideItem(index);
  1071. currentSlide.find('.lg-video-cont').attr('style', lgVideoStyle);
  1072. };
  1073. /**
  1074. * Update slides dynamically.
  1075. * Add, edit or delete slides dynamically when lightGallery is opened.
  1076. * Modify the current gallery items and pass it via updateSlides method
  1077. * @note
  1078. * - Do not mutate existing lightGallery items directly.
  1079. * - Always pass new list of gallery items
  1080. * - You need to take care of thumbnails outside the gallery if any
  1081. * - user this method only if you want to update slides when the gallery is opened. Otherwise, use `refresh()` method.
  1082. * @param items Gallery items
  1083. * @param index After the update operation, which slide gallery should navigate to
  1084. * @category lGPublicMethods
  1085. * @example
  1086. * const plugin = lightGallery();
  1087. *
  1088. * // Adding slides dynamically
  1089. * let galleryItems = [
  1090. * // Access existing lightGallery items
  1091. * // galleryItems are automatically generated internally from the gallery HTML markup
  1092. * // or directly from galleryItems when dynamic gallery is used
  1093. * ...plugin.galleryItems,
  1094. * ...[
  1095. * {
  1096. * src: 'img/img-1.png',
  1097. * thumb: 'img/thumb1.png',
  1098. * },
  1099. * ],
  1100. * ];
  1101. * plugin.updateSlides(
  1102. * galleryItems,
  1103. * plugin.index,
  1104. * );
  1105. *
  1106. *
  1107. * // Remove slides dynamically
  1108. * galleryItems = JSON.parse(
  1109. * JSON.stringify(updateSlideInstance.galleryItems),
  1110. * );
  1111. * galleryItems.shift();
  1112. * updateSlideInstance.updateSlides(galleryItems, 1);
  1113. * @see <a href="/demos/update-slides/">Demo</a>
  1114. */
  1115. LightGallery.prototype.updateSlides = function (items, index) {
  1116. if (this.index > items.length - 1) {
  1117. this.index = items.length - 1;
  1118. }
  1119. if (items.length === 1) {
  1120. this.index = 0;
  1121. }
  1122. if (!items.length) {
  1123. this.closeGallery();
  1124. return;
  1125. }
  1126. var currentSrc = this.galleryItems[index].src;
  1127. this.galleryItems = items;
  1128. this.updateControls();
  1129. this.$inner.empty();
  1130. this.currentItemsInDom = [];
  1131. var _index = 0;
  1132. // Find the current index based on source value of the slide
  1133. this.galleryItems.some(function (galleryItem, itemIndex) {
  1134. if (galleryItem.src === currentSrc) {
  1135. _index = itemIndex;
  1136. return true;
  1137. }
  1138. return false;
  1139. });
  1140. this.currentItemsInDom = this.organizeSlideItems(_index, -1);
  1141. this.loadContent(_index, true);
  1142. this.getSlideItem(_index).addClass('lg-current');
  1143. this.index = _index;
  1144. this.updateCurrentCounter(_index);
  1145. this.LGel.trigger(lGEvents.updateSlides);
  1146. };
  1147. // Get gallery items based on multiple conditions
  1148. LightGallery.prototype.getItems = function () {
  1149. // Gallery items
  1150. this.items = [];
  1151. if (!this.settings.dynamic) {
  1152. if (this.settings.selector === 'this') {
  1153. this.items.push(this.el);
  1154. }
  1155. else if (this.settings.selector) {
  1156. if (typeof this.settings.selector === 'string') {
  1157. if (this.settings.selectWithin) {
  1158. var selectWithin = $LG(this.settings.selectWithin);
  1159. this.items = selectWithin
  1160. .find(this.settings.selector)
  1161. .get();
  1162. }
  1163. else {
  1164. this.items = this.el.querySelectorAll(this.settings.selector);
  1165. }
  1166. }
  1167. else {
  1168. this.items = this.settings.selector;
  1169. }
  1170. }
  1171. else {
  1172. this.items = this.el.children;
  1173. }
  1174. return utils.getDynamicOptions(this.items, this.settings.extraProps, this.settings.getCaptionFromTitleOrAlt, this.settings.exThumbImage);
  1175. }
  1176. else {
  1177. return this.settings.dynamicEl || [];
  1178. }
  1179. };
  1180. LightGallery.prototype.shouldHideScrollbar = function () {
  1181. return (this.settings.hideScrollbar &&
  1182. document.body === this.settings.container);
  1183. };
  1184. LightGallery.prototype.hideScrollbar = function () {
  1185. if (!this.shouldHideScrollbar()) {
  1186. return;
  1187. }
  1188. this.bodyPaddingRight = parseFloat($LG('body').style().paddingRight);
  1189. var bodyRect = document.documentElement.getBoundingClientRect();
  1190. var scrollbarWidth = window.innerWidth - bodyRect.width;
  1191. $LG(document.body).css('padding-right', scrollbarWidth + this.bodyPaddingRight + 'px');
  1192. $LG(document.body).addClass('lg-overlay-open');
  1193. };
  1194. LightGallery.prototype.resetScrollBar = function () {
  1195. if (!this.shouldHideScrollbar()) {
  1196. return;
  1197. }
  1198. $LG(document.body).css('padding-right', this.bodyPaddingRight + 'px');
  1199. $LG(document.body).removeClass('lg-overlay-open');
  1200. };
  1201. /**
  1202. * Open lightGallery.
  1203. * Open gallery with specific slide by passing index of the slide as parameter.
  1204. * @category lGPublicMethods
  1205. * @param {Number} index - index of the slide
  1206. * @param {HTMLElement} element - Which image lightGallery should zoom from
  1207. *
  1208. * @example
  1209. * const $dynamicGallery = document.getElementById('dynamic-gallery-demo');
  1210. * const dynamicGallery = lightGallery($dynamicGallery, {
  1211. * dynamic: true,
  1212. * dynamicEl: [
  1213. * {
  1214. * src: 'img/1.jpg',
  1215. * thumb: 'img/thumb-1.jpg',
  1216. * subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>',
  1217. * },
  1218. * ...
  1219. * ],
  1220. * });
  1221. * $dynamicGallery.addEventListener('click', function () {
  1222. * // Starts with third item.(Optional).
  1223. * // This is useful if you want use dynamic mode with
  1224. * // custom thumbnails (thumbnails outside gallery),
  1225. * dynamicGallery.openGallery(2);
  1226. * });
  1227. *
  1228. */
  1229. LightGallery.prototype.openGallery = function (index, element) {
  1230. var _this = this;
  1231. if (index === void 0) { index = this.settings.index; }
  1232. // prevent accidental double execution
  1233. if (this.lgOpened)
  1234. return;
  1235. this.lgOpened = true;
  1236. this.outer.removeClass('lg-hide-items');
  1237. this.hideScrollbar();
  1238. // Add display block, but still has opacity 0
  1239. this.$container.addClass('lg-show');
  1240. var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, index);
  1241. this.currentItemsInDom = itemsToBeInsertedToDom;
  1242. var items = '';
  1243. itemsToBeInsertedToDom.forEach(function (item) {
  1244. items = items + ("<div id=\"" + item + "\" class=\"lg-item\"></div>");
  1245. });
  1246. this.$inner.append(items);
  1247. this.addHtml(index);
  1248. var transform = '';
  1249. this.mediaContainerPosition = this.getMediaContainerPosition();
  1250. var _a = this.mediaContainerPosition, top = _a.top, bottom = _a.bottom;
  1251. if (!this.settings.allowMediaOverlap) {
  1252. this.setMediaContainerPosition(top, bottom);
  1253. }
  1254. var __slideVideoInfo = this.galleryItems[index].__slideVideoInfo;
  1255. if (this.zoomFromOrigin && element) {
  1256. this.currentImageSize = utils.getSize(element, this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
  1257. transform = utils.getTransform(element, this.outer, top, bottom, this.currentImageSize);
  1258. }
  1259. if (!this.zoomFromOrigin || !transform) {
  1260. this.outer.addClass(this.settings.startClass);
  1261. this.getSlideItem(index).removeClass('lg-complete');
  1262. }
  1263. var timeout = this.settings.zoomFromOrigin
  1264. ? 100
  1265. : this.settings.backdropDuration;
  1266. setTimeout(function () {
  1267. _this.outer.addClass('lg-components-open');
  1268. }, timeout);
  1269. this.index = index;
  1270. this.LGel.trigger(lGEvents.beforeOpen);
  1271. // add class lg-current to remove initial transition
  1272. this.getSlideItem(index).addClass('lg-current');
  1273. this.lGalleryOn = false;
  1274. // Store the current scroll top value to scroll back after closing the gallery..
  1275. this.prevScrollTop = $LG(window).scrollTop();
  1276. setTimeout(function () {
  1277. // Need to check both zoomFromOrigin and transform values as we need to set set the
  1278. // default opening animation if user missed to add the lg-size attribute
  1279. if (_this.zoomFromOrigin && transform) {
  1280. var currentSlide_1 = _this.getSlideItem(index);
  1281. currentSlide_1.css('transform', transform);
  1282. setTimeout(function () {
  1283. currentSlide_1
  1284. .addClass('lg-start-progress lg-start-end-progress')
  1285. .css('transition-duration', _this.settings.startAnimationDuration + 'ms');
  1286. _this.outer.addClass('lg-zoom-from-image');
  1287. });
  1288. setTimeout(function () {
  1289. currentSlide_1.css('transform', 'translate3d(0, 0, 0)');
  1290. }, 100);
  1291. }
  1292. setTimeout(function () {
  1293. _this.$backdrop.addClass('in');
  1294. _this.$container.addClass('lg-show-in');
  1295. }, 10);
  1296. setTimeout(function () {
  1297. if (_this.settings.trapFocus &&
  1298. document.body === _this.settings.container) {
  1299. _this.trapFocus();
  1300. }
  1301. }, _this.settings.backdropDuration + 50);
  1302. // lg-visible class resets gallery opacity to 1
  1303. if (!_this.zoomFromOrigin || !transform) {
  1304. setTimeout(function () {
  1305. _this.outer.addClass('lg-visible');
  1306. }, _this.settings.backdropDuration);
  1307. }
  1308. // initiate slide function
  1309. _this.slide(index, false, false, false);
  1310. _this.LGel.trigger(lGEvents.afterOpen);
  1311. });
  1312. if (document.body === this.settings.container) {
  1313. $LG('html').addClass('lg-on');
  1314. }
  1315. };
  1316. /**
  1317. * Note - Changing the position of the media on every slide transition creates a flickering effect.
  1318. * Therefore, The height of the caption is calculated dynamically, only once based on the first slide caption.
  1319. * if you have dynamic captions for each media,
  1320. * you can provide an appropriate height for the captions via allowMediaOverlap option
  1321. */
  1322. LightGallery.prototype.getMediaContainerPosition = function () {
  1323. if (this.settings.allowMediaOverlap) {
  1324. return {
  1325. top: 0,
  1326. bottom: 0,
  1327. };
  1328. }
  1329. var top = this.$toolbar.get().clientHeight || 0;
  1330. var subHtml = this.outer.find('.lg-components .lg-sub-html').get();
  1331. var captionHeight = this.settings.defaultCaptionHeight ||
  1332. (subHtml && subHtml.clientHeight) ||
  1333. 0;
  1334. var thumbContainer = this.outer.find('.lg-thumb-outer').get();
  1335. var thumbHeight = thumbContainer ? thumbContainer.clientHeight : 0;
  1336. var bottom = thumbHeight + captionHeight;
  1337. return {
  1338. top: top,
  1339. bottom: bottom,
  1340. };
  1341. };
  1342. LightGallery.prototype.setMediaContainerPosition = function (top, bottom) {
  1343. if (top === void 0) { top = 0; }
  1344. if (bottom === void 0) { bottom = 0; }
  1345. this.$content.css('top', top + 'px').css('bottom', bottom + 'px');
  1346. };
  1347. LightGallery.prototype.hideBars = function () {
  1348. var _this = this;
  1349. // Hide controllers if mouse doesn't move for some period
  1350. setTimeout(function () {
  1351. _this.outer.removeClass('lg-hide-items');
  1352. if (_this.settings.hideBarsDelay > 0) {
  1353. _this.outer.on('mousemove.lg click.lg touchstart.lg', function () {
  1354. _this.outer.removeClass('lg-hide-items');
  1355. clearTimeout(_this.hideBarTimeout);
  1356. // Timeout will be cleared on each slide movement also
  1357. _this.hideBarTimeout = setTimeout(function () {
  1358. _this.outer.addClass('lg-hide-items');
  1359. }, _this.settings.hideBarsDelay);
  1360. });
  1361. _this.outer.trigger('mousemove.lg');
  1362. }
  1363. }, this.settings.showBarsAfter);
  1364. };
  1365. LightGallery.prototype.initPictureFill = function ($img) {
  1366. if (this.settings.supportLegacyBrowser) {
  1367. try {
  1368. picturefill({
  1369. elements: [$img.get()],
  1370. });
  1371. }
  1372. catch (e) {
  1373. console.warn('lightGallery :- If you want srcset or picture tag to be supported for older browser please include picturefil javascript library in your document.');
  1374. }
  1375. }
  1376. };
  1377. /**
  1378. * @desc Create image counter
  1379. * Ex: 1/10
  1380. */
  1381. LightGallery.prototype.counter = function () {
  1382. if (this.settings.counter) {
  1383. var counterHtml = "<div class=\"lg-counter\" role=\"status\" aria-live=\"polite\">\n <span id=\"" + this.getIdName('lg-counter-current') + "\" class=\"lg-counter-current\">" + (this.index + 1) + " </span> /\n <span id=\"" + this.getIdName('lg-counter-all') + "\" class=\"lg-counter-all\">" + this.galleryItems.length + " </span></div>";
  1384. this.outer.find(this.settings.appendCounterTo).append(counterHtml);
  1385. }
  1386. };
  1387. /**
  1388. * @desc add sub-html into the slide
  1389. * @param {Number} index - index of the slide
  1390. */
  1391. LightGallery.prototype.addHtml = function (index) {
  1392. var subHtml;
  1393. var subHtmlUrl;
  1394. if (this.galleryItems[index].subHtmlUrl) {
  1395. subHtmlUrl = this.galleryItems[index].subHtmlUrl;
  1396. }
  1397. else {
  1398. subHtml = this.galleryItems[index].subHtml;
  1399. }
  1400. if (!subHtmlUrl) {
  1401. if (subHtml) {
  1402. // get first letter of sub-html
  1403. // if first letter starts with . or # get the html form the jQuery object
  1404. var fL = subHtml.substring(0, 1);
  1405. if (fL === '.' || fL === '#') {
  1406. if (this.settings.subHtmlSelectorRelative &&
  1407. !this.settings.dynamic) {
  1408. subHtml = $LG(this.items)
  1409. .eq(index)
  1410. .find(subHtml)
  1411. .first()
  1412. .html();
  1413. }
  1414. else {
  1415. subHtml = $LG(subHtml).first().html();
  1416. }
  1417. }
  1418. }
  1419. else {
  1420. subHtml = '';
  1421. }
  1422. }
  1423. if (this.settings.appendSubHtmlTo !== '.lg-item') {
  1424. if (subHtmlUrl) {
  1425. this.outer.find('.lg-sub-html').load(subHtmlUrl);
  1426. }
  1427. else {
  1428. this.outer.find('.lg-sub-html').html(subHtml);
  1429. }
  1430. }
  1431. else {
  1432. var currentSlide = $LG(this.getSlideItemId(index));
  1433. if (subHtmlUrl) {
  1434. currentSlide.load(subHtmlUrl);
  1435. }
  1436. else {
  1437. currentSlide.append("<div class=\"lg-sub-html\">" + subHtml + "</div>");
  1438. }
  1439. }
  1440. // Add lg-empty-html class if title doesn't exist
  1441. if (typeof subHtml !== 'undefined' && subHtml !== null) {
  1442. if (subHtml === '') {
  1443. this.outer
  1444. .find(this.settings.appendSubHtmlTo)
  1445. .addClass('lg-empty-html');
  1446. }
  1447. else {
  1448. this.outer
  1449. .find(this.settings.appendSubHtmlTo)
  1450. .removeClass('lg-empty-html');
  1451. }
  1452. }
  1453. this.LGel.trigger(lGEvents.afterAppendSubHtml, {
  1454. index: index,
  1455. });
  1456. };
  1457. /**
  1458. * @desc Preload slides
  1459. * @param {Number} index - index of the slide
  1460. * @todo preload not working for the first slide, Also, should work for the first and last slide as well
  1461. */
  1462. LightGallery.prototype.preload = function (index) {
  1463. for (var i = 1; i <= this.settings.preload; i++) {
  1464. if (i >= this.galleryItems.length - index) {
  1465. break;
  1466. }
  1467. this.loadContent(index + i, false);
  1468. }
  1469. for (var j = 1; j <= this.settings.preload; j++) {
  1470. if (index - j < 0) {
  1471. break;
  1472. }
  1473. this.loadContent(index - j, false);
  1474. }
  1475. };
  1476. LightGallery.prototype.getDummyImgStyles = function (imageSize) {
  1477. if (!imageSize)
  1478. return '';
  1479. return "width:" + imageSize.width + "px;\n margin-left: -" + imageSize.width / 2 + "px;\n margin-top: -" + imageSize.height / 2 + "px;\n height:" + imageSize.height + "px";
  1480. };
  1481. LightGallery.prototype.getVideoContStyle = function (imageSize) {
  1482. if (!imageSize)
  1483. return '';
  1484. return "width:" + imageSize.width + "px;\n height:" + imageSize.height + "px";
  1485. };
  1486. LightGallery.prototype.getDummyImageContent = function ($currentSlide, index, alt) {
  1487. var $currentItem;
  1488. if (!this.settings.dynamic) {
  1489. $currentItem = $LG(this.items).eq(index);
  1490. }
  1491. if ($currentItem) {
  1492. var _dummyImgSrc = void 0;
  1493. if (!this.settings.exThumbImage) {
  1494. _dummyImgSrc = $currentItem.find('img').first().attr('src');
  1495. }
  1496. else {
  1497. _dummyImgSrc = $currentItem.attr(this.settings.exThumbImage);
  1498. }
  1499. if (!_dummyImgSrc)
  1500. return '';
  1501. var imgStyle = this.getDummyImgStyles(this.currentImageSize);
  1502. var dummyImgContent = "<img " + alt + " style=\"" + imgStyle + "\" class=\"lg-dummy-img\" src=\"" + _dummyImgSrc + "\" />";
  1503. $currentSlide.addClass('lg-first-slide');
  1504. this.outer.addClass('lg-first-slide-loading');
  1505. return dummyImgContent;
  1506. }
  1507. return '';
  1508. };
  1509. LightGallery.prototype.setImgMarkup = function (src, $currentSlide, index) {
  1510. var currentGalleryItem = this.galleryItems[index];
  1511. var alt = currentGalleryItem.alt, srcset = currentGalleryItem.srcset, sizes = currentGalleryItem.sizes, sources = currentGalleryItem.sources;
  1512. // Use the thumbnail as dummy image which will be resized to actual image size and
  1513. // displayed on top of actual image
  1514. var imgContent = '';
  1515. var altAttr = alt ? 'alt="' + alt + '"' : '';
  1516. if (this.isFirstSlideWithZoomAnimation()) {
  1517. imgContent = this.getDummyImageContent($currentSlide, index, altAttr);
  1518. }
  1519. else {
  1520. imgContent = utils.getImgMarkup(index, src, altAttr, srcset, sizes, sources);
  1521. }
  1522. var imgMarkup = "<picture class=\"lg-img-wrap\"> " + imgContent + "</picture>";
  1523. $currentSlide.prepend(imgMarkup);
  1524. };
  1525. LightGallery.prototype.onSlideObjectLoad = function ($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
  1526. var mediaObject = $slide.find('.lg-object').first();
  1527. if (utils.isImageLoaded(mediaObject.get()) ||
  1528. isHTML5VideoWithoutPoster) {
  1529. onLoad();
  1530. }
  1531. else {
  1532. mediaObject.on('load.lg error.lg', function () {
  1533. onLoad && onLoad();
  1534. });
  1535. mediaObject.on('error.lg', function () {
  1536. onError && onError();
  1537. });
  1538. }
  1539. };
  1540. /**
  1541. *
  1542. * @param $el Current slide item
  1543. * @param index
  1544. * @param delay Delay is 0 except first time
  1545. * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
  1546. * @param isFirstSlide
  1547. */
  1548. LightGallery.prototype.onLgObjectLoad = function (currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
  1549. var _this = this;
  1550. this.onSlideObjectLoad(currentSlide, isHTML5VideoWithoutPoster, function () {
  1551. _this.triggerSlideItemLoad(currentSlide, index, delay, speed, isFirstSlide);
  1552. }, function () {
  1553. currentSlide.addClass('lg-complete lg-complete_');
  1554. currentSlide.html('<span class="lg-error-msg">Oops... Failed to load content...</span>');
  1555. });
  1556. };
  1557. LightGallery.prototype.triggerSlideItemLoad = function ($currentSlide, index, delay, speed, isFirstSlide) {
  1558. var _this = this;
  1559. var currentGalleryItem = this.galleryItems[index];
  1560. // Adding delay for video slides without poster for better performance and user experience
  1561. // Videos should start playing once once the gallery is completely loaded
  1562. var _speed = isFirstSlide &&
  1563. this.getSlideType(currentGalleryItem) === 'video' &&
  1564. !currentGalleryItem.poster
  1565. ? speed
  1566. : 0;
  1567. setTimeout(function () {
  1568. $currentSlide.addClass('lg-complete lg-complete_');
  1569. _this.LGel.trigger(lGEvents.slideItemLoad, {
  1570. index: index,
  1571. delay: delay || 0,
  1572. isFirstSlide: isFirstSlide,
  1573. });
  1574. }, _speed);
  1575. };
  1576. LightGallery.prototype.isFirstSlideWithZoomAnimation = function () {
  1577. return !!(!this.lGalleryOn &&
  1578. this.zoomFromOrigin &&
  1579. this.currentImageSize);
  1580. };
  1581. // Add video slideInfo
  1582. LightGallery.prototype.addSlideVideoInfo = function (items) {
  1583. var _this = this;
  1584. items.forEach(function (element, index) {
  1585. element.__slideVideoInfo = utils.isVideo(element.src, !!element.video, index);
  1586. if (element.__slideVideoInfo &&
  1587. _this.settings.loadYouTubePoster &&
  1588. !element.poster &&
  1589. element.__slideVideoInfo.youtube) {
  1590. element.poster = "//img.youtube.com/vi/" + element.__slideVideoInfo.youtube[1] + "/maxresdefault.jpg";
  1591. }
  1592. });
  1593. };
  1594. /**
  1595. * Load slide content into slide.
  1596. * This is used to load content into slides that is not visible too
  1597. * @param {Number} index - index of the slide.
  1598. * @param {Boolean} rec - if true call loadcontent() function again.
  1599. */
  1600. LightGallery.prototype.loadContent = function (index, rec) {
  1601. var _this = this;
  1602. var currentGalleryItem = this.galleryItems[index];
  1603. var $currentSlide = $LG(this.getSlideItemId(index));
  1604. var poster = currentGalleryItem.poster, srcset = currentGalleryItem.srcset, sizes = currentGalleryItem.sizes, sources = currentGalleryItem.sources;
  1605. var src = currentGalleryItem.src;
  1606. var video = currentGalleryItem.video;
  1607. var _html5Video = video && typeof video === 'string' ? JSON.parse(video) : video;
  1608. if (currentGalleryItem.responsive) {
  1609. var srcDyItms = currentGalleryItem.responsive.split(',');
  1610. src = utils.getResponsiveSrc(srcDyItms) || src;
  1611. }
  1612. var videoInfo = currentGalleryItem.__slideVideoInfo;
  1613. var lgVideoStyle = '';
  1614. var iframe = !!currentGalleryItem.iframe;
  1615. var isFirstSlide = !this.lGalleryOn;
  1616. // delay for adding complete class. it is 0 except first time.
  1617. var delay = 0;
  1618. if (isFirstSlide) {
  1619. if (this.zoomFromOrigin && this.currentImageSize) {
  1620. delay = this.settings.startAnimationDuration + 10;
  1621. }
  1622. else {
  1623. delay = this.settings.backdropDuration + 10;
  1624. }
  1625. }
  1626. if (!$currentSlide.hasClass('lg-loaded')) {
  1627. if (videoInfo) {
  1628. var _a = this.mediaContainerPosition, top_2 = _a.top, bottom = _a.bottom;
  1629. var videoSize = utils.getSize(this.items[index], this.outer, top_2 + bottom, videoInfo && this.settings.videoMaxSize);
  1630. lgVideoStyle = this.getVideoContStyle(videoSize);
  1631. }
  1632. if (iframe) {
  1633. var markup = utils.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, this.settings.iframeMaxWidth, this.settings.iframeMaxHeight, src, currentGalleryItem.iframeTitle);
  1634. $currentSlide.prepend(markup);
  1635. }
  1636. else if (poster) {
  1637. var dummyImg = '';
  1638. var hasStartAnimation = isFirstSlide &&
  1639. this.zoomFromOrigin &&
  1640. this.currentImageSize;
  1641. if (hasStartAnimation) {
  1642. dummyImg = this.getDummyImageContent($currentSlide, index, '');
  1643. }
  1644. var markup = utils.getVideoPosterMarkup(poster, dummyImg || '', lgVideoStyle, this.settings.strings['playVideo'], videoInfo);
  1645. $currentSlide.prepend(markup);
  1646. }
  1647. else if (videoInfo) {
  1648. var markup = "<div class=\"lg-video-cont \" style=\"" + lgVideoStyle + "\"></div>";
  1649. $currentSlide.prepend(markup);
  1650. }
  1651. else {
  1652. this.setImgMarkup(src, $currentSlide, index);
  1653. if (srcset || sources) {
  1654. var $img = $currentSlide.find('.lg-object');
  1655. this.initPictureFill($img);
  1656. }
  1657. }
  1658. if (poster || videoInfo) {
  1659. this.LGel.trigger(lGEvents.hasVideo, {
  1660. index: index,
  1661. src: src,
  1662. html5Video: _html5Video,
  1663. hasPoster: !!poster,
  1664. });
  1665. }
  1666. this.LGel.trigger(lGEvents.afterAppendSlide, { index: index });
  1667. if (this.lGalleryOn &&
  1668. this.settings.appendSubHtmlTo === '.lg-item') {
  1669. this.addHtml(index);
  1670. }
  1671. }
  1672. // For first time add some delay for displaying the start animation.
  1673. var _speed = 0;
  1674. // Do not change the delay value because it is required for zoom plugin.
  1675. // If gallery opened from direct url (hash) speed value should be 0
  1676. if (delay && !$LG(document.body).hasClass('lg-from-hash')) {
  1677. _speed = delay;
  1678. }
  1679. // Only for first slide and zoomFromOrigin is enabled
  1680. if (this.isFirstSlideWithZoomAnimation()) {
  1681. setTimeout(function () {
  1682. $currentSlide
  1683. .removeClass('lg-start-end-progress lg-start-progress')
  1684. .removeAttr('style');
  1685. }, this.settings.startAnimationDuration + 100);
  1686. if (!$currentSlide.hasClass('lg-loaded')) {
  1687. setTimeout(function () {
  1688. if (_this.getSlideType(currentGalleryItem) === 'image') {
  1689. var alt = currentGalleryItem.alt;
  1690. var altAttr = alt ? 'alt="' + alt + '"' : '';
  1691. $currentSlide
  1692. .find('.lg-img-wrap')
  1693. .append(utils.getImgMarkup(index, src, altAttr, srcset, sizes, currentGalleryItem.sources));
  1694. if (srcset || sources) {
  1695. var $img = $currentSlide.find('.lg-object');
  1696. _this.initPictureFill($img);
  1697. }
  1698. }
  1699. if (_this.getSlideType(currentGalleryItem) === 'image' ||
  1700. (_this.getSlideType(currentGalleryItem) === 'video' &&
  1701. poster)) {
  1702. _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, false);
  1703. // load remaining slides once the slide is completely loaded
  1704. _this.onSlideObjectLoad($currentSlide, !!(videoInfo && videoInfo.html5 && !poster), function () {
  1705. _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
  1706. }, function () {
  1707. _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
  1708. });
  1709. }
  1710. }, this.settings.startAnimationDuration + 100);
  1711. }
  1712. }
  1713. // SLide content has been added to dom
  1714. $currentSlide.addClass('lg-loaded');
  1715. if (!this.isFirstSlideWithZoomAnimation() ||
  1716. (this.getSlideType(currentGalleryItem) === 'video' && !poster)) {
  1717. this.onLgObjectLoad($currentSlide, index, delay, _speed, isFirstSlide, !!(videoInfo && videoInfo.html5 && !poster));
  1718. }
  1719. // When gallery is opened once content is loaded (second time) need to add lg-complete class for css styling
  1720. if ((!this.zoomFromOrigin || !this.currentImageSize) &&
  1721. $currentSlide.hasClass('lg-complete_') &&
  1722. !this.lGalleryOn) {
  1723. setTimeout(function () {
  1724. $currentSlide.addClass('lg-complete');
  1725. }, this.settings.backdropDuration);
  1726. }
  1727. // Content loaded
  1728. // Need to set lGalleryOn before calling preload function
  1729. this.lGalleryOn = true;
  1730. if (rec === true) {
  1731. if (!$currentSlide.hasClass('lg-complete_')) {
  1732. $currentSlide
  1733. .find('.lg-object')
  1734. .first()
  1735. .on('load.lg error.lg', function () {
  1736. _this.preload(index);
  1737. });
  1738. }
  1739. else {
  1740. this.preload(index);
  1741. }
  1742. }
  1743. };
  1744. /**
  1745. * @desc Remove dummy image content and load next slides
  1746. * Called only for the first time if zoomFromOrigin animation is enabled
  1747. * @param index
  1748. * @param $currentSlide
  1749. * @param speed
  1750. */
  1751. LightGallery.prototype.loadContentOnFirstSlideLoad = function (index, $currentSlide, speed) {
  1752. var _this = this;
  1753. setTimeout(function () {
  1754. $currentSlide.find('.lg-dummy-img').remove();
  1755. $currentSlide.removeClass('lg-first-slide');
  1756. _this.outer.removeClass('lg-first-slide-loading');
  1757. _this.isDummyImageRemoved = true;
  1758. _this.preload(index);
  1759. }, speed + 300);
  1760. };
  1761. LightGallery.prototype.getItemsToBeInsertedToDom = function (index, prevIndex, numberOfItems) {
  1762. var _this = this;
  1763. if (numberOfItems === void 0) { numberOfItems = 0; }
  1764. var itemsToBeInsertedToDom = [];
  1765. // Minimum 2 items should be there
  1766. var possibleNumberOfItems = Math.max(numberOfItems, 3);
  1767. possibleNumberOfItems = Math.min(possibleNumberOfItems, this.galleryItems.length);
  1768. var prevIndexItem = "lg-item-" + this.lgId + "-" + prevIndex;
  1769. if (this.galleryItems.length <= 3) {
  1770. this.galleryItems.forEach(function (_element, index) {
  1771. itemsToBeInsertedToDom.push("lg-item-" + _this.lgId + "-" + index);
  1772. });
  1773. return itemsToBeInsertedToDom;
  1774. }
  1775. if (index < (this.galleryItems.length - 1) / 2) {
  1776. for (var idx = index; idx > index - possibleNumberOfItems / 2 && idx >= 0; idx--) {
  1777. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + idx);
  1778. }
  1779. var numberOfExistingItems = itemsToBeInsertedToDom.length;
  1780. for (var idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
  1781. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (index + idx + 1));
  1782. }
  1783. }
  1784. else {
  1785. for (var idx = index; idx <= this.galleryItems.length - 1 &&
  1786. idx < index + possibleNumberOfItems / 2; idx++) {
  1787. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + idx);
  1788. }
  1789. var numberOfExistingItems = itemsToBeInsertedToDom.length;
  1790. for (var idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
  1791. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (index - idx - 1));
  1792. }
  1793. }
  1794. if (this.settings.loop) {
  1795. if (index === this.galleryItems.length - 1) {
  1796. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + 0);
  1797. }
  1798. else if (index === 0) {
  1799. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (this.galleryItems.length - 1));
  1800. }
  1801. }
  1802. if (itemsToBeInsertedToDom.indexOf(prevIndexItem) === -1) {
  1803. itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + prevIndex);
  1804. }
  1805. return itemsToBeInsertedToDom;
  1806. };
  1807. LightGallery.prototype.organizeSlideItems = function (index, prevIndex) {
  1808. var _this = this;
  1809. var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, prevIndex, this.settings.numberOfSlideItemsInDom);
  1810. itemsToBeInsertedToDom.forEach(function (item) {
  1811. if (_this.currentItemsInDom.indexOf(item) === -1) {
  1812. _this.$inner.append("<div id=\"" + item + "\" class=\"lg-item\"></div>");
  1813. }
  1814. });
  1815. this.currentItemsInDom.forEach(function (item) {
  1816. if (itemsToBeInsertedToDom.indexOf(item) === -1) {
  1817. $LG("#" + item).remove();
  1818. }
  1819. });
  1820. return itemsToBeInsertedToDom;
  1821. };
  1822. /**
  1823. * Get previous index of the slide
  1824. */
  1825. LightGallery.prototype.getPreviousSlideIndex = function () {
  1826. var prevIndex = 0;
  1827. try {
  1828. var currentItemId = this.outer
  1829. .find('.lg-current')
  1830. .first()
  1831. .attr('id');
  1832. prevIndex = parseInt(currentItemId.split('-')[3]) || 0;
  1833. }
  1834. catch (error) {
  1835. prevIndex = 0;
  1836. }
  1837. return prevIndex;
  1838. };
  1839. LightGallery.prototype.setDownloadValue = function (index) {
  1840. if (this.settings.download) {
  1841. var currentGalleryItem = this.galleryItems[index];
  1842. var hideDownloadBtn = currentGalleryItem.downloadUrl === false ||
  1843. currentGalleryItem.downloadUrl === 'false';
  1844. if (hideDownloadBtn) {
  1845. this.outer.addClass('lg-hide-download');
  1846. }
  1847. else {
  1848. var $download = this.getElementById('lg-download');
  1849. this.outer.removeClass('lg-hide-download');
  1850. $download.attr('href', currentGalleryItem.downloadUrl ||
  1851. currentGalleryItem.src);
  1852. if (currentGalleryItem.download) {
  1853. $download.attr('download', currentGalleryItem.download);
  1854. }
  1855. }
  1856. }
  1857. };
  1858. LightGallery.prototype.makeSlideAnimation = function (direction, currentSlideItem, previousSlideItem) {
  1859. var _this = this;
  1860. if (this.lGalleryOn) {
  1861. previousSlideItem.addClass('lg-slide-progress');
  1862. }
  1863. setTimeout(function () {
  1864. // remove all transitions
  1865. _this.outer.addClass('lg-no-trans');
  1866. _this.outer
  1867. .find('.lg-item')
  1868. .removeClass('lg-prev-slide lg-next-slide');
  1869. if (direction === 'prev') {
  1870. //prevslide
  1871. currentSlideItem.addClass('lg-prev-slide');
  1872. previousSlideItem.addClass('lg-next-slide');
  1873. }
  1874. else {
  1875. // next slide
  1876. currentSlideItem.addClass('lg-next-slide');
  1877. previousSlideItem.addClass('lg-prev-slide');
  1878. }
  1879. // give 50 ms for browser to add/remove class
  1880. setTimeout(function () {
  1881. _this.outer.find('.lg-item').removeClass('lg-current');
  1882. currentSlideItem.addClass('lg-current');
  1883. // reset all transitions
  1884. _this.outer.removeClass('lg-no-trans');
  1885. }, 50);
  1886. }, this.lGalleryOn ? this.settings.slideDelay : 0);
  1887. };
  1888. /**
  1889. * Goto a specific slide.
  1890. * @param {Number} index - index of the slide
  1891. * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
  1892. * @param {Boolean} fromThumb - true if slide function called via thumbnail click
  1893. * @param {String} direction - Direction of the slide(next/prev)
  1894. * @category lGPublicMethods
  1895. * @example
  1896. * const plugin = lightGallery();
  1897. * // to go to 3rd slide
  1898. * plugin.slide(2);
  1899. *
  1900. */
  1901. LightGallery.prototype.slide = function (index, fromTouch, fromThumb, direction) {
  1902. var _this = this;
  1903. var prevIndex = this.getPreviousSlideIndex();
  1904. this.currentItemsInDom = this.organizeSlideItems(index, prevIndex);
  1905. // Prevent multiple call, Required for hsh plugin
  1906. if (this.lGalleryOn && prevIndex === index) {
  1907. return;
  1908. }
  1909. var numberOfGalleryItems = this.galleryItems.length;
  1910. if (!this.lgBusy) {
  1911. if (this.settings.counter) {
  1912. this.updateCurrentCounter(index);
  1913. }
  1914. var currentSlideItem = this.getSlideItem(index);
  1915. var previousSlideItem_1 = this.getSlideItem(prevIndex);
  1916. var currentGalleryItem = this.galleryItems[index];
  1917. var videoInfo = currentGalleryItem.__slideVideoInfo;
  1918. this.outer.attr('data-lg-slide-type', this.getSlideType(currentGalleryItem));
  1919. this.setDownloadValue(index);
  1920. if (videoInfo) {
  1921. var _a = this.mediaContainerPosition, top_3 = _a.top, bottom = _a.bottom;
  1922. var videoSize = utils.getSize(this.items[index], this.outer, top_3 + bottom, videoInfo && this.settings.videoMaxSize);
  1923. this.resizeVideoSlide(index, videoSize);
  1924. }
  1925. this.LGel.trigger(lGEvents.beforeSlide, {
  1926. prevIndex: prevIndex,
  1927. index: index,
  1928. fromTouch: !!fromTouch,
  1929. fromThumb: !!fromThumb,
  1930. });
  1931. this.lgBusy = true;
  1932. clearTimeout(this.hideBarTimeout);
  1933. this.arrowDisable(index);
  1934. if (!direction) {
  1935. if (index < prevIndex) {
  1936. direction = 'prev';
  1937. }
  1938. else if (index > prevIndex) {
  1939. direction = 'next';
  1940. }
  1941. }
  1942. if (!fromTouch) {
  1943. this.makeSlideAnimation(direction, currentSlideItem, previousSlideItem_1);
  1944. }
  1945. else {
  1946. this.outer
  1947. .find('.lg-item')
  1948. .removeClass('lg-prev-slide lg-current lg-next-slide');
  1949. var touchPrev = void 0;
  1950. var touchNext = void 0;
  1951. if (numberOfGalleryItems > 2) {
  1952. touchPrev = index - 1;
  1953. touchNext = index + 1;
  1954. if (index === 0 && prevIndex === numberOfGalleryItems - 1) {
  1955. // next slide
  1956. touchNext = 0;
  1957. touchPrev = numberOfGalleryItems - 1;
  1958. }
  1959. else if (index === numberOfGalleryItems - 1 &&
  1960. prevIndex === 0) {
  1961. // prev slide
  1962. touchNext = 0;
  1963. touchPrev = numberOfGalleryItems - 1;
  1964. }
  1965. }
  1966. else {
  1967. touchPrev = 0;
  1968. touchNext = 1;
  1969. }
  1970. if (direction === 'prev') {
  1971. this.getSlideItem(touchNext).addClass('lg-next-slide');
  1972. }
  1973. else {
  1974. this.getSlideItem(touchPrev).addClass('lg-prev-slide');
  1975. }
  1976. currentSlideItem.addClass('lg-current');
  1977. }
  1978. // Do not put load content in set timeout as it needs to load immediately when the gallery is opened
  1979. if (!this.lGalleryOn) {
  1980. this.loadContent(index, true);
  1981. }
  1982. else {
  1983. setTimeout(function () {
  1984. _this.loadContent(index, true);
  1985. // Add title if this.settings.appendSubHtmlTo === lg-sub-html
  1986. if (_this.settings.appendSubHtmlTo !== '.lg-item') {
  1987. _this.addHtml(index);
  1988. }
  1989. }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
  1990. }
  1991. setTimeout(function () {
  1992. _this.lgBusy = false;
  1993. previousSlideItem_1.removeClass('lg-slide-progress');
  1994. _this.LGel.trigger(lGEvents.afterSlide, {
  1995. prevIndex: prevIndex,
  1996. index: index,
  1997. fromTouch: fromTouch,
  1998. fromThumb: fromThumb,
  1999. });
  2000. }, (this.lGalleryOn ? this.settings.speed + 100 : 100) + (fromTouch ? 0 : this.settings.slideDelay));
  2001. }
  2002. this.index = index;
  2003. };
  2004. LightGallery.prototype.updateCurrentCounter = function (index) {
  2005. this.getElementById('lg-counter-current').html(index + 1 + '');
  2006. };
  2007. LightGallery.prototype.updateCounterTotal = function () {
  2008. this.getElementById('lg-counter-all').html(this.galleryItems.length + '');
  2009. };
  2010. LightGallery.prototype.getSlideType = function (item) {
  2011. if (item.__slideVideoInfo) {
  2012. return 'video';
  2013. }
  2014. else if (item.iframe) {
  2015. return 'iframe';
  2016. }
  2017. else {
  2018. return 'image';
  2019. }
  2020. };
  2021. LightGallery.prototype.touchMove = function (startCoords, endCoords, e) {
  2022. var distanceX = endCoords.pageX - startCoords.pageX;
  2023. var distanceY = endCoords.pageY - startCoords.pageY;
  2024. var allowSwipe = false;
  2025. if (this.swipeDirection) {
  2026. allowSwipe = true;
  2027. }
  2028. else {
  2029. if (Math.abs(distanceX) > 15) {
  2030. this.swipeDirection = 'horizontal';
  2031. allowSwipe = true;
  2032. }
  2033. else if (Math.abs(distanceY) > 15) {
  2034. this.swipeDirection = 'vertical';
  2035. allowSwipe = true;
  2036. }
  2037. }
  2038. if (!allowSwipe) {
  2039. return;
  2040. }
  2041. var $currentSlide = this.getSlideItem(this.index);
  2042. if (this.swipeDirection === 'horizontal') {
  2043. e === null || e === void 0 ? void 0 : e.preventDefault();
  2044. // reset opacity and transition duration
  2045. this.outer.addClass('lg-dragging');
  2046. // move current slide
  2047. this.setTranslate($currentSlide, distanceX, 0);
  2048. // move next and prev slide with current slide
  2049. var width = $currentSlide.get().offsetWidth;
  2050. var slideWidthAmount = (width * 15) / 100;
  2051. var gutter = slideWidthAmount - Math.abs((distanceX * 10) / 100);
  2052. this.setTranslate(this.outer.find('.lg-prev-slide').first(), -width + distanceX - gutter, 0);
  2053. this.setTranslate(this.outer.find('.lg-next-slide').first(), width + distanceX + gutter, 0);
  2054. }
  2055. else if (this.swipeDirection === 'vertical') {
  2056. if (this.settings.swipeToClose) {
  2057. e === null || e === void 0 ? void 0 : e.preventDefault();
  2058. this.$container.addClass('lg-dragging-vertical');
  2059. var opacity = 1 - Math.abs(distanceY) / window.innerHeight;
  2060. this.$backdrop.css('opacity', opacity);
  2061. var scale = 1 - Math.abs(distanceY) / (window.innerWidth * 2);
  2062. this.setTranslate($currentSlide, 0, distanceY, scale, scale);
  2063. if (Math.abs(distanceY) > 100) {
  2064. this.outer
  2065. .addClass('lg-hide-items')
  2066. .removeClass('lg-components-open');
  2067. }
  2068. }
  2069. }
  2070. };
  2071. LightGallery.prototype.touchEnd = function (endCoords, startCoords, event) {
  2072. var _this = this;
  2073. var distance;
  2074. // keep slide animation for any mode while dragg/swipe
  2075. if (this.settings.mode !== 'lg-slide') {
  2076. this.outer.addClass('lg-slide');
  2077. }
  2078. // set transition duration
  2079. setTimeout(function () {
  2080. _this.$container.removeClass('lg-dragging-vertical');
  2081. _this.outer
  2082. .removeClass('lg-dragging lg-hide-items')
  2083. .addClass('lg-components-open');
  2084. var triggerClick = true;
  2085. if (_this.swipeDirection === 'horizontal') {
  2086. distance = endCoords.pageX - startCoords.pageX;
  2087. var distanceAbs = Math.abs(endCoords.pageX - startCoords.pageX);
  2088. if (distance < 0 &&
  2089. distanceAbs > _this.settings.swipeThreshold) {
  2090. _this.goToNextSlide(true);
  2091. triggerClick = false;
  2092. }
  2093. else if (distance > 0 &&
  2094. distanceAbs > _this.settings.swipeThreshold) {
  2095. _this.goToPrevSlide(true);
  2096. triggerClick = false;
  2097. }
  2098. }
  2099. else if (_this.swipeDirection === 'vertical') {
  2100. distance = Math.abs(endCoords.pageY - startCoords.pageY);
  2101. if (_this.settings.closable &&
  2102. _this.settings.swipeToClose &&
  2103. distance > 100) {
  2104. _this.closeGallery();
  2105. return;
  2106. }
  2107. else {
  2108. _this.$backdrop.css('opacity', 1);
  2109. }
  2110. }
  2111. _this.outer.find('.lg-item').removeAttr('style');
  2112. if (triggerClick &&
  2113. Math.abs(endCoords.pageX - startCoords.pageX) < 5) {
  2114. // Trigger click if distance is less than 5 pix
  2115. var target = $LG(event.target);
  2116. if (_this.isPosterElement(target)) {
  2117. _this.LGel.trigger(lGEvents.posterClick);
  2118. }
  2119. }
  2120. _this.swipeDirection = undefined;
  2121. });
  2122. // remove slide class once drag/swipe is completed if mode is not slide
  2123. setTimeout(function () {
  2124. if (!_this.outer.hasClass('lg-dragging') &&
  2125. _this.settings.mode !== 'lg-slide') {
  2126. _this.outer.removeClass('lg-slide');
  2127. }
  2128. }, this.settings.speed + 100);
  2129. };
  2130. LightGallery.prototype.enableSwipe = function () {
  2131. var _this = this;
  2132. var startCoords = {};
  2133. var endCoords = {};
  2134. var isMoved = false;
  2135. var isSwiping = false;
  2136. if (this.settings.enableSwipe) {
  2137. this.$inner.on('touchstart.lg', function (e) {
  2138. _this.dragOrSwipeEnabled = true;
  2139. var $item = _this.getSlideItem(_this.index);
  2140. if (($LG(e.target).hasClass('lg-item') ||
  2141. $item.get().contains(e.target)) &&
  2142. !_this.outer.hasClass('lg-zoomed') &&
  2143. !_this.lgBusy &&
  2144. e.touches.length === 1) {
  2145. isSwiping = true;
  2146. _this.touchAction = 'swipe';
  2147. _this.manageSwipeClass();
  2148. startCoords = {
  2149. pageX: e.touches[0].pageX,
  2150. pageY: e.touches[0].pageY,
  2151. };
  2152. }
  2153. });
  2154. this.$inner.on('touchmove.lg', function (e) {
  2155. if (isSwiping &&
  2156. _this.touchAction === 'swipe' &&
  2157. e.touches.length === 1) {
  2158. endCoords = {
  2159. pageX: e.touches[0].pageX,
  2160. pageY: e.touches[0].pageY,
  2161. };
  2162. _this.touchMove(startCoords, endCoords, e);
  2163. isMoved = true;
  2164. }
  2165. });
  2166. this.$inner.on('touchend.lg', function (event) {
  2167. if (_this.touchAction === 'swipe') {
  2168. if (isMoved) {
  2169. isMoved = false;
  2170. _this.touchEnd(endCoords, startCoords, event);
  2171. }
  2172. else if (isSwiping) {
  2173. var target = $LG(event.target);
  2174. if (_this.isPosterElement(target)) {
  2175. _this.LGel.trigger(lGEvents.posterClick);
  2176. }
  2177. }
  2178. _this.touchAction = undefined;
  2179. isSwiping = false;
  2180. }
  2181. });
  2182. }
  2183. };
  2184. LightGallery.prototype.enableDrag = function () {
  2185. var _this = this;
  2186. var startCoords = {};
  2187. var endCoords = {};
  2188. var isDraging = false;
  2189. var isMoved = false;
  2190. if (this.settings.enableDrag) {
  2191. this.outer.on('mousedown.lg', function (e) {
  2192. _this.dragOrSwipeEnabled = true;
  2193. var $item = _this.getSlideItem(_this.index);
  2194. if ($LG(e.target).hasClass('lg-item') ||
  2195. $item.get().contains(e.target)) {
  2196. if (!_this.outer.hasClass('lg-zoomed') && !_this.lgBusy) {
  2197. e.preventDefault();
  2198. if (!_this.lgBusy) {
  2199. _this.manageSwipeClass();
  2200. startCoords = {
  2201. pageX: e.pageX,
  2202. pageY: e.pageY,
  2203. };
  2204. isDraging = true;
  2205. // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
  2206. _this.outer.get().scrollLeft += 1;
  2207. _this.outer.get().scrollLeft -= 1;
  2208. // *
  2209. _this.outer
  2210. .removeClass('lg-grab')
  2211. .addClass('lg-grabbing');
  2212. _this.LGel.trigger(lGEvents.dragStart);
  2213. }
  2214. }
  2215. }
  2216. });
  2217. $LG(window).on("mousemove.lg.global" + this.lgId, function (e) {
  2218. if (isDraging && _this.lgOpened) {
  2219. isMoved = true;
  2220. endCoords = {
  2221. pageX: e.pageX,
  2222. pageY: e.pageY,
  2223. };
  2224. _this.touchMove(startCoords, endCoords);
  2225. _this.LGel.trigger(lGEvents.dragMove);
  2226. }
  2227. });
  2228. $LG(window).on("mouseup.lg.global" + this.lgId, function (event) {
  2229. if (!_this.lgOpened) {
  2230. return;
  2231. }
  2232. var target = $LG(event.target);
  2233. if (isMoved) {
  2234. isMoved = false;
  2235. _this.touchEnd(endCoords, startCoords, event);
  2236. _this.LGel.trigger(lGEvents.dragEnd);
  2237. }
  2238. else if (_this.isPosterElement(target)) {
  2239. _this.LGel.trigger(lGEvents.posterClick);
  2240. }
  2241. // Prevent execution on click
  2242. if (isDraging) {
  2243. isDraging = false;
  2244. _this.outer.removeClass('lg-grabbing').addClass('lg-grab');
  2245. }
  2246. });
  2247. }
  2248. };
  2249. LightGallery.prototype.triggerPosterClick = function () {
  2250. var _this = this;
  2251. this.$inner.on('click.lg', function (event) {
  2252. if (!_this.dragOrSwipeEnabled &&
  2253. _this.isPosterElement($LG(event.target))) {
  2254. _this.LGel.trigger(lGEvents.posterClick);
  2255. }
  2256. });
  2257. };
  2258. LightGallery.prototype.manageSwipeClass = function () {
  2259. var _touchNext = this.index + 1;
  2260. var _touchPrev = this.index - 1;
  2261. if (this.settings.loop && this.galleryItems.length > 2) {
  2262. if (this.index === 0) {
  2263. _touchPrev = this.galleryItems.length - 1;
  2264. }
  2265. else if (this.index === this.galleryItems.length - 1) {
  2266. _touchNext = 0;
  2267. }
  2268. }
  2269. this.outer.find('.lg-item').removeClass('lg-next-slide lg-prev-slide');
  2270. if (_touchPrev > -1) {
  2271. this.getSlideItem(_touchPrev).addClass('lg-prev-slide');
  2272. }
  2273. this.getSlideItem(_touchNext).addClass('lg-next-slide');
  2274. };
  2275. /**
  2276. * Go to next slide
  2277. * @param {Boolean} fromTouch - true if slide function called via touch event
  2278. * @category lGPublicMethods
  2279. * @example
  2280. * const plugin = lightGallery();
  2281. * plugin.goToNextSlide();
  2282. * @see <a href="/demos/methods/">Demo</a>
  2283. */
  2284. LightGallery.prototype.goToNextSlide = function (fromTouch) {
  2285. var _this = this;
  2286. var _loop = this.settings.loop;
  2287. if (fromTouch && this.galleryItems.length < 3) {
  2288. _loop = false;
  2289. }
  2290. if (!this.lgBusy) {
  2291. if (this.index + 1 < this.galleryItems.length) {
  2292. this.index++;
  2293. this.LGel.trigger(lGEvents.beforeNextSlide, {
  2294. index: this.index,
  2295. });
  2296. this.slide(this.index, !!fromTouch, false, 'next');
  2297. }
  2298. else {
  2299. if (_loop) {
  2300. this.index = 0;
  2301. this.LGel.trigger(lGEvents.beforeNextSlide, {
  2302. index: this.index,
  2303. });
  2304. this.slide(this.index, !!fromTouch, false, 'next');
  2305. }
  2306. else if (this.settings.slideEndAnimation && !fromTouch) {
  2307. this.outer.addClass('lg-right-end');
  2308. setTimeout(function () {
  2309. _this.outer.removeClass('lg-right-end');
  2310. }, 400);
  2311. }
  2312. }
  2313. }
  2314. };
  2315. /**
  2316. * Go to previous slides
  2317. * @param {Boolean} fromTouch - true if slide function called via touch event
  2318. * @category lGPublicMethods
  2319. * @example
  2320. * const plugin = lightGallery({});
  2321. * plugin.goToPrevSlide();
  2322. * @see <a href="/demos/methods/">Demo</a>
  2323. *
  2324. */
  2325. LightGallery.prototype.goToPrevSlide = function (fromTouch) {
  2326. var _this = this;
  2327. var _loop = this.settings.loop;
  2328. if (fromTouch && this.galleryItems.length < 3) {
  2329. _loop = false;
  2330. }
  2331. if (!this.lgBusy) {
  2332. if (this.index > 0) {
  2333. this.index--;
  2334. this.LGel.trigger(lGEvents.beforePrevSlide, {
  2335. index: this.index,
  2336. fromTouch: fromTouch,
  2337. });
  2338. this.slide(this.index, !!fromTouch, false, 'prev');
  2339. }
  2340. else {
  2341. if (_loop) {
  2342. this.index = this.galleryItems.length - 1;
  2343. this.LGel.trigger(lGEvents.beforePrevSlide, {
  2344. index: this.index,
  2345. fromTouch: fromTouch,
  2346. });
  2347. this.slide(this.index, !!fromTouch, false, 'prev');
  2348. }
  2349. else if (this.settings.slideEndAnimation && !fromTouch) {
  2350. this.outer.addClass('lg-left-end');
  2351. setTimeout(function () {
  2352. _this.outer.removeClass('lg-left-end');
  2353. }, 400);
  2354. }
  2355. }
  2356. }
  2357. };
  2358. LightGallery.prototype.keyPress = function () {
  2359. var _this = this;
  2360. $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
  2361. if (_this.lgOpened &&
  2362. _this.settings.escKey === true &&
  2363. e.keyCode === 27) {
  2364. e.preventDefault();
  2365. if (_this.settings.allowMediaOverlap &&
  2366. _this.outer.hasClass('lg-can-toggle') &&
  2367. _this.outer.hasClass('lg-components-open')) {
  2368. _this.outer.removeClass('lg-components-open');
  2369. }
  2370. else {
  2371. _this.closeGallery();
  2372. }
  2373. }
  2374. if (_this.lgOpened && _this.galleryItems.length > 1) {
  2375. if (e.keyCode === 37) {
  2376. e.preventDefault();
  2377. _this.goToPrevSlide();
  2378. }
  2379. if (e.keyCode === 39) {
  2380. e.preventDefault();
  2381. _this.goToNextSlide();
  2382. }
  2383. }
  2384. });
  2385. };
  2386. LightGallery.prototype.arrow = function () {
  2387. var _this = this;
  2388. this.getElementById('lg-prev').on('click.lg', function () {
  2389. _this.goToPrevSlide();
  2390. });
  2391. this.getElementById('lg-next').on('click.lg', function () {
  2392. _this.goToNextSlide();
  2393. });
  2394. };
  2395. LightGallery.prototype.arrowDisable = function (index) {
  2396. // Disable arrows if settings.hideControlOnEnd is true
  2397. if (!this.settings.loop && this.settings.hideControlOnEnd) {
  2398. var $prev = this.getElementById('lg-prev');
  2399. var $next = this.getElementById('lg-next');
  2400. if (index + 1 === this.galleryItems.length) {
  2401. $next.attr('disabled', 'disabled').addClass('disabled');
  2402. }
  2403. else {
  2404. $next.removeAttr('disabled').removeClass('disabled');
  2405. }
  2406. if (index === 0) {
  2407. $prev.attr('disabled', 'disabled').addClass('disabled');
  2408. }
  2409. else {
  2410. $prev.removeAttr('disabled').removeClass('disabled');
  2411. }
  2412. }
  2413. };
  2414. LightGallery.prototype.setTranslate = function ($el, xValue, yValue, scaleX, scaleY) {
  2415. if (scaleX === void 0) { scaleX = 1; }
  2416. if (scaleY === void 0) { scaleY = 1; }
  2417. $el.css('transform', 'translate3d(' +
  2418. xValue +
  2419. 'px, ' +
  2420. yValue +
  2421. 'px, 0px) scale3d(' +
  2422. scaleX +
  2423. ', ' +
  2424. scaleY +
  2425. ', 1)');
  2426. };
  2427. LightGallery.prototype.mousewheel = function () {
  2428. var _this = this;
  2429. var lastCall = 0;
  2430. this.outer.on('wheel.lg', function (e) {
  2431. if (!e.deltaY || _this.galleryItems.length < 2) {
  2432. return;
  2433. }
  2434. e.preventDefault();
  2435. var now = new Date().getTime();
  2436. if (now - lastCall < 1000) {
  2437. return;
  2438. }
  2439. lastCall = now;
  2440. if (e.deltaY > 0) {
  2441. _this.goToNextSlide();
  2442. }
  2443. else if (e.deltaY < 0) {
  2444. _this.goToPrevSlide();
  2445. }
  2446. });
  2447. };
  2448. LightGallery.prototype.isSlideElement = function (target) {
  2449. return (target.hasClass('lg-outer') ||
  2450. target.hasClass('lg-item') ||
  2451. target.hasClass('lg-img-wrap'));
  2452. };
  2453. LightGallery.prototype.isPosterElement = function (target) {
  2454. var playButton = this.getSlideItem(this.index)
  2455. .find('.lg-video-play-button')
  2456. .get();
  2457. return (target.hasClass('lg-video-poster') ||
  2458. target.hasClass('lg-video-play-button') ||
  2459. (playButton && playButton.contains(target.get())));
  2460. };
  2461. /**
  2462. * Maximize minimize inline gallery.
  2463. * @category lGPublicMethods
  2464. */
  2465. LightGallery.prototype.toggleMaximize = function () {
  2466. var _this = this;
  2467. this.getElementById('lg-maximize').on('click.lg', function () {
  2468. _this.$container.toggleClass('lg-inline');
  2469. _this.refreshOnResize();
  2470. });
  2471. };
  2472. LightGallery.prototype.invalidateItems = function () {
  2473. for (var index = 0; index < this.items.length; index++) {
  2474. var element = this.items[index];
  2475. var $element = $LG(element);
  2476. $element.off("click.lgcustom-item-" + $element.attr('data-lg-id'));
  2477. }
  2478. };
  2479. LightGallery.prototype.trapFocus = function () {
  2480. var _this = this;
  2481. this.$container.get().focus({
  2482. preventScroll: true,
  2483. });
  2484. $LG(window).on("keydown.lg.global" + this.lgId, function (e) {
  2485. if (!_this.lgOpened) {
  2486. return;
  2487. }
  2488. var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
  2489. if (!isTabPressed) {
  2490. return;
  2491. }
  2492. var focusableEls = utils.getFocusableElements(_this.$container.get());
  2493. var firstFocusableEl = focusableEls[0];
  2494. var lastFocusableEl = focusableEls[focusableEls.length - 1];
  2495. if (e.shiftKey) {
  2496. if (document.activeElement === firstFocusableEl) {
  2497. lastFocusableEl.focus();
  2498. e.preventDefault();
  2499. }
  2500. }
  2501. else {
  2502. if (document.activeElement === lastFocusableEl) {
  2503. firstFocusableEl.focus();
  2504. e.preventDefault();
  2505. }
  2506. }
  2507. });
  2508. };
  2509. LightGallery.prototype.manageCloseGallery = function () {
  2510. var _this = this;
  2511. if (!this.settings.closable)
  2512. return;
  2513. var mousedown = false;
  2514. this.getElementById('lg-close').on('click.lg', function () {
  2515. _this.closeGallery();
  2516. });
  2517. if (this.settings.closeOnTap) {
  2518. // If you drag the slide and release outside gallery gets close on chrome
  2519. // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
  2520. this.outer.on('mousedown.lg', function (e) {
  2521. var target = $LG(e.target);
  2522. if (_this.isSlideElement(target)) {
  2523. mousedown = true;
  2524. }
  2525. else {
  2526. mousedown = false;
  2527. }
  2528. });
  2529. this.outer.on('mousemove.lg', function () {
  2530. mousedown = false;
  2531. });
  2532. this.outer.on('mouseup.lg', function (e) {
  2533. var target = $LG(e.target);
  2534. if (_this.isSlideElement(target) && mousedown) {
  2535. if (!_this.outer.hasClass('lg-dragging')) {
  2536. _this.closeGallery();
  2537. }
  2538. }
  2539. });
  2540. }
  2541. };
  2542. /**
  2543. * Close lightGallery if it is opened.
  2544. *
  2545. * @description If closable is false in the settings, you need to pass true via closeGallery method to force close gallery
  2546. * @return returns the estimated time to close gallery completely including the close animation duration
  2547. * @category lGPublicMethods
  2548. * @example
  2549. * const plugin = lightGallery();
  2550. * plugin.closeGallery();
  2551. *
  2552. */
  2553. LightGallery.prototype.closeGallery = function (force) {
  2554. var _this = this;
  2555. if (!this.lgOpened || (!this.settings.closable && !force)) {
  2556. return 0;
  2557. }
  2558. this.LGel.trigger(lGEvents.beforeClose);
  2559. if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
  2560. $LG(window).scrollTop(this.prevScrollTop);
  2561. }
  2562. var currentItem = this.items[this.index];
  2563. var transform;
  2564. if (this.zoomFromOrigin && currentItem) {
  2565. var _a = this.mediaContainerPosition, top_4 = _a.top, bottom = _a.bottom;
  2566. var _b = this.galleryItems[this.index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster;
  2567. var imageSize = utils.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && poster && this.settings.videoMaxSize);
  2568. transform = utils.getTransform(currentItem, this.outer, top_4, bottom, imageSize);
  2569. }
  2570. if (this.zoomFromOrigin && transform) {
  2571. this.outer.addClass('lg-closing lg-zoom-from-image');
  2572. this.getSlideItem(this.index)
  2573. .addClass('lg-start-end-progress')
  2574. .css('transition-duration', this.settings.startAnimationDuration + 'ms')
  2575. .css('transform', transform);
  2576. }
  2577. else {
  2578. this.outer.addClass('lg-hide-items');
  2579. // lg-zoom-from-image is used for setting the opacity to 1 if zoomFromOrigin is true
  2580. // If the closing item doesn't have the lg-size attribute, remove this class to avoid the closing css conflicts
  2581. this.outer.removeClass('lg-zoom-from-image');
  2582. }
  2583. // Unbind all events added by lightGallery
  2584. // @todo
  2585. //this.$el.off('.lg.tm');
  2586. this.destroyModules();
  2587. this.lGalleryOn = false;
  2588. this.isDummyImageRemoved = false;
  2589. this.zoomFromOrigin = this.settings.zoomFromOrigin;
  2590. clearTimeout(this.hideBarTimeout);
  2591. this.hideBarTimeout = false;
  2592. $LG('html').removeClass('lg-on');
  2593. this.outer.removeClass('lg-visible lg-components-open');
  2594. // Resetting opacity to 0 isd required as vertical swipe to close function adds inline opacity.
  2595. this.$backdrop.removeClass('in').css('opacity', 0);
  2596. var removeTimeout = this.zoomFromOrigin && transform
  2597. ? Math.max(this.settings.startAnimationDuration, this.settings.backdropDuration)
  2598. : this.settings.backdropDuration;
  2599. this.$container.removeClass('lg-show-in');
  2600. // Once the closign animation is completed and gallery is invisible
  2601. setTimeout(function () {
  2602. if (_this.zoomFromOrigin && transform) {
  2603. _this.outer.removeClass('lg-zoom-from-image');
  2604. }
  2605. _this.$container.removeClass('lg-show');
  2606. // Reset scrollbar
  2607. _this.resetScrollBar();
  2608. // Need to remove inline opacity as it is used in the stylesheet as well
  2609. _this.$backdrop
  2610. .removeAttr('style')
  2611. .css('transition-duration', _this.settings.backdropDuration + 'ms');
  2612. _this.outer.removeClass("lg-closing " + _this.settings.startClass);
  2613. _this.getSlideItem(_this.index).removeClass('lg-start-end-progress');
  2614. _this.$inner.empty();
  2615. if (_this.lgOpened) {
  2616. _this.LGel.trigger(lGEvents.afterClose, {
  2617. instance: _this,
  2618. });
  2619. }
  2620. if (_this.$container.get()) {
  2621. _this.$container.get().blur();
  2622. }
  2623. _this.lgOpened = false;
  2624. }, removeTimeout + 100);
  2625. return removeTimeout + 100;
  2626. };
  2627. LightGallery.prototype.initModules = function () {
  2628. this.plugins.forEach(function (module) {
  2629. try {
  2630. module.init();
  2631. }
  2632. catch (err) {
  2633. console.warn("lightGallery:- make sure lightGallery module is properly initiated");
  2634. }
  2635. });
  2636. };
  2637. LightGallery.prototype.destroyModules = function (destroy) {
  2638. this.plugins.forEach(function (module) {
  2639. try {
  2640. if (destroy) {
  2641. module.destroy();
  2642. }
  2643. else {
  2644. module.closeGallery && module.closeGallery();
  2645. }
  2646. }
  2647. catch (err) {
  2648. console.warn("lightGallery:- make sure lightGallery module is properly destroyed");
  2649. }
  2650. });
  2651. };
  2652. /**
  2653. * Refresh lightGallery with new set of children.
  2654. *
  2655. * @description This is useful to update the gallery when the child elements are changed without calling destroy method.
  2656. *
  2657. * If you are using dynamic mode, you can pass the modified array of dynamicEl as the first parameter to refresh the dynamic gallery
  2658. * @see <a href="/demos/dynamic-mode/">Demo</a>
  2659. * @category lGPublicMethods
  2660. * @example
  2661. * const plugin = lightGallery();
  2662. * // Delete or add children, then call
  2663. * plugin.refresh();
  2664. *
  2665. */
  2666. LightGallery.prototype.refresh = function (galleryItems) {
  2667. if (!this.settings.dynamic) {
  2668. this.invalidateItems();
  2669. }
  2670. if (galleryItems) {
  2671. this.galleryItems = galleryItems;
  2672. }
  2673. else {
  2674. this.galleryItems = this.getItems();
  2675. }
  2676. this.updateControls();
  2677. this.openGalleryOnItemClick();
  2678. this.LGel.trigger(lGEvents.updateSlides);
  2679. };
  2680. LightGallery.prototype.updateControls = function () {
  2681. this.addSlideVideoInfo(this.galleryItems);
  2682. this.updateCounterTotal();
  2683. this.manageSingleSlideClassName();
  2684. };
  2685. LightGallery.prototype.destroyGallery = function () {
  2686. this.destroyModules(true);
  2687. if (!this.settings.dynamic) {
  2688. this.invalidateItems();
  2689. }
  2690. $LG(window).off(".lg.global" + this.lgId);
  2691. this.LGel.off('.lg');
  2692. this.$container.remove();
  2693. };
  2694. /**
  2695. * Destroy lightGallery.
  2696. * Destroy lightGallery and its plugin instances completely
  2697. *
  2698. * @description This method also calls CloseGallery function internally. Returns the time takes to completely close and destroy the instance.
  2699. * In case if you want to re-initialize lightGallery right after destroying it, initialize it only once the destroy process is completed.
  2700. * You can use refresh method most of the times.
  2701. * @category lGPublicMethods
  2702. * @example
  2703. * const plugin = lightGallery();
  2704. * plugin.destroy();
  2705. *
  2706. */
  2707. LightGallery.prototype.destroy = function () {
  2708. var closeTimeout = this.closeGallery(true);
  2709. if (closeTimeout) {
  2710. setTimeout(this.destroyGallery.bind(this), closeTimeout);
  2711. }
  2712. else {
  2713. this.destroyGallery();
  2714. }
  2715. return closeTimeout;
  2716. };
  2717. return LightGallery;
  2718. }());
  2719. function lightGallery(el, options) {
  2720. return new LightGallery(el, options);
  2721. }
  2722. return lightGallery;
  2723. })));
  2724. //# sourceMappingURL=lightgallery.umd.js.map