lightgallery 2.9.0 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (595) hide show
  1. package/LICENSE +690 -0
  2. package/README.md +31 -21
  3. package/dist/README.md +229 -0
  4. package/{css → dist/css}/lg-autoplay.css +7 -4
  5. package/{css → dist/css}/lg-autoplay.css.map +1 -1
  6. package/{css → dist/css}/lg-comments.css +0 -6
  7. package/{css → dist/css}/lg-comments.css.map +1 -1
  8. package/dist/css/lg-fullscreen.css +11 -0
  9. package/dist/css/lg-fullscreen.css.map +1 -0
  10. package/dist/css/lg-justified.css +37 -0
  11. package/dist/css/lg-justified.css.map +1 -0
  12. package/{css → dist/css}/lg-pager.css.map +1 -1
  13. package/{css → dist/css}/lg-rotate.css +0 -16
  14. package/{css → dist/css}/lg-rotate.css.map +1 -1
  15. package/dist/css/lg-rtl.css +94 -0
  16. package/dist/css/lg-rtl.css.map +1 -0
  17. package/{css → dist/css}/lg-share.css +4 -32
  18. package/dist/css/lg-share.css.map +1 -0
  19. package/{css → dist/css}/lg-thumbnail.css +7 -3
  20. package/dist/css/lg-thumbnail.css.map +1 -0
  21. package/{css → dist/css}/lg-transitions.css +10 -0
  22. package/dist/css/lg-transitions.css.map +1 -0
  23. package/{css → dist/css}/lg-zoom.css +20 -9
  24. package/dist/css/lg-zoom.css.map +1 -0
  25. package/{css → dist/css}/lightgallery-bundle.css +150 -118
  26. package/dist/css/lightgallery-bundle.css.map +1 -0
  27. package/dist/css/lightgallery-bundle.min.css +1 -0
  28. package/{css → dist/css}/lightgallery-core.css +49 -7
  29. package/dist/css/lightgallery-core.css.map +1 -0
  30. package/{css → dist/css}/lightgallery.css +105 -44
  31. package/dist/css/lightgallery.css.map +1 -0
  32. package/dist/lightgallery.es5.js +3848 -0
  33. package/dist/lightgallery.es5.js.map +1 -0
  34. package/dist/lightgallery.min.js +1 -0
  35. package/dist/lightgallery.umd.js +3851 -0
  36. package/dist/lightgallery.umd.js.map +1 -0
  37. package/dist/package.json +33 -0
  38. package/dist/plugins/autoplay/lg-autoplay.es5.js +193 -0
  39. package/dist/plugins/autoplay/lg-autoplay.es5.js.map +1 -0
  40. package/dist/plugins/autoplay/lg-autoplay.min.js +1 -0
  41. package/dist/plugins/autoplay/lg-autoplay.umd.js +196 -0
  42. package/dist/plugins/autoplay/lg-autoplay.umd.js.map +1 -0
  43. package/dist/plugins/autoplay/package.json +7 -0
  44. package/dist/plugins/comment/lg-comment.es5.js +136 -0
  45. package/dist/plugins/comment/lg-comment.es5.js.map +1 -0
  46. package/dist/plugins/comment/lg-comment.min.js +1 -0
  47. package/dist/plugins/comment/lg-comment.umd.js +139 -0
  48. package/dist/plugins/comment/lg-comment.umd.js.map +1 -0
  49. package/dist/plugins/comment/package.json +7 -0
  50. package/dist/plugins/fullscreen/lg-fullscreen.es5.js +114 -0
  51. package/dist/plugins/fullscreen/lg-fullscreen.es5.js.map +1 -0
  52. package/dist/plugins/fullscreen/lg-fullscreen.min.js +1 -0
  53. package/dist/plugins/fullscreen/lg-fullscreen.umd.js +117 -0
  54. package/dist/plugins/fullscreen/lg-fullscreen.umd.js.map +1 -0
  55. package/dist/plugins/fullscreen/package.json +7 -0
  56. package/dist/plugins/hash/lg-hash.es5.js +207 -0
  57. package/dist/plugins/hash/lg-hash.es5.js.map +1 -0
  58. package/dist/plugins/hash/lg-hash.min.js +1 -0
  59. package/dist/plugins/hash/lg-hash.umd.js +210 -0
  60. package/dist/plugins/hash/lg-hash.umd.js.map +1 -0
  61. package/dist/plugins/hash/package.json +7 -0
  62. package/dist/plugins/justified/lg-justified.es5.js +415 -0
  63. package/dist/plugins/justified/lg-justified.es5.js.map +1 -0
  64. package/dist/plugins/justified/lg-justified.min.js +1 -0
  65. package/dist/plugins/justified/lg-justified.umd.js +418 -0
  66. package/dist/plugins/justified/lg-justified.umd.js.map +1 -0
  67. package/dist/plugins/justified/package.json +7 -0
  68. package/dist/plugins/mediumZoom/lg-medium-zoom.es5.js +95 -0
  69. package/dist/plugins/mediumZoom/lg-medium-zoom.es5.js.map +1 -0
  70. package/dist/plugins/mediumZoom/lg-medium-zoom.min.js +1 -0
  71. package/dist/plugins/mediumZoom/lg-medium-zoom.umd.js +98 -0
  72. package/dist/plugins/mediumZoom/lg-medium-zoom.umd.js.map +1 -0
  73. package/dist/plugins/mediumZoom/package.json +7 -0
  74. package/dist/plugins/originCrop/lg-origin-crop.es5.js +622 -0
  75. package/dist/plugins/originCrop/lg-origin-crop.es5.js.map +1 -0
  76. package/dist/plugins/originCrop/lg-origin-crop.min.js +1 -0
  77. package/dist/plugins/originCrop/lg-origin-crop.umd.js +625 -0
  78. package/dist/plugins/originCrop/lg-origin-crop.umd.js.map +1 -0
  79. package/dist/plugins/pager/lg-pager.es5.js +96 -0
  80. package/dist/plugins/pager/lg-pager.es5.js.map +1 -0
  81. package/dist/plugins/pager/lg-pager.min.js +1 -0
  82. package/dist/plugins/pager/lg-pager.umd.js +99 -0
  83. package/dist/plugins/pager/lg-pager.umd.js.map +1 -0
  84. package/dist/plugins/pager/package.json +7 -0
  85. package/dist/plugins/relativeCaption/lg-relative-caption.es5.js +98 -0
  86. package/dist/plugins/relativeCaption/lg-relative-caption.es5.js.map +1 -0
  87. package/dist/plugins/relativeCaption/lg-relative-caption.min.js +1 -0
  88. package/dist/plugins/relativeCaption/lg-relative-caption.umd.js +101 -0
  89. package/dist/plugins/relativeCaption/lg-relative-caption.umd.js.map +1 -0
  90. package/dist/plugins/relativeCaption/package.json +7 -0
  91. package/dist/plugins/rotate/lg-rotate.es5.js +226 -0
  92. package/dist/plugins/rotate/lg-rotate.es5.js.map +1 -0
  93. package/dist/plugins/rotate/lg-rotate.min.js +1 -0
  94. package/dist/plugins/rotate/lg-rotate.umd.js +229 -0
  95. package/dist/plugins/rotate/lg-rotate.umd.js.map +1 -0
  96. package/dist/plugins/rotate/package.json +7 -0
  97. package/dist/plugins/share/lg-share.es5.js +309 -0
  98. package/dist/plugins/share/lg-share.es5.js.map +1 -0
  99. package/dist/plugins/share/lg-share.min.js +1 -0
  100. package/dist/plugins/share/lg-share.umd.js +312 -0
  101. package/dist/plugins/share/lg-share.umd.js.map +1 -0
  102. package/dist/plugins/share/package.json +7 -0
  103. package/dist/plugins/thumbnail/lg-thumbnail.es5.js +792 -0
  104. package/dist/plugins/thumbnail/lg-thumbnail.es5.js.map +1 -0
  105. package/dist/plugins/thumbnail/lg-thumbnail.min.js +1 -0
  106. package/dist/plugins/thumbnail/lg-thumbnail.umd.js +795 -0
  107. package/dist/plugins/thumbnail/lg-thumbnail.umd.js.map +1 -0
  108. package/dist/plugins/thumbnail/package.json +7 -0
  109. package/dist/plugins/video/lg-video.es5.js +518 -0
  110. package/dist/plugins/video/lg-video.es5.js.map +1 -0
  111. package/dist/plugins/video/lg-video.min.js +1 -0
  112. package/dist/plugins/video/lg-video.umd.js +521 -0
  113. package/dist/plugins/video/lg-video.umd.js.map +1 -0
  114. package/dist/plugins/video/package.json +7 -0
  115. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +72 -0
  116. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js.map +1 -0
  117. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -0
  118. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +75 -0
  119. package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js.map +1 -0
  120. package/dist/plugins/vimeoThumbnail/package.json +7 -0
  121. package/dist/plugins/zoom/lg-zoom.es5.js +1412 -0
  122. package/dist/plugins/zoom/lg-zoom.es5.js.map +1 -0
  123. package/dist/plugins/zoom/lg-zoom.min.js +1 -0
  124. package/dist/plugins/zoom/lg-zoom.umd.js +1415 -0
  125. package/dist/plugins/zoom/lg-zoom.umd.js.map +1 -0
  126. package/dist/plugins/zoom/package.json +7 -0
  127. package/{scss → dist/scss}/_lg-theme-default.scss +68 -18
  128. package/{scss → dist/scss}/_lg-variables.scss +0 -1
  129. package/{scss → dist/scss}/lg-autoplay.scss +10 -4
  130. package/{scss → dist/scss}/lg-comments.scss +0 -8
  131. package/dist/scss/lg-fullscreen.scss +15 -0
  132. package/dist/scss/lg-justified.scss +63 -0
  133. package/{scss → dist/scss}/lg-rotate.scss +0 -24
  134. package/dist/scss/lg-rtl.scss +145 -0
  135. package/{scss → dist/scss}/lg-share.scss +6 -33
  136. package/{scss → dist/scss}/lg-thumbnail.scss +16 -5
  137. package/{scss → dist/scss}/lg-zoom.scss +46 -9
  138. package/{scss → dist/scss}/lightgallery-bundle.scss +0 -1
  139. package/{scss → dist/scss}/lightgallery-core.scss +73 -6
  140. package/{scss → dist/scss}/lightgallery.scss +0 -1
  141. package/{scss → dist/scss}/transitions/_lg-scale-up.scss +6 -0
  142. package/{scss → dist/scss}/transitions/_lg-slide-circular-vertical.scss +6 -0
  143. package/{scss → dist/scss}/transitions/_lg-slide-circular.scss +6 -0
  144. package/{scss → dist/scss}/transitions/_lg-soft-zoom.scss +6 -0
  145. package/{scss → dist/scss}/transitions/_lg-zoom-in-big.scss +6 -0
  146. package/{scss → dist/scss}/transitions/_lg-zoom-in-out.scss +6 -0
  147. package/{scss → dist/scss}/transitions/_lg-zoom-in.scss +6 -0
  148. package/{scss → dist/scss}/transitions/_lg-zoom-out-big.scss +6 -0
  149. package/{scss → dist/scss}/transitions/_lg-zoom-out-in.scss +6 -0
  150. package/{scss → dist/scss}/transitions/_lg-zoom-out.scss +6 -0
  151. package/{index.d.ts → dist/types/index.d.ts} +8 -4
  152. package/{lg-events.d.ts → dist/types/lg-events.d.ts} +300 -300
  153. package/dist/types/lg-icons.d.ts +27 -0
  154. package/{lg-plugin.d.ts → dist/types/lg-plugin.d.ts} +7 -7
  155. package/{lg-settings.d.ts → dist/types/lg-settings.d.ts} +555 -425
  156. package/dist/types/lg-spring-runner.d.ts +14 -0
  157. package/dist/types/lg-toolbar-overflow.d.ts +36 -0
  158. package/{lg-utils.d.ts → dist/types/lg-utils.d.ts} +236 -228
  159. package/{lgQuery.d.ts → dist/types/lgQuery.d.ts} +56 -56
  160. package/{lightgallery.d.ts → dist/types/lightgallery.d.ts} +385 -305
  161. package/{plugins → dist/types/plugins}/autoplay/lg-autoplay-settings.d.ts +41 -38
  162. package/{plugins → dist/types/plugins}/autoplay/lg-autoplay.d.ts +22 -22
  163. package/{plugins → dist/types/plugins}/comment/lg-comment-settings.d.ts +36 -33
  164. package/{plugins → dist/types/plugins}/comment/lg-comment.d.ts +25 -25
  165. package/{plugins → dist/types/plugins}/fullscreen/lg-fullscreen-settings.d.ts +17 -14
  166. package/{plugins → dist/types/plugins}/fullscreen/lg-fullscreen.d.ts +16 -16
  167. package/dist/types/plugins/hash/lg-hash-settings.d.ts +28 -0
  168. package/{plugins → dist/types/plugins}/hash/lg-hash.d.ts +25 -23
  169. package/dist/types/plugins/justified/lg-justified-settings.d.ts +42 -0
  170. package/dist/types/plugins/justified/lg-justified.d.ts +55 -0
  171. package/{plugins → dist/types/plugins}/mediumZoom/lg-medium-zoom-settings.d.ts +16 -16
  172. package/{plugins → dist/types/plugins}/mediumZoom/lg-medium-zoom.d.ts +12 -12
  173. package/dist/types/plugins/originCrop/lg-origin-crop-settings.d.ts +12 -0
  174. package/dist/types/plugins/originCrop/lg-origin-crop.d.ts +79 -0
  175. package/{plugins → dist/types/plugins}/pager/lg-pager-settings.d.ts +7 -7
  176. package/{plugins → dist/types/plugins}/pager/lg-pager.d.ts +13 -13
  177. package/{plugins → dist/types/plugins}/relativeCaption/lg-relative-caption-settings.d.ts +7 -7
  178. package/{plugins → dist/types/plugins}/relativeCaption/lg-relative-caption.d.ts +14 -14
  179. package/{plugins → dist/types/plugins}/rotate/lg-rotate-settings.d.ts +47 -45
  180. package/{plugins → dist/types/plugins}/rotate/lg-rotate.d.ts +25 -24
  181. package/{plugins → dist/types/plugins}/share/lg-fb-share-utils.d.ts +2 -2
  182. package/{plugins → dist/types/plugins}/share/lg-pinterest-share-utils.d.ts +2 -2
  183. package/{plugins → dist/types/plugins}/share/lg-share-settings.d.ts +71 -56
  184. package/dist/types/plugins/share/lg-share.d.ts +33 -0
  185. package/dist/types/plugins/share/lg-twitter-share-utils.d.ts +4 -0
  186. package/{plugins → dist/types/plugins}/share/types.d.ts +6 -6
  187. package/{plugins → dist/types/plugins}/thumbnail/lg-thumbnail-settings.d.ts +85 -70
  188. package/dist/types/plugins/thumbnail/lg-thumbnail.d.ts +88 -0
  189. package/{plugins → dist/types/plugins}/video/lg-video-settings.d.ts +94 -71
  190. package/{plugins → dist/types/plugins}/video/lg-video.d.ts +116 -104
  191. package/{plugins → dist/types/plugins}/video/types.d.ts +8 -8
  192. package/{plugins → dist/types/plugins}/vimeoThumbnail/lg-vimeo-thumbnail-settings.d.ts +11 -11
  193. package/{plugins → dist/types/plugins}/vimeoThumbnail/lg-vimeo-thumbnail.d.ts +14 -14
  194. package/{plugins → dist/types/plugins}/zoom/lg-zoom-settings.d.ts +54 -51
  195. package/{plugins → dist/types/plugins}/zoom/lg-zoom.d.ts +145 -108
  196. package/{types.d.ts → dist/types/types.d.ts} +40 -40
  197. package/package.json +237 -8
  198. package/angular/10/README.md +0 -24
  199. package/angular/10/bundles/lightgallery-angular-10.umd.js +0 -289
  200. package/angular/10/bundles/lightgallery-angular-10.umd.js.map +0 -1
  201. package/angular/10/bundles/lightgallery-angular-10.umd.min.js +0 -2
  202. package/angular/10/bundles/lightgallery-angular-10.umd.min.js.map +0 -1
  203. package/angular/10/esm2015/lib/lightgallery-angular.component.js +0 -225
  204. package/angular/10/esm2015/lib/lightgallery-angular.module.js +0 -17
  205. package/angular/10/esm2015/lib/lightgallery-angular.service.js +0 -14
  206. package/angular/10/esm2015/lightgallery-angular-10.js +0 -5
  207. package/angular/10/esm2015/public-api.js +0 -7
  208. package/angular/10/fesm2015/lightgallery-angular-10.js +0 -261
  209. package/angular/10/fesm2015/lightgallery-angular-10.js.map +0 -1
  210. package/angular/10/lib/lightgallery-angular.component.d.ts +0 -39
  211. package/angular/10/lib/lightgallery-angular.component.d.ts.map +0 -1
  212. package/angular/10/lib/lightgallery-angular.module.d.ts +0 -7
  213. package/angular/10/lib/lightgallery-angular.module.d.ts.map +0 -1
  214. package/angular/10/lib/lightgallery-angular.service.d.ts +0 -7
  215. package/angular/10/lib/lightgallery-angular.service.d.ts.map +0 -1
  216. package/angular/10/lightgallery-angular-10.d.ts +0 -6
  217. package/angular/10/lightgallery-angular-10.d.ts.map +0 -1
  218. package/angular/10/package.json +0 -21
  219. package/angular/10/public-api.d.ts +0 -4
  220. package/angular/10/public-api.d.ts.map +0 -1
  221. package/angular/11/README.md +0 -24
  222. package/angular/11/bundles/lightgallery-angular-11.umd.js +0 -290
  223. package/angular/11/bundles/lightgallery-angular-11.umd.js.map +0 -1
  224. package/angular/11/bundles/lightgallery-angular-11.umd.min.js +0 -2
  225. package/angular/11/bundles/lightgallery-angular-11.umd.min.js.map +0 -1
  226. package/angular/11/esm2015/lib/lightgallery-angular.component.js +0 -225
  227. package/angular/11/esm2015/lib/lightgallery-angular.module.js +0 -18
  228. package/angular/11/esm2015/lib/lightgallery-angular.service.js +0 -14
  229. package/angular/11/esm2015/lightgallery-angular-11.js +0 -5
  230. package/angular/11/esm2015/public-api.js +0 -7
  231. package/angular/11/fesm2015/lightgallery-angular-11.js +0 -262
  232. package/angular/11/fesm2015/lightgallery-angular-11.js.map +0 -1
  233. package/angular/11/lib/lightgallery-angular.component.d.ts +0 -39
  234. package/angular/11/lib/lightgallery-angular.component.d.ts.map +0 -1
  235. package/angular/11/lib/lightgallery-angular.module.d.ts +0 -8
  236. package/angular/11/lib/lightgallery-angular.module.d.ts.map +0 -1
  237. package/angular/11/lib/lightgallery-angular.service.d.ts +0 -7
  238. package/angular/11/lib/lightgallery-angular.service.d.ts.map +0 -1
  239. package/angular/11/lightgallery-angular-11.d.ts +0 -6
  240. package/angular/11/lightgallery-angular-11.d.ts.map +0 -1
  241. package/angular/11/package.json +0 -21
  242. package/angular/11/public-api.d.ts +0 -4
  243. package/angular/11/public-api.d.ts.map +0 -1
  244. package/angular/12/README.md +0 -24
  245. package/angular/12/bundles/lightgallery-angular-12.umd.js +0 -296
  246. package/angular/12/bundles/lightgallery-angular-12.umd.js.map +0 -1
  247. package/angular/12/esm2015/lib/lightgallery-angular.component.js +0 -221
  248. package/angular/12/esm2015/lib/lightgallery-angular.module.js +0 -17
  249. package/angular/12/esm2015/lib/lightgallery-angular.service.js +0 -14
  250. package/angular/12/esm2015/lightgallery-angular-12.js +0 -5
  251. package/angular/12/esm2015/public-api.js +0 -7
  252. package/angular/12/fesm2015/lightgallery-angular-12.js +0 -258
  253. package/angular/12/fesm2015/lightgallery-angular-12.js.map +0 -1
  254. package/angular/12/lib/lightgallery-angular.component.d.ts +0 -38
  255. package/angular/12/lib/lightgallery-angular.module.d.ts +0 -7
  256. package/angular/12/lib/lightgallery-angular.service.d.ts +0 -6
  257. package/angular/12/lightgallery-angular-12.d.ts +0 -5
  258. package/angular/12/package.json +0 -18
  259. package/angular/12/public-api.d.ts +0 -3
  260. package/angular/13/README.md +0 -24
  261. package/angular/13/esm2020/lib/lightgallery-angular.component.mjs +0 -221
  262. package/angular/13/esm2020/lib/lightgallery-angular.module.mjs +0 -17
  263. package/angular/13/esm2020/lib/lightgallery-angular.service.mjs +0 -14
  264. package/angular/13/esm2020/lightgallery-angular-13.mjs +0 -5
  265. package/angular/13/esm2020/public-api.mjs +0 -7
  266. package/angular/13/fesm2015/lightgallery-angular-13.mjs +0 -258
  267. package/angular/13/fesm2015/lightgallery-angular-13.mjs.map +0 -1
  268. package/angular/13/fesm2020/lightgallery-angular-13.mjs +0 -258
  269. package/angular/13/fesm2020/lightgallery-angular-13.mjs.map +0 -1
  270. package/angular/13/lib/lightgallery-angular.component.d.ts +0 -38
  271. package/angular/13/lib/lightgallery-angular.module.d.ts +0 -7
  272. package/angular/13/lib/lightgallery-angular.service.d.ts +0 -6
  273. package/angular/13/lightgallery-angular-13.d.ts +0 -5
  274. package/angular/13/package.json +0 -31
  275. package/angular/13/public-api.d.ts +0 -3
  276. package/angular/14/README.md +0 -24
  277. package/angular/14/esm2020/lib/lightgallery-angular.component.mjs +0 -217
  278. package/angular/14/esm2020/lib/lightgallery-angular.module.mjs +0 -17
  279. package/angular/14/esm2020/lib/lightgallery-angular.service.mjs +0 -14
  280. package/angular/14/esm2020/lightgallery-angular-14.mjs +0 -5
  281. package/angular/14/esm2020/public-api.mjs +0 -7
  282. package/angular/14/fesm2015/lightgallery-angular-14.mjs +0 -254
  283. package/angular/14/fesm2015/lightgallery-angular-14.mjs.map +0 -1
  284. package/angular/14/fesm2020/lightgallery-angular-14.mjs +0 -254
  285. package/angular/14/fesm2020/lightgallery-angular-14.mjs.map +0 -1
  286. package/angular/14/index.d.ts +0 -5
  287. package/angular/14/lib/lightgallery-angular.component.d.ts +0 -38
  288. package/angular/14/lib/lightgallery-angular.module.d.ts +0 -7
  289. package/angular/14/lib/lightgallery-angular.service.d.ts +0 -6
  290. package/angular/14/package.json +0 -31
  291. package/angular/14/public-api.d.ts +0 -3
  292. package/angular/15/README.md +0 -24
  293. package/angular/15/esm2022/lib/lightgallery-angular.component.mjs +0 -218
  294. package/angular/15/esm2022/lib/lightgallery-angular.module.mjs +0 -18
  295. package/angular/15/esm2022/lib/lightgallery-angular.service.mjs +0 -15
  296. package/angular/15/esm2022/lightgallery-angular-15.mjs +0 -5
  297. package/angular/15/esm2022/public-api.mjs +0 -7
  298. package/angular/15/fesm2022/lightgallery-angular-15.mjs +0 -254
  299. package/angular/15/fesm2022/lightgallery-angular-15.mjs.map +0 -1
  300. package/angular/15/index.d.ts +0 -5
  301. package/angular/15/lib/lightgallery-angular.component.d.ts +0 -38
  302. package/angular/15/lib/lightgallery-angular.module.d.ts +0 -7
  303. package/angular/15/lib/lightgallery-angular.service.d.ts +0 -6
  304. package/angular/15/package.json +0 -25
  305. package/angular/15/public-api.d.ts +0 -3
  306. package/angular/16/README.md +0 -24
  307. package/angular/16/esm2022/lib/lightgallery-angular.component.mjs +0 -218
  308. package/angular/16/esm2022/lib/lightgallery-angular.module.mjs +0 -18
  309. package/angular/16/esm2022/lib/lightgallery-angular.service.mjs +0 -15
  310. package/angular/16/esm2022/lightgallery-angular-16.mjs +0 -5
  311. package/angular/16/esm2022/public-api.mjs +0 -7
  312. package/angular/16/fesm2022/lightgallery-angular-16.mjs +0 -254
  313. package/angular/16/fesm2022/lightgallery-angular-16.mjs.map +0 -1
  314. package/angular/16/index.d.ts +0 -5
  315. package/angular/16/lib/lightgallery-angular.component.d.ts +0 -38
  316. package/angular/16/lib/lightgallery-angular.module.d.ts +0 -7
  317. package/angular/16/lib/lightgallery-angular.service.d.ts +0 -6
  318. package/angular/16/package.json +0 -25
  319. package/angular/16/public-api.d.ts +0 -3
  320. package/angular/9/README.md +0 -24
  321. package/angular/9/bundles/lightgallery-angular-9.umd.js +0 -271
  322. package/angular/9/bundles/lightgallery-angular-9.umd.js.map +0 -1
  323. package/angular/9/bundles/lightgallery-angular-9.umd.min.js +0 -2
  324. package/angular/9/bundles/lightgallery-angular-9.umd.min.js.map +0 -1
  325. package/angular/9/esm2015/lib/lightgallery-angular.component.js +0 -225
  326. package/angular/9/esm2015/lib/lightgallery-angular.module.js +0 -17
  327. package/angular/9/esm2015/lib/lightgallery-angular.service.js +0 -14
  328. package/angular/9/esm2015/lightgallery-angular-9.js +0 -5
  329. package/angular/9/esm2015/public-api.js +0 -7
  330. package/angular/9/esm5/lib/lightgallery-angular.component.js +0 -228
  331. package/angular/9/esm5/lib/lightgallery-angular.module.js +0 -21
  332. package/angular/9/esm5/lib/lightgallery-angular.service.js +0 -17
  333. package/angular/9/esm5/lightgallery-angular-9.js +0 -5
  334. package/angular/9/esm5/public-api.js +0 -7
  335. package/angular/9/fesm2015/lightgallery-angular-9.js +0 -261
  336. package/angular/9/fesm2015/lightgallery-angular-9.js.map +0 -1
  337. package/angular/9/fesm5/lightgallery-angular-9.js +0 -268
  338. package/angular/9/fesm5/lightgallery-angular-9.js.map +0 -1
  339. package/angular/9/lib/lightgallery-angular.component.d.ts +0 -38
  340. package/angular/9/lib/lightgallery-angular.module.d.ts +0 -6
  341. package/angular/9/lib/lightgallery-angular.service.d.ts +0 -6
  342. package/angular/9/lightgallery-angular-9.d.ts +0 -5
  343. package/angular/9/package.json +0 -23
  344. package/angular/9/public-api.d.ts +0 -3
  345. package/angular/README.md +0 -24
  346. package/angular/esm2022/lib/lightgallery-angular.component.mjs +0 -218
  347. package/angular/esm2022/lib/lightgallery-angular.module.mjs +0 -18
  348. package/angular/esm2022/lib/lightgallery-angular.service.mjs +0 -15
  349. package/angular/esm2022/lightgallery-angular.mjs +0 -5
  350. package/angular/esm2022/public-api.mjs +0 -7
  351. package/angular/fesm2022/lightgallery-angular.mjs +0 -254
  352. package/angular/fesm2022/lightgallery-angular.mjs.map +0 -1
  353. package/angular/index.d.ts +0 -5
  354. package/angular/lib/lightgallery-angular.component.d.ts +0 -38
  355. package/angular/lib/lightgallery-angular.module.d.ts +0 -7
  356. package/angular/lib/lightgallery-angular.service.d.ts +0 -6
  357. package/angular/package.json +0 -25
  358. package/angular/public-api.d.ts +0 -3
  359. package/css/lg-fullscreen.css +0 -8
  360. package/css/lg-fullscreen.css.map +0 -1
  361. package/css/lg-share.css.map +0 -1
  362. package/css/lg-thumbnail.css.map +0 -1
  363. package/css/lg-transitions.css.map +0 -1
  364. package/css/lg-zoom.css.map +0 -1
  365. package/css/lightgallery-bundle.css.map +0 -1
  366. package/css/lightgallery-bundle.min.css +0 -1
  367. package/css/lightgallery-core.css.map +0 -1
  368. package/css/lightgallery.css.map +0 -1
  369. package/fonts/lg.svg +0 -54
  370. package/fonts/lg.ttf +0 -0
  371. package/fonts/lg.woff +0 -0
  372. package/fonts/lg.woff2 +0 -0
  373. package/lib/index.js +0 -8
  374. package/lib/index.js.map +0 -1
  375. package/lib/lg-events.js +0 -37
  376. package/lib/lg-events.js.map +0 -1
  377. package/lib/lg-plugin.js +0 -13
  378. package/lib/lg-plugin.js.map +0 -1
  379. package/lib/lg-settings.js +0 -83
  380. package/lib/lg-settings.js.map +0 -1
  381. package/lib/lg-utils.js +0 -328
  382. package/lib/lg-utils.js.map +0 -1
  383. package/lib/lgQuery.js +0 -385
  384. package/lib/lgQuery.js.map +0 -1
  385. package/lib/lightgallery.js +0 -1949
  386. package/lib/lightgallery.js.map +0 -1
  387. package/lib/plugins/autoplay/lg-autoplay-settings.js +0 -16
  388. package/lib/plugins/autoplay/lg-autoplay-settings.js.map +0 -1
  389. package/lib/plugins/autoplay/lg-autoplay.js +0 -184
  390. package/lib/plugins/autoplay/lg-autoplay.js.map +0 -1
  391. package/lib/plugins/comment/lg-comment-settings.js +0 -17
  392. package/lib/plugins/comment/lg-comment-settings.js.map +0 -1
  393. package/lib/plugins/comment/lg-comment.js +0 -140
  394. package/lib/plugins/comment/lg-comment.js.map +0 -1
  395. package/lib/plugins/fullscreen/lg-fullscreen-settings.js +0 -10
  396. package/lib/plugins/fullscreen/lg-fullscreen-settings.js.map +0 -1
  397. package/lib/plugins/fullscreen/lg-fullscreen.js +0 -108
  398. package/lib/plugins/fullscreen/lg-fullscreen.js.map +0 -1
  399. package/lib/plugins/hash/lg-hash-settings.js +0 -9
  400. package/lib/plugins/hash/lg-hash-settings.js.map +0 -1
  401. package/lib/plugins/hash/lg-hash.js +0 -139
  402. package/lib/plugins/hash/lg-hash.js.map +0 -1
  403. package/lib/plugins/mediumZoom/lg-medium-zoom-settings.js +0 -9
  404. package/lib/plugins/mediumZoom/lg-medium-zoom-settings.js.map +0 -1
  405. package/lib/plugins/mediumZoom/lg-medium-zoom.js +0 -73
  406. package/lib/plugins/mediumZoom/lg-medium-zoom.js.map +0 -1
  407. package/lib/plugins/pager/lg-pager-settings.js +0 -7
  408. package/lib/plugins/pager/lg-pager-settings.js.map +0 -1
  409. package/lib/plugins/pager/lg-pager.js +0 -82
  410. package/lib/plugins/pager/lg-pager.js.map +0 -1
  411. package/lib/plugins/relativeCaption/lg-relative-caption-settings.js +0 -7
  412. package/lib/plugins/relativeCaption/lg-relative-caption-settings.js.map +0 -1
  413. package/lib/plugins/relativeCaption/lg-relative-caption.js +0 -97
  414. package/lib/plugins/relativeCaption/lg-relative-caption.js.map +0 -1
  415. package/lib/plugins/rotate/lg-rotate-settings.js +0 -18
  416. package/lib/plugins/rotate/lg-rotate-settings.js.map +0 -1
  417. package/lib/plugins/rotate/lg-rotate.js +0 -206
  418. package/lib/plugins/rotate/lg-rotate.js.map +0 -1
  419. package/lib/plugins/share/lg-fb-share-utils.js +0 -10
  420. package/lib/plugins/share/lg-fb-share-utils.js.map +0 -1
  421. package/lib/plugins/share/lg-pinterest-share-utils.js +0 -17
  422. package/lib/plugins/share/lg-pinterest-share-utils.js.map +0 -1
  423. package/lib/plugins/share/lg-share-settings.js +0 -15
  424. package/lib/plugins/share/lg-share-settings.js.map +0 -1
  425. package/lib/plugins/share/lg-share.js +0 -130
  426. package/lib/plugins/share/lg-share.js.map +0 -1
  427. package/lib/plugins/share/lg-twitter-share-utils.js +0 -11
  428. package/lib/plugins/share/lg-twitter-share-utils.js.map +0 -1
  429. package/lib/plugins/share/types.js +0 -3
  430. package/lib/plugins/share/types.js.map +0 -1
  431. package/lib/plugins/thumbnail/lg-thumbnail-settings.js +0 -23
  432. package/lib/plugins/thumbnail/lg-thumbnail-settings.js.map +0 -1
  433. package/lib/plugins/thumbnail/lg-thumbnail.js +0 -414
  434. package/lib/plugins/thumbnail/lg-thumbnail.js.map +0 -1
  435. package/lib/plugins/video/lg-video-settings.js +0 -15
  436. package/lib/plugins/video/lg-video-settings.js.map +0 -1
  437. package/lib/plugins/video/lg-video-utils.js +0 -84
  438. package/lib/plugins/video/lg-video-utils.js.map +0 -1
  439. package/lib/plugins/video/lg-video.js +0 -411
  440. package/lib/plugins/video/lg-video.js.map +0 -1
  441. package/lib/plugins/video/types.js +0 -3
  442. package/lib/plugins/video/types.js.map +0 -1
  443. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail-settings.js +0 -8
  444. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail-settings.js.map +0 -1
  445. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail.js +0 -122
  446. package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail.js.map +0 -1
  447. package/lib/plugins/zoom/lg-zoom-settings.js +0 -21
  448. package/lib/plugins/zoom/lg-zoom-settings.js.map +0 -1
  449. package/lib/plugins/zoom/lg-zoom.js +0 -909
  450. package/lib/plugins/zoom/lg-zoom.js.map +0 -1
  451. package/lib/types.js +0 -3
  452. package/lib/types.js.map +0 -1
  453. package/lightgallery-2.9.0.tgz +0 -0
  454. package/lightgallery.es5.js +0 -2786
  455. package/lightgallery.es5.js.map +0 -1
  456. package/lightgallery.min.js +0 -8
  457. package/lightgallery.umd.js +0 -2794
  458. package/lightgallery.umd.js.map +0 -1
  459. package/lit/custom-elements.json +0 -82
  460. package/lit/lightgallery.esm.js +0 -59
  461. package/lit/lightgallery.umd.js +0 -37
  462. package/lit/package.json +0 -8
  463. package/plugins/autoplay/lg-autoplay.es5.js +0 -250
  464. package/plugins/autoplay/lg-autoplay.es5.js.map +0 -1
  465. package/plugins/autoplay/lg-autoplay.min.js +0 -8
  466. package/plugins/autoplay/lg-autoplay.umd.js +0 -258
  467. package/plugins/autoplay/lg-autoplay.umd.js.map +0 -1
  468. package/plugins/autoplay/package.json +0 -7
  469. package/plugins/comment/lg-comment.es5.js +0 -205
  470. package/plugins/comment/lg-comment.es5.js.map +0 -1
  471. package/plugins/comment/lg-comment.min.js +0 -8
  472. package/plugins/comment/lg-comment.umd.js +0 -213
  473. package/plugins/comment/lg-comment.umd.js.map +0 -1
  474. package/plugins/comment/package.json +0 -7
  475. package/plugins/fullscreen/lg-fullscreen.es5.js +0 -135
  476. package/plugins/fullscreen/lg-fullscreen.es5.js.map +0 -1
  477. package/plugins/fullscreen/lg-fullscreen.min.js +0 -8
  478. package/plugins/fullscreen/lg-fullscreen.umd.js +0 -143
  479. package/plugins/fullscreen/lg-fullscreen.umd.js.map +0 -1
  480. package/plugins/fullscreen/package.json +0 -7
  481. package/plugins/hash/lg-hash-settings.d.ts +0 -16
  482. package/plugins/hash/lg-hash.es5.js +0 -198
  483. package/plugins/hash/lg-hash.es5.js.map +0 -1
  484. package/plugins/hash/lg-hash.min.js +0 -8
  485. package/plugins/hash/lg-hash.umd.js +0 -206
  486. package/plugins/hash/lg-hash.umd.js.map +0 -1
  487. package/plugins/hash/package.json +0 -7
  488. package/plugins/mediumZoom/lg-medium-zoom.es5.js +0 -132
  489. package/plugins/mediumZoom/lg-medium-zoom.es5.js.map +0 -1
  490. package/plugins/mediumZoom/lg-medium-zoom.min.js +0 -8
  491. package/plugins/mediumZoom/lg-medium-zoom.umd.js +0 -140
  492. package/plugins/mediumZoom/lg-medium-zoom.umd.js.map +0 -1
  493. package/plugins/mediumZoom/package.json +0 -7
  494. package/plugins/pager/lg-pager.es5.js +0 -139
  495. package/plugins/pager/lg-pager.es5.js.map +0 -1
  496. package/plugins/pager/lg-pager.min.js +0 -8
  497. package/plugins/pager/lg-pager.umd.js +0 -147
  498. package/plugins/pager/lg-pager.umd.js.map +0 -1
  499. package/plugins/pager/package.json +0 -7
  500. package/plugins/relativeCaption/lg-relative-caption.es5.js +0 -154
  501. package/plugins/relativeCaption/lg-relative-caption.es5.js.map +0 -1
  502. package/plugins/relativeCaption/lg-relative-caption.min.js +0 -8
  503. package/plugins/relativeCaption/lg-relative-caption.umd.js +0 -162
  504. package/plugins/relativeCaption/lg-relative-caption.umd.js.map +0 -1
  505. package/plugins/relativeCaption/package.json +0 -7
  506. package/plugins/rotate/lg-rotate.es5.js +0 -274
  507. package/plugins/rotate/lg-rotate.es5.js.map +0 -1
  508. package/plugins/rotate/lg-rotate.min.js +0 -8
  509. package/plugins/rotate/lg-rotate.umd.js +0 -282
  510. package/plugins/rotate/lg-rotate.umd.js.map +0 -1
  511. package/plugins/rotate/package.json +0 -7
  512. package/plugins/share/lg-share.d.ts +0 -15
  513. package/plugins/share/lg-share.es5.js +0 -219
  514. package/plugins/share/lg-share.es5.js.map +0 -1
  515. package/plugins/share/lg-share.min.js +0 -8
  516. package/plugins/share/lg-share.umd.js +0 -227
  517. package/plugins/share/lg-share.umd.js.map +0 -1
  518. package/plugins/share/lg-twitter-share-utils.d.ts +0 -2
  519. package/plugins/share/package.json +0 -7
  520. package/plugins/thumbnail/lg-thumbnail.d.ts +0 -48
  521. package/plugins/thumbnail/lg-thumbnail.es5.js +0 -487
  522. package/plugins/thumbnail/lg-thumbnail.es5.js.map +0 -1
  523. package/plugins/thumbnail/lg-thumbnail.min.js +0 -8
  524. package/plugins/thumbnail/lg-thumbnail.umd.js +0 -495
  525. package/plugins/thumbnail/lg-thumbnail.umd.js.map +0 -1
  526. package/plugins/thumbnail/package.json +0 -7
  527. package/plugins/video/lg-video-utils.d.ts +0 -10
  528. package/plugins/video/lg-video.es5.js +0 -545
  529. package/plugins/video/lg-video.es5.js.map +0 -1
  530. package/plugins/video/lg-video.min.js +0 -8
  531. package/plugins/video/lg-video.umd.js +0 -553
  532. package/plugins/video/lg-video.umd.js.map +0 -1
  533. package/plugins/video/package.json +0 -7
  534. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +0 -182
  535. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js.map +0 -1
  536. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +0 -8
  537. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +0 -190
  538. package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js.map +0 -1
  539. package/plugins/vimeoThumbnail/package.json +0 -7
  540. package/plugins/zoom/lg-zoom.es5.js +0 -980
  541. package/plugins/zoom/lg-zoom.es5.js.map +0 -1
  542. package/plugins/zoom/lg-zoom.min.js +0 -8
  543. package/plugins/zoom/lg-zoom.umd.js +0 -988
  544. package/plugins/zoom/lg-zoom.umd.js.map +0 -1
  545. package/plugins/zoom/package.json +0 -7
  546. package/react/Lightgallery.d.ts +0 -33
  547. package/react/Lightgallery.es5.js +0 -2988
  548. package/react/Lightgallery.es5.js.map +0 -1
  549. package/react/Lightgallery.umd.js +0 -2994
  550. package/react/Lightgallery.umd.js.map +0 -1
  551. package/react/package.json +0 -7
  552. package/scss/_lg-fonts.scss +0 -27
  553. package/scss/lg-fullscreen.scss +0 -9
  554. package/vue/LightGallery.vue.d.ts +0 -37
  555. package/vue/LightGalleryVue.common.js +0 -9343
  556. package/vue/LightGalleryVue.common.js.map +0 -1
  557. package/vue/LightGalleryVue.umd.js +0 -9353
  558. package/vue/LightGalleryVue.umd.js.map +0 -1
  559. package/vue/LightGalleryVue.umd.min.js +0 -8
  560. package/vue/LightGalleryVue.umd.min.js.map +0 -1
  561. package/vue/package.json +0 -7
  562. /package/{css → dist/css}/lg-medium-zoom.css +0 -0
  563. /package/{css → dist/css}/lg-medium-zoom.css.map +0 -0
  564. /package/{css → dist/css}/lg-pager.css +0 -0
  565. /package/{css → dist/css}/lg-relative-caption.css +0 -0
  566. /package/{css → dist/css}/lg-relative-caption.css.map +0 -0
  567. /package/{css → dist/css}/lg-video.css +0 -0
  568. /package/{css → dist/css}/lg-video.css.map +0 -0
  569. /package/{images → dist/images}/loading.gif +0 -0
  570. /package/{scss → dist/scss}/_lg-mixins.scss +0 -0
  571. /package/{scss → dist/scss}/lg-medium-zoom.scss +0 -0
  572. /package/{scss → dist/scss}/lg-pager.scss +0 -0
  573. /package/{scss → dist/scss}/lg-relative-caption.scss +0 -0
  574. /package/{scss → dist/scss}/lg-transitions.scss +0 -0
  575. /package/{scss → dist/scss}/lg-video.scss +0 -0
  576. /package/{scss → dist/scss}/transitions/_index.scss +0 -0
  577. /package/{scss → dist/scss}/transitions/_lg-lollipop-rev.scss +0 -0
  578. /package/{scss → dist/scss}/transitions/_lg-lollipop.scss +0 -0
  579. /package/{scss → dist/scss}/transitions/_lg-rotate-rev.scss +0 -0
  580. /package/{scss → dist/scss}/transitions/_lg-rotate.scss +0 -0
  581. /package/{scss → dist/scss}/transitions/_lg-slide-skew-cross-rev.scss +0 -0
  582. /package/{scss → dist/scss}/transitions/_lg-slide-skew-cross.scss +0 -0
  583. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-rev.scss +0 -0
  584. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-y-rev.scss +0 -0
  585. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-y.scss +0 -0
  586. /package/{scss → dist/scss}/transitions/_lg-slide-skew-only.scss +0 -0
  587. /package/{scss → dist/scss}/transitions/_lg-slide-skew-rev.scss +0 -0
  588. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-cross-rev.scss +0 -0
  589. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-cross.scss +0 -0
  590. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-rev.scss +0 -0
  591. /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver.scss +0 -0
  592. /package/{scss → dist/scss}/transitions/_lg-slide-skew.scss +0 -0
  593. /package/{scss → dist/scss}/transitions/_lg-slide-vertical-growth.scss +0 -0
  594. /package/{scss → dist/scss}/transitions/_lg-slide-vertical.scss +0 -0
  595. /package/{scss → dist/scss}/transitions/_lg-tube.scss +0 -0
@@ -1,1949 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.LightGallery = void 0;
15
- var lg_events_1 = require("./lg-events");
16
- var lg_settings_1 = require("./lg-settings");
17
- var lg_utils_1 = require("./lg-utils");
18
- var lgQuery_1 = require("./lgQuery");
19
- // @ref - https://stackoverflow.com/questions/3971841/how-to-resize-images-proportionally-keeping-the-aspect-ratio
20
- // @ref - https://2ality.com/2017/04/setting-up-multi-platform-packages.html
21
- // Unique id for each gallery
22
- var lgId = 0;
23
- var LightGallery = /** @class */ (function () {
24
- function LightGallery(element, options) {
25
- this.lgOpened = false;
26
- this.index = 0;
27
- // lightGallery modules
28
- this.plugins = [];
29
- // false when lightGallery load first slide content;
30
- this.lGalleryOn = false;
31
- // True when a slide animation is in progress
32
- this.lgBusy = false;
33
- this.currentItemsInDom = [];
34
- // Scroll top value before lightGallery is opened
35
- this.prevScrollTop = 0;
36
- this.bodyPaddingRight = 0;
37
- this.isDummyImageRemoved = false;
38
- this.dragOrSwipeEnabled = false;
39
- this.mediaContainerPosition = {
40
- top: 0,
41
- bottom: 0,
42
- };
43
- if (!element) {
44
- return this;
45
- }
46
- lgId++;
47
- this.lgId = lgId;
48
- this.el = element;
49
- this.LGel = lgQuery_1.$LG(element);
50
- this.generateSettings(options);
51
- this.buildModules();
52
- // When using dynamic mode, ensure dynamicEl is an array
53
- if (this.settings.dynamic &&
54
- this.settings.dynamicEl !== undefined &&
55
- !Array.isArray(this.settings.dynamicEl)) {
56
- throw 'When using dynamic mode, you must also define dynamicEl as an Array.';
57
- }
58
- this.galleryItems = this.getItems();
59
- this.normalizeSettings();
60
- // Gallery items
61
- this.init();
62
- this.validateLicense();
63
- return this;
64
- }
65
- LightGallery.prototype.generateSettings = function (options) {
66
- // lightGallery settings
67
- this.settings = __assign(__assign({}, lg_settings_1.lightGalleryCoreSettings), options);
68
- if (this.settings.isMobile &&
69
- typeof this.settings.isMobile === 'function'
70
- ? this.settings.isMobile()
71
- : lg_utils_1.default.isMobile()) {
72
- var mobileSettings = __assign(__assign({}, this.settings.mobileSettings), this.settings.mobileSettings);
73
- this.settings = __assign(__assign({}, this.settings), mobileSettings);
74
- }
75
- };
76
- LightGallery.prototype.normalizeSettings = function () {
77
- if (this.settings.slideEndAnimation) {
78
- this.settings.hideControlOnEnd = false;
79
- }
80
- if (!this.settings.closable) {
81
- this.settings.swipeToClose = false;
82
- }
83
- // And reset it on close to get the correct value next time
84
- this.zoomFromOrigin = this.settings.zoomFromOrigin;
85
- // At the moment, Zoom from image doesn't support dynamic options
86
- // @todo add zoomFromOrigin support for dynamic images
87
- if (this.settings.dynamic) {
88
- this.zoomFromOrigin = false;
89
- }
90
- if (this.settings.container) {
91
- var container = this.settings.container;
92
- if (typeof container === 'function') {
93
- this.settings.container = container();
94
- }
95
- else if (typeof container === 'string') {
96
- var el = document.querySelector(container);
97
- this.settings.container = el !== null && el !== void 0 ? el : document.body;
98
- }
99
- }
100
- else {
101
- this.settings.container = document.body;
102
- }
103
- // settings.preload should not be grater than $item.length
104
- this.settings.preload = Math.min(this.settings.preload, this.galleryItems.length);
105
- };
106
- LightGallery.prototype.init = function () {
107
- var _this = this;
108
- this.addSlideVideoInfo(this.galleryItems);
109
- this.buildStructure();
110
- this.LGel.trigger(lg_events_1.lGEvents.init, {
111
- instance: this,
112
- });
113
- if (this.settings.keyPress) {
114
- this.keyPress();
115
- }
116
- setTimeout(function () {
117
- _this.enableDrag();
118
- _this.enableSwipe();
119
- _this.triggerPosterClick();
120
- }, 50);
121
- this.arrow();
122
- if (this.settings.mousewheel) {
123
- this.mousewheel();
124
- }
125
- if (!this.settings.dynamic) {
126
- this.openGalleryOnItemClick();
127
- }
128
- };
129
- LightGallery.prototype.openGalleryOnItemClick = function () {
130
- var _this = this;
131
- var _loop_1 = function (index) {
132
- var element = this_1.items[index];
133
- var $element = lgQuery_1.$LG(element);
134
- // Using different namespace for click because click event should not unbind if selector is same object('this')
135
- // @todo manage all event listners - should have namespace that represent element
136
- var uuid = lgQuery_1.lgQuery.generateUUID();
137
- $element
138
- .attr('data-lg-id', uuid)
139
- .on("click.lgcustom-item-" + uuid, function (e) {
140
- e.preventDefault();
141
- var currentItemIndex = _this.settings.index || index;
142
- _this.openGallery(currentItemIndex, element);
143
- });
144
- };
145
- var this_1 = this;
146
- // Using for loop instead of using bubbling as the items can be any html element.
147
- for (var index = 0; index < this.items.length; index++) {
148
- _loop_1(index);
149
- }
150
- };
151
- /**
152
- * Module constructor
153
- * Modules are build incrementally.
154
- * Gallery should be opened only once all the modules are initialized.
155
- * use moduleBuildTimeout to make sure this
156
- */
157
- LightGallery.prototype.buildModules = function () {
158
- var _this = this;
159
- this.settings.plugins.forEach(function (plugin) {
160
- _this.plugins.push(new plugin(_this, lgQuery_1.$LG));
161
- });
162
- };
163
- LightGallery.prototype.validateLicense = function () {
164
- if (!this.settings.licenseKey) {
165
- console.error('Please provide a valid license key');
166
- }
167
- else if (this.settings.licenseKey === '0000-0000-000-0000') {
168
- console.warn("lightGallery: " + this.settings.licenseKey + " license key is not valid for production use");
169
- }
170
- };
171
- LightGallery.prototype.getSlideItem = function (index) {
172
- return lgQuery_1.$LG(this.getSlideItemId(index));
173
- };
174
- LightGallery.prototype.getSlideItemId = function (index) {
175
- return "#lg-item-" + this.lgId + "-" + index;
176
- };
177
- LightGallery.prototype.getIdName = function (id) {
178
- return id + "-" + this.lgId;
179
- };
180
- LightGallery.prototype.getElementById = function (id) {
181
- return lgQuery_1.$LG("#" + this.getIdName(id));
182
- };
183
- LightGallery.prototype.manageSingleSlideClassName = function () {
184
- if (this.galleryItems.length < 2) {
185
- this.outer.addClass('lg-single-item');
186
- }
187
- else {
188
- this.outer.removeClass('lg-single-item');
189
- }
190
- };
191
- LightGallery.prototype.buildStructure = function () {
192
- var _this = this;
193
- var container = this.$container && this.$container.get();
194
- if (container) {
195
- return;
196
- }
197
- var controls = '';
198
- var subHtmlCont = '';
199
- // Create controls
200
- if (this.settings.controls) {
201
- 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>";
202
- }
203
- if (this.settings.appendSubHtmlTo !== '.lg-item') {
204
- subHtmlCont =
205
- '<div class="lg-sub-html" role="status" aria-live="polite"></div>';
206
- }
207
- var addClasses = '';
208
- if (this.settings.allowMediaOverlap) {
209
- // Do not remove space before last single quote
210
- addClasses += 'lg-media-overlap ';
211
- }
212
- var ariaLabelledby = this.settings.ariaLabelledby
213
- ? 'aria-labelledby="' + this.settings.ariaLabelledby + '"'
214
- : '';
215
- var ariaDescribedby = this.settings.ariaDescribedby
216
- ? 'aria-describedby="' + this.settings.ariaDescribedby + '"'
217
- : '';
218
- var containerClassName = "lg-container " + this.settings.addClass + " " + (document.body !== this.settings.container ? 'lg-inline' : '');
219
- var closeIcon = this.settings.closable && this.settings.showCloseIcon
220
- ? "<button type=\"button\" aria-label=\"" + this.settings.strings['closeGallery'] + "\" id=\"" + this.getIdName('lg-close') + "\" class=\"lg-close lg-icon\"></button>"
221
- : '';
222
- var maximizeIcon = this.settings.showMaximizeIcon
223
- ? "<button type=\"button\" aria-label=\"" + this.settings.strings['toggleMaximize'] + "\" id=\"" + this.getIdName('lg-maximize') + "\" class=\"lg-maximize lg-icon\"></button>"
224
- : '';
225
- 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'
226
- ? subHtmlCont
227
- : '') + "\n <div id=\"" + this.getIdName('lg-components') + "\" class=\"lg-components\">\n " + (this.settings.appendSubHtmlTo === '.lg-sub-html'
228
- ? subHtmlCont
229
- : '') + "\n </div>\n </div>\n </div>\n ";
230
- lgQuery_1.$LG(this.settings.container).append(template);
231
- if (document.body !== this.settings.container) {
232
- lgQuery_1.$LG(this.settings.container).css('position', 'relative');
233
- }
234
- this.outer = this.getElementById('lg-outer');
235
- this.$lgComponents = this.getElementById('lg-components');
236
- this.$backdrop = this.getElementById('lg-backdrop');
237
- this.$container = this.getElementById('lg-container');
238
- this.$inner = this.getElementById('lg-inner');
239
- this.$content = this.getElementById('lg-content');
240
- this.$toolbar = this.getElementById('lg-toolbar');
241
- this.$backdrop.css('transition-duration', this.settings.backdropDuration + 'ms');
242
- var outerClassNames = this.settings.mode + " ";
243
- this.manageSingleSlideClassName();
244
- if (this.settings.enableDrag) {
245
- outerClassNames += 'lg-grab ';
246
- }
247
- this.outer.addClass(outerClassNames);
248
- this.$inner.css('transition-timing-function', this.settings.easing);
249
- this.$inner.css('transition-duration', this.settings.speed + 'ms');
250
- if (this.settings.download) {
251
- 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>");
252
- }
253
- this.counter();
254
- lgQuery_1.$LG(window).on("resize.lg.global" + this.lgId + " orientationchange.lg.global" + this.lgId, function () {
255
- _this.refreshOnResize();
256
- });
257
- this.hideBars();
258
- this.manageCloseGallery();
259
- this.toggleMaximize();
260
- this.initModules();
261
- };
262
- LightGallery.prototype.refreshOnResize = function () {
263
- if (this.lgOpened) {
264
- var currentGalleryItem = this.galleryItems[this.index];
265
- var __slideVideoInfo = currentGalleryItem.__slideVideoInfo;
266
- this.mediaContainerPosition = this.getMediaContainerPosition();
267
- var _a = this.mediaContainerPosition, top_1 = _a.top, bottom = _a.bottom;
268
- this.currentImageSize = lg_utils_1.default.getSize(this.items[this.index], this.outer, top_1 + bottom, __slideVideoInfo && this.settings.videoMaxSize);
269
- if (__slideVideoInfo) {
270
- this.resizeVideoSlide(this.index, this.currentImageSize);
271
- }
272
- if (this.zoomFromOrigin && !this.isDummyImageRemoved) {
273
- var imgStyle = this.getDummyImgStyles(this.currentImageSize);
274
- this.outer
275
- .find('.lg-current .lg-dummy-img')
276
- .first()
277
- .attr('style', imgStyle);
278
- }
279
- this.LGel.trigger(lg_events_1.lGEvents.containerResize);
280
- }
281
- };
282
- LightGallery.prototype.resizeVideoSlide = function (index, imageSize) {
283
- var lgVideoStyle = this.getVideoContStyle(imageSize);
284
- var currentSlide = this.getSlideItem(index);
285
- currentSlide.find('.lg-video-cont').attr('style', lgVideoStyle);
286
- };
287
- /**
288
- * Update slides dynamically.
289
- * Add, edit or delete slides dynamically when lightGallery is opened.
290
- * Modify the current gallery items and pass it via updateSlides method
291
- * @note
292
- * - Do not mutate existing lightGallery items directly.
293
- * - Always pass new list of gallery items
294
- * - You need to take care of thumbnails outside the gallery if any
295
- * - user this method only if you want to update slides when the gallery is opened. Otherwise, use `refresh()` method.
296
- * @param items Gallery items
297
- * @param index After the update operation, which slide gallery should navigate to
298
- * @category lGPublicMethods
299
- * @example
300
- * const plugin = lightGallery();
301
- *
302
- * // Adding slides dynamically
303
- * let galleryItems = [
304
- * // Access existing lightGallery items
305
- * // galleryItems are automatically generated internally from the gallery HTML markup
306
- * // or directly from galleryItems when dynamic gallery is used
307
- * ...plugin.galleryItems,
308
- * ...[
309
- * {
310
- * src: 'img/img-1.png',
311
- * thumb: 'img/thumb1.png',
312
- * },
313
- * ],
314
- * ];
315
- * plugin.updateSlides(
316
- * galleryItems,
317
- * plugin.index,
318
- * );
319
- *
320
- *
321
- * // Remove slides dynamically
322
- * galleryItems = JSON.parse(
323
- * JSON.stringify(updateSlideInstance.galleryItems),
324
- * );
325
- * galleryItems.shift();
326
- * updateSlideInstance.updateSlides(galleryItems, 1);
327
- * @see <a href="/demos/update-slides/">Demo</a>
328
- */
329
- LightGallery.prototype.updateSlides = function (items, index) {
330
- if (this.index > items.length - 1) {
331
- this.index = items.length - 1;
332
- }
333
- if (items.length === 1) {
334
- this.index = 0;
335
- }
336
- if (!items.length) {
337
- this.closeGallery();
338
- return;
339
- }
340
- var currentSrc = this.galleryItems[index].src;
341
- this.galleryItems = items;
342
- this.updateControls();
343
- this.$inner.empty();
344
- this.currentItemsInDom = [];
345
- var _index = 0;
346
- // Find the current index based on source value of the slide
347
- this.galleryItems.some(function (galleryItem, itemIndex) {
348
- if (galleryItem.src === currentSrc) {
349
- _index = itemIndex;
350
- return true;
351
- }
352
- return false;
353
- });
354
- this.currentItemsInDom = this.organizeSlideItems(_index, -1);
355
- this.loadContent(_index, true);
356
- this.getSlideItem(_index).addClass('lg-current');
357
- this.index = _index;
358
- this.updateCurrentCounter(_index);
359
- this.LGel.trigger(lg_events_1.lGEvents.updateSlides);
360
- };
361
- // Get gallery items based on multiple conditions
362
- LightGallery.prototype.getItems = function () {
363
- // Gallery items
364
- this.items = [];
365
- if (!this.settings.dynamic) {
366
- if (this.settings.selector === 'this') {
367
- this.items.push(this.el);
368
- }
369
- else if (this.settings.selector) {
370
- if (typeof this.settings.selector === 'string') {
371
- if (this.settings.selectWithin) {
372
- var selectWithin = lgQuery_1.$LG(this.settings.selectWithin);
373
- this.items = selectWithin
374
- .find(this.settings.selector)
375
- .get();
376
- }
377
- else {
378
- this.items = this.el.querySelectorAll(this.settings.selector);
379
- }
380
- }
381
- else {
382
- this.items = this.settings.selector;
383
- }
384
- }
385
- else {
386
- this.items = this.el.children;
387
- }
388
- return lg_utils_1.default.getDynamicOptions(this.items, this.settings.extraProps, this.settings.getCaptionFromTitleOrAlt, this.settings.exThumbImage);
389
- }
390
- else {
391
- return this.settings.dynamicEl || [];
392
- }
393
- };
394
- LightGallery.prototype.shouldHideScrollbar = function () {
395
- return (this.settings.hideScrollbar &&
396
- document.body === this.settings.container);
397
- };
398
- LightGallery.prototype.hideScrollbar = function () {
399
- if (!this.shouldHideScrollbar()) {
400
- return;
401
- }
402
- this.bodyPaddingRight = parseFloat(lgQuery_1.$LG('body').style().paddingRight);
403
- var bodyRect = document.documentElement.getBoundingClientRect();
404
- var scrollbarWidth = window.innerWidth - bodyRect.width;
405
- lgQuery_1.$LG(document.body).css('padding-right', scrollbarWidth + this.bodyPaddingRight + 'px');
406
- lgQuery_1.$LG(document.body).addClass('lg-overlay-open');
407
- };
408
- LightGallery.prototype.resetScrollBar = function () {
409
- if (!this.shouldHideScrollbar()) {
410
- return;
411
- }
412
- lgQuery_1.$LG(document.body).css('padding-right', this.bodyPaddingRight + 'px');
413
- lgQuery_1.$LG(document.body).removeClass('lg-overlay-open');
414
- };
415
- /**
416
- * Open lightGallery.
417
- * Open gallery with specific slide by passing index of the slide as parameter.
418
- * @category lGPublicMethods
419
- * @param {Number} index - index of the slide
420
- * @param {HTMLElement} element - Which image lightGallery should zoom from
421
- *
422
- * @example
423
- * const $dynamicGallery = document.getElementById('dynamic-gallery-demo');
424
- * const dynamicGallery = lightGallery($dynamicGallery, {
425
- * dynamic: true,
426
- * dynamicEl: [
427
- * {
428
- * src: 'img/1.jpg',
429
- * thumb: 'img/thumb-1.jpg',
430
- * subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>',
431
- * },
432
- * ...
433
- * ],
434
- * });
435
- * $dynamicGallery.addEventListener('click', function () {
436
- * // Starts with third item.(Optional).
437
- * // This is useful if you want use dynamic mode with
438
- * // custom thumbnails (thumbnails outside gallery),
439
- * dynamicGallery.openGallery(2);
440
- * });
441
- *
442
- */
443
- LightGallery.prototype.openGallery = function (index, element) {
444
- var _this = this;
445
- if (index === void 0) { index = this.settings.index; }
446
- // prevent accidental double execution
447
- if (this.lgOpened)
448
- return;
449
- this.lgOpened = true;
450
- this.outer.removeClass('lg-hide-items');
451
- this.hideScrollbar();
452
- // Add display block, but still has opacity 0
453
- this.$container.addClass('lg-show');
454
- var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, index);
455
- this.currentItemsInDom = itemsToBeInsertedToDom;
456
- var items = '';
457
- itemsToBeInsertedToDom.forEach(function (item) {
458
- items = items + ("<div id=\"" + item + "\" class=\"lg-item\"></div>");
459
- });
460
- this.$inner.append(items);
461
- this.addHtml(index);
462
- var transform = '';
463
- this.mediaContainerPosition = this.getMediaContainerPosition();
464
- var _a = this.mediaContainerPosition, top = _a.top, bottom = _a.bottom;
465
- if (!this.settings.allowMediaOverlap) {
466
- this.setMediaContainerPosition(top, bottom);
467
- }
468
- var __slideVideoInfo = this.galleryItems[index].__slideVideoInfo;
469
- if (this.zoomFromOrigin && element) {
470
- this.currentImageSize = lg_utils_1.default.getSize(element, this.outer, top + bottom, __slideVideoInfo && this.settings.videoMaxSize);
471
- transform = lg_utils_1.default.getTransform(element, this.outer, top, bottom, this.currentImageSize);
472
- }
473
- if (!this.zoomFromOrigin || !transform) {
474
- this.outer.addClass(this.settings.startClass);
475
- this.getSlideItem(index).removeClass('lg-complete');
476
- }
477
- var timeout = this.settings.zoomFromOrigin
478
- ? 100
479
- : this.settings.backdropDuration;
480
- setTimeout(function () {
481
- _this.outer.addClass('lg-components-open');
482
- }, timeout);
483
- this.index = index;
484
- this.LGel.trigger(lg_events_1.lGEvents.beforeOpen);
485
- // add class lg-current to remove initial transition
486
- this.getSlideItem(index).addClass('lg-current');
487
- this.lGalleryOn = false;
488
- // Store the current scroll top value to scroll back after closing the gallery..
489
- this.prevScrollTop = lgQuery_1.$LG(window).scrollTop();
490
- setTimeout(function () {
491
- // Need to check both zoomFromOrigin and transform values as we need to set set the
492
- // default opening animation if user missed to add the lg-size attribute
493
- if (_this.zoomFromOrigin && transform) {
494
- var currentSlide_1 = _this.getSlideItem(index);
495
- currentSlide_1.css('transform', transform);
496
- setTimeout(function () {
497
- currentSlide_1
498
- .addClass('lg-start-progress lg-start-end-progress')
499
- .css('transition-duration', _this.settings.startAnimationDuration + 'ms');
500
- _this.outer.addClass('lg-zoom-from-image');
501
- });
502
- setTimeout(function () {
503
- currentSlide_1.css('transform', 'translate3d(0, 0, 0)');
504
- }, 100);
505
- }
506
- setTimeout(function () {
507
- _this.$backdrop.addClass('in');
508
- _this.$container.addClass('lg-show-in');
509
- }, 10);
510
- setTimeout(function () {
511
- if (_this.settings.trapFocus &&
512
- document.body === _this.settings.container) {
513
- _this.trapFocus();
514
- }
515
- }, _this.settings.backdropDuration + 50);
516
- // lg-visible class resets gallery opacity to 1
517
- if (!_this.zoomFromOrigin || !transform) {
518
- setTimeout(function () {
519
- _this.outer.addClass('lg-visible');
520
- }, _this.settings.backdropDuration);
521
- }
522
- // initiate slide function
523
- _this.slide(index, false, false, false);
524
- _this.LGel.trigger(lg_events_1.lGEvents.afterOpen);
525
- });
526
- if (document.body === this.settings.container) {
527
- lgQuery_1.$LG('html').addClass('lg-on');
528
- }
529
- };
530
- /**
531
- * Note - Changing the position of the media on every slide transition creates a flickering effect.
532
- * Therefore, The height of the caption is calculated dynamically, only once based on the first slide caption.
533
- * if you have dynamic captions for each media,
534
- * you can provide an appropriate height for the captions via allowMediaOverlap option
535
- */
536
- LightGallery.prototype.getMediaContainerPosition = function () {
537
- if (this.settings.allowMediaOverlap) {
538
- return {
539
- top: 0,
540
- bottom: 0,
541
- };
542
- }
543
- var top = this.$toolbar.get().clientHeight || 0;
544
- var subHtml = this.outer.find('.lg-components .lg-sub-html').get();
545
- var captionHeight = this.settings.defaultCaptionHeight ||
546
- (subHtml && subHtml.clientHeight) ||
547
- 0;
548
- var thumbContainer = this.outer.find('.lg-thumb-outer').get();
549
- var thumbHeight = thumbContainer ? thumbContainer.clientHeight : 0;
550
- var bottom = thumbHeight + captionHeight;
551
- return {
552
- top: top,
553
- bottom: bottom,
554
- };
555
- };
556
- LightGallery.prototype.setMediaContainerPosition = function (top, bottom) {
557
- if (top === void 0) { top = 0; }
558
- if (bottom === void 0) { bottom = 0; }
559
- this.$content.css('top', top + 'px').css('bottom', bottom + 'px');
560
- };
561
- LightGallery.prototype.hideBars = function () {
562
- var _this = this;
563
- // Hide controllers if mouse doesn't move for some period
564
- setTimeout(function () {
565
- _this.outer.removeClass('lg-hide-items');
566
- if (_this.settings.hideBarsDelay > 0) {
567
- _this.outer.on('mousemove.lg click.lg touchstart.lg', function () {
568
- _this.outer.removeClass('lg-hide-items');
569
- clearTimeout(_this.hideBarTimeout);
570
- // Timeout will be cleared on each slide movement also
571
- _this.hideBarTimeout = setTimeout(function () {
572
- _this.outer.addClass('lg-hide-items');
573
- }, _this.settings.hideBarsDelay);
574
- });
575
- _this.outer.trigger('mousemove.lg');
576
- }
577
- }, this.settings.showBarsAfter);
578
- };
579
- LightGallery.prototype.initPictureFill = function ($img) {
580
- if (this.settings.supportLegacyBrowser) {
581
- try {
582
- picturefill({
583
- elements: [$img.get()],
584
- });
585
- }
586
- catch (e) {
587
- console.warn('lightGallery :- If you want srcset or picture tag to be supported for older browser please include picturefil javascript library in your document.');
588
- }
589
- }
590
- };
591
- /**
592
- * @desc Create image counter
593
- * Ex: 1/10
594
- */
595
- LightGallery.prototype.counter = function () {
596
- if (this.settings.counter) {
597
- 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>";
598
- this.outer.find(this.settings.appendCounterTo).append(counterHtml);
599
- }
600
- };
601
- /**
602
- * @desc add sub-html into the slide
603
- * @param {Number} index - index of the slide
604
- */
605
- LightGallery.prototype.addHtml = function (index) {
606
- var subHtml;
607
- var subHtmlUrl;
608
- if (this.galleryItems[index].subHtmlUrl) {
609
- subHtmlUrl = this.galleryItems[index].subHtmlUrl;
610
- }
611
- else {
612
- subHtml = this.galleryItems[index].subHtml;
613
- }
614
- if (!subHtmlUrl) {
615
- if (subHtml) {
616
- // get first letter of sub-html
617
- // if first letter starts with . or # get the html form the jQuery object
618
- var fL = subHtml.substring(0, 1);
619
- if (fL === '.' || fL === '#') {
620
- try {
621
- if (this.settings.subHtmlSelectorRelative &&
622
- !this.settings.dynamic) {
623
- subHtml = lgQuery_1.$LG(this.items)
624
- .eq(index)
625
- .find(subHtml)
626
- .first()
627
- .html();
628
- }
629
- else {
630
- subHtml = lgQuery_1.$LG(subHtml).first().html();
631
- }
632
- }
633
- catch (error) {
634
- console.warn("Error processing subHtml selector \"" + subHtml + "\"");
635
- subHtml = '';
636
- }
637
- }
638
- }
639
- else {
640
- subHtml = '';
641
- }
642
- }
643
- if (this.settings.appendSubHtmlTo !== '.lg-item') {
644
- if (subHtmlUrl) {
645
- lg_utils_1.default.fetchCaptionFromUrl(subHtmlUrl, this.outer.find('.lg-sub-html'), 'replace');
646
- }
647
- else {
648
- this.outer.find('.lg-sub-html').html(subHtml);
649
- }
650
- }
651
- else {
652
- var currentSlide = lgQuery_1.$LG(this.getSlideItemId(index));
653
- if (subHtmlUrl) {
654
- lg_utils_1.default.fetchCaptionFromUrl(subHtmlUrl, currentSlide, 'append');
655
- }
656
- else {
657
- currentSlide.append("<div class=\"lg-sub-html\">" + subHtml + "</div>");
658
- }
659
- }
660
- // Add lg-empty-html class if title doesn't exist
661
- if (typeof subHtml !== 'undefined' && subHtml !== null) {
662
- if (subHtml === '') {
663
- this.outer
664
- .find(this.settings.appendSubHtmlTo)
665
- .addClass('lg-empty-html');
666
- }
667
- else {
668
- this.outer
669
- .find(this.settings.appendSubHtmlTo)
670
- .removeClass('lg-empty-html');
671
- }
672
- }
673
- this.LGel.trigger(lg_events_1.lGEvents.afterAppendSubHtml, {
674
- index: index,
675
- });
676
- };
677
- /**
678
- * @desc Preload slides
679
- * @param {Number} index - index of the slide
680
- * @todo preload not working for the first slide, Also, should work for the first and last slide as well
681
- */
682
- LightGallery.prototype.preload = function (index) {
683
- for (var i = 1; i <= this.settings.preload; i++) {
684
- if (i >= this.galleryItems.length - index) {
685
- break;
686
- }
687
- this.loadContent(index + i, false);
688
- }
689
- for (var j = 1; j <= this.settings.preload; j++) {
690
- if (index - j < 0) {
691
- break;
692
- }
693
- this.loadContent(index - j, false);
694
- }
695
- };
696
- LightGallery.prototype.getDummyImgStyles = function (imageSize) {
697
- if (!imageSize)
698
- return '';
699
- return "width:" + imageSize.width + "px;\n margin-left: -" + imageSize.width / 2 + "px;\n margin-top: -" + imageSize.height / 2 + "px;\n height:" + imageSize.height + "px";
700
- };
701
- LightGallery.prototype.getVideoContStyle = function (imageSize) {
702
- if (!imageSize)
703
- return '';
704
- return "width:" + imageSize.width + "px;\n height:" + imageSize.height + "px";
705
- };
706
- LightGallery.prototype.getDummyImageContent = function ($currentSlide, index, alt) {
707
- var $currentItem;
708
- if (!this.settings.dynamic) {
709
- $currentItem = lgQuery_1.$LG(this.items).eq(index);
710
- }
711
- if ($currentItem) {
712
- var _dummyImgSrc = void 0;
713
- if (!this.settings.exThumbImage) {
714
- _dummyImgSrc = $currentItem.find('img').first().attr('src');
715
- }
716
- else {
717
- _dummyImgSrc = $currentItem.attr(this.settings.exThumbImage);
718
- }
719
- if (!_dummyImgSrc)
720
- return '';
721
- var imgStyle = this.getDummyImgStyles(this.currentImageSize);
722
- var dummyImgContentImg = document.createElement('img');
723
- dummyImgContentImg.alt = alt || '';
724
- dummyImgContentImg.src = _dummyImgSrc;
725
- dummyImgContentImg.className = "lg-dummy-img";
726
- dummyImgContentImg.style.cssText = imgStyle;
727
- $currentSlide.addClass('lg-first-slide');
728
- this.outer.addClass('lg-first-slide-loading');
729
- return dummyImgContentImg;
730
- }
731
- return '';
732
- };
733
- LightGallery.prototype.setImgMarkup = function (src, $currentSlide, index) {
734
- var currentGalleryItem = this.galleryItems[index];
735
- var alt = currentGalleryItem.alt, srcset = currentGalleryItem.srcset, sizes = currentGalleryItem.sizes, sources = currentGalleryItem.sources;
736
- // Use the thumbnail as dummy image which will be resized to actual image size and
737
- // displayed on top of actual image
738
- var imgContent = '';
739
- var altAttr = alt ? 'alt="' + alt + '"' : '';
740
- if (this.isFirstSlideWithZoomAnimation()) {
741
- imgContent = this.getDummyImageContent($currentSlide, index, altAttr);
742
- }
743
- else {
744
- imgContent = lg_utils_1.default.getImgMarkup(index, src, altAttr, srcset, sizes, sources);
745
- }
746
- var picture = document.createElement('picture');
747
- picture.className = 'lg-img-wrap';
748
- lgQuery_1.$LG(picture).append(imgContent);
749
- $currentSlide.prepend(picture);
750
- };
751
- LightGallery.prototype.onSlideObjectLoad = function ($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
752
- var mediaObject = $slide.find('.lg-object').first();
753
- if (lg_utils_1.default.isImageLoaded(mediaObject.get()) ||
754
- isHTML5VideoWithoutPoster) {
755
- onLoad();
756
- }
757
- else {
758
- mediaObject.on('load.lg error.lg', function () {
759
- onLoad && onLoad();
760
- });
761
- mediaObject.on('error.lg', function () {
762
- onError && onError();
763
- });
764
- }
765
- };
766
- /**
767
- *
768
- * @param $el Current slide item
769
- * @param index
770
- * @param delay Delay is 0 except first time
771
- * @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
772
- * @param isFirstSlide
773
- */
774
- LightGallery.prototype.onLgObjectLoad = function (currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
775
- var _this = this;
776
- this.onSlideObjectLoad(currentSlide, isHTML5VideoWithoutPoster, function () {
777
- _this.triggerSlideItemLoad(currentSlide, index, delay, speed, isFirstSlide);
778
- }, function () {
779
- currentSlide.addClass('lg-complete lg-complete_');
780
- currentSlide.html('<span class="lg-error-msg">' +
781
- _this.settings.strings['mediaLoadingFailed'] +
782
- '</span>');
783
- });
784
- };
785
- LightGallery.prototype.triggerSlideItemLoad = function ($currentSlide, index, delay, speed, isFirstSlide) {
786
- var _this = this;
787
- var currentGalleryItem = this.galleryItems[index];
788
- // Adding delay for video slides without poster for better performance and user experience
789
- // Videos should start playing once once the gallery is completely loaded
790
- var _speed = isFirstSlide &&
791
- this.getSlideType(currentGalleryItem) === 'video' &&
792
- !currentGalleryItem.poster
793
- ? speed
794
- : 0;
795
- setTimeout(function () {
796
- $currentSlide.addClass('lg-complete lg-complete_');
797
- _this.LGel.trigger(lg_events_1.lGEvents.slideItemLoad, {
798
- index: index,
799
- delay: delay || 0,
800
- isFirstSlide: isFirstSlide,
801
- });
802
- }, _speed);
803
- };
804
- LightGallery.prototype.isFirstSlideWithZoomAnimation = function () {
805
- return !!(!this.lGalleryOn &&
806
- this.zoomFromOrigin &&
807
- this.currentImageSize);
808
- };
809
- // Add video slideInfo
810
- LightGallery.prototype.addSlideVideoInfo = function (items) {
811
- var _this = this;
812
- items.forEach(function (element, index) {
813
- element.__slideVideoInfo = lg_utils_1.default.isVideo(element.src, !!element.video, index);
814
- if (element.__slideVideoInfo &&
815
- _this.settings.loadYouTubePoster &&
816
- !element.poster &&
817
- element.__slideVideoInfo.youtube) {
818
- element.poster = "//img.youtube.com/vi/" + element.__slideVideoInfo.youtube[1] + "/maxresdefault.jpg";
819
- }
820
- });
821
- };
822
- /**
823
- * Load slide content into slide.
824
- * This is used to load content into slides that is not visible too
825
- * @param {Number} index - index of the slide.
826
- * @param {Boolean} rec - if true call loadcontent() function again.
827
- */
828
- LightGallery.prototype.loadContent = function (index, rec) {
829
- var _this = this;
830
- var currentGalleryItem = this.galleryItems[index];
831
- var $currentSlide = lgQuery_1.$LG(this.getSlideItemId(index));
832
- var poster = currentGalleryItem.poster, srcset = currentGalleryItem.srcset, sizes = currentGalleryItem.sizes, sources = currentGalleryItem.sources;
833
- var src = currentGalleryItem.src;
834
- var video = currentGalleryItem.video;
835
- var _html5Video = video && typeof video === 'string' ? JSON.parse(video) : video;
836
- if (currentGalleryItem.responsive) {
837
- var srcDyItms = currentGalleryItem.responsive.split(',');
838
- src = lg_utils_1.default.getResponsiveSrc(srcDyItms) || src;
839
- }
840
- var videoInfo = currentGalleryItem.__slideVideoInfo;
841
- var lgVideoStyle = '';
842
- var iframe = !!currentGalleryItem.iframe;
843
- var isFirstSlide = !this.lGalleryOn;
844
- // delay for adding complete class. it is 0 except first time.
845
- var delay = 0;
846
- if (isFirstSlide) {
847
- if (this.zoomFromOrigin && this.currentImageSize) {
848
- delay = this.settings.startAnimationDuration + 10;
849
- }
850
- else {
851
- delay = this.settings.backdropDuration + 10;
852
- }
853
- }
854
- if (!$currentSlide.hasClass('lg-loaded')) {
855
- if (videoInfo) {
856
- var _a = this.mediaContainerPosition, top_2 = _a.top, bottom = _a.bottom;
857
- var videoSize = lg_utils_1.default.getSize(this.items[index], this.outer, top_2 + bottom, videoInfo && this.settings.videoMaxSize);
858
- lgVideoStyle = this.getVideoContStyle(videoSize);
859
- }
860
- if (iframe) {
861
- var markup = lg_utils_1.default.getIframeMarkup(this.settings.iframeWidth, this.settings.iframeHeight, this.settings.iframeMaxWidth, this.settings.iframeMaxHeight, src, currentGalleryItem.iframeTitle);
862
- $currentSlide.prepend(markup);
863
- }
864
- else if (poster) {
865
- var dummyImg = '';
866
- var hasStartAnimation = isFirstSlide &&
867
- this.zoomFromOrigin &&
868
- this.currentImageSize;
869
- if (hasStartAnimation) {
870
- dummyImg = this.getDummyImageContent($currentSlide, index, '');
871
- }
872
- var markup = lg_utils_1.default.getVideoPosterMarkup(poster, dummyImg || '', lgVideoStyle, this.settings.strings['playVideo'], videoInfo);
873
- $currentSlide.prepend(markup);
874
- }
875
- else if (videoInfo) {
876
- var markup = "<div class=\"lg-video-cont \" style=\"" + lgVideoStyle + "\"></div>";
877
- $currentSlide.prepend(markup);
878
- }
879
- else {
880
- this.setImgMarkup(src, $currentSlide, index);
881
- if (srcset || sources) {
882
- var $img = $currentSlide.find('.lg-object');
883
- this.initPictureFill($img);
884
- }
885
- }
886
- if (poster || videoInfo) {
887
- this.LGel.trigger(lg_events_1.lGEvents.hasVideo, {
888
- index: index,
889
- src: src,
890
- html5Video: _html5Video,
891
- hasPoster: !!poster,
892
- });
893
- }
894
- this.LGel.trigger(lg_events_1.lGEvents.afterAppendSlide, { index: index });
895
- if (this.lGalleryOn &&
896
- this.settings.appendSubHtmlTo === '.lg-item') {
897
- this.addHtml(index);
898
- }
899
- }
900
- // For first time add some delay for displaying the start animation.
901
- var _speed = 0;
902
- // Do not change the delay value because it is required for zoom plugin.
903
- // If gallery opened from direct url (hash) speed value should be 0
904
- if (delay && !lgQuery_1.$LG(document.body).hasClass('lg-from-hash')) {
905
- _speed = delay;
906
- }
907
- // Only for first slide and zoomFromOrigin is enabled
908
- if (this.isFirstSlideWithZoomAnimation()) {
909
- setTimeout(function () {
910
- $currentSlide
911
- .removeClass('lg-start-end-progress lg-start-progress')
912
- .removeAttr('style');
913
- }, this.settings.startAnimationDuration + 100);
914
- if (!$currentSlide.hasClass('lg-loaded')) {
915
- setTimeout(function () {
916
- if (_this.getSlideType(currentGalleryItem) === 'image') {
917
- var alt = currentGalleryItem.alt;
918
- var altAttr = alt ? 'alt="' + alt + '"' : '';
919
- $currentSlide
920
- .find('.lg-img-wrap')
921
- .append(lg_utils_1.default.getImgMarkup(index, src, altAttr, srcset, sizes, currentGalleryItem.sources));
922
- if (srcset || sources) {
923
- var $img = $currentSlide.find('.lg-object');
924
- _this.initPictureFill($img);
925
- }
926
- }
927
- if (_this.getSlideType(currentGalleryItem) === 'image' ||
928
- (_this.getSlideType(currentGalleryItem) === 'video' &&
929
- poster)) {
930
- _this.onLgObjectLoad($currentSlide, index, delay, _speed, true, false);
931
- // load remaining slides once the slide is completely loaded
932
- _this.onSlideObjectLoad($currentSlide, !!(videoInfo && videoInfo.html5 && !poster), function () {
933
- _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
934
- }, function () {
935
- _this.loadContentOnFirstSlideLoad(index, $currentSlide, _speed);
936
- });
937
- }
938
- }, this.settings.startAnimationDuration + 100);
939
- }
940
- }
941
- // SLide content has been added to dom
942
- $currentSlide.addClass('lg-loaded');
943
- if (!this.isFirstSlideWithZoomAnimation() ||
944
- (this.getSlideType(currentGalleryItem) === 'video' && !poster)) {
945
- this.onLgObjectLoad($currentSlide, index, delay, _speed, isFirstSlide, !!(videoInfo && videoInfo.html5 && !poster));
946
- }
947
- // When gallery is opened once content is loaded (second time) need to add lg-complete class for css styling
948
- if ((!this.zoomFromOrigin || !this.currentImageSize) &&
949
- $currentSlide.hasClass('lg-complete_') &&
950
- !this.lGalleryOn) {
951
- setTimeout(function () {
952
- $currentSlide.addClass('lg-complete');
953
- }, this.settings.backdropDuration);
954
- }
955
- // Content loaded
956
- // Need to set lGalleryOn before calling preload function
957
- this.lGalleryOn = true;
958
- if (rec === true) {
959
- if (!$currentSlide.hasClass('lg-complete_')) {
960
- $currentSlide
961
- .find('.lg-object')
962
- .first()
963
- .on('load.lg error.lg', function () {
964
- _this.preload(index);
965
- });
966
- }
967
- else {
968
- this.preload(index);
969
- }
970
- }
971
- };
972
- /**
973
- * @desc Remove dummy image content and load next slides
974
- * Called only for the first time if zoomFromOrigin animation is enabled
975
- * @param index
976
- * @param $currentSlide
977
- * @param speed
978
- */
979
- LightGallery.prototype.loadContentOnFirstSlideLoad = function (index, $currentSlide, speed) {
980
- var _this = this;
981
- setTimeout(function () {
982
- $currentSlide.find('.lg-dummy-img').remove();
983
- $currentSlide.removeClass('lg-first-slide');
984
- _this.outer.removeClass('lg-first-slide-loading');
985
- _this.isDummyImageRemoved = true;
986
- _this.preload(index);
987
- }, speed + 300);
988
- };
989
- LightGallery.prototype.getItemsToBeInsertedToDom = function (index, prevIndex, numberOfItems) {
990
- var _this = this;
991
- if (numberOfItems === void 0) { numberOfItems = 0; }
992
- var itemsToBeInsertedToDom = [];
993
- // Minimum 2 items should be there
994
- var possibleNumberOfItems = Math.max(numberOfItems, 3);
995
- possibleNumberOfItems = Math.min(possibleNumberOfItems, this.galleryItems.length);
996
- var prevIndexItem = "lg-item-" + this.lgId + "-" + prevIndex;
997
- if (this.galleryItems.length <= 3) {
998
- this.galleryItems.forEach(function (_element, index) {
999
- itemsToBeInsertedToDom.push("lg-item-" + _this.lgId + "-" + index);
1000
- });
1001
- return itemsToBeInsertedToDom;
1002
- }
1003
- if (index < (this.galleryItems.length - 1) / 2) {
1004
- for (var idx = index; idx > index - possibleNumberOfItems / 2 && idx >= 0; idx--) {
1005
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + idx);
1006
- }
1007
- var numberOfExistingItems = itemsToBeInsertedToDom.length;
1008
- for (var idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
1009
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (index + idx + 1));
1010
- }
1011
- }
1012
- else {
1013
- for (var idx = index; idx <= this.galleryItems.length - 1 &&
1014
- idx < index + possibleNumberOfItems / 2; idx++) {
1015
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + idx);
1016
- }
1017
- var numberOfExistingItems = itemsToBeInsertedToDom.length;
1018
- for (var idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
1019
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (index - idx - 1));
1020
- }
1021
- }
1022
- if (this.settings.loop) {
1023
- if (index === this.galleryItems.length - 1) {
1024
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + 0);
1025
- }
1026
- else if (index === 0) {
1027
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + (this.galleryItems.length - 1));
1028
- }
1029
- }
1030
- if (itemsToBeInsertedToDom.indexOf(prevIndexItem) === -1) {
1031
- itemsToBeInsertedToDom.push("lg-item-" + this.lgId + "-" + prevIndex);
1032
- }
1033
- return itemsToBeInsertedToDom;
1034
- };
1035
- LightGallery.prototype.organizeSlideItems = function (index, prevIndex) {
1036
- var _this = this;
1037
- var itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(index, prevIndex, this.settings.numberOfSlideItemsInDom);
1038
- itemsToBeInsertedToDom.forEach(function (item) {
1039
- if (_this.currentItemsInDom.indexOf(item) === -1) {
1040
- _this.$inner.append("<div id=\"" + item + "\" class=\"lg-item\"></div>");
1041
- }
1042
- });
1043
- this.currentItemsInDom.forEach(function (item) {
1044
- if (itemsToBeInsertedToDom.indexOf(item) === -1) {
1045
- lgQuery_1.$LG("#" + item).remove();
1046
- }
1047
- });
1048
- return itemsToBeInsertedToDom;
1049
- };
1050
- /**
1051
- * Get previous index of the slide
1052
- */
1053
- LightGallery.prototype.getPreviousSlideIndex = function () {
1054
- var prevIndex = 0;
1055
- try {
1056
- var currentItemId = this.outer
1057
- .find('.lg-current')
1058
- .first()
1059
- .attr('id');
1060
- prevIndex = parseInt(currentItemId.split('-')[3]) || 0;
1061
- }
1062
- catch (error) {
1063
- prevIndex = 0;
1064
- }
1065
- return prevIndex;
1066
- };
1067
- LightGallery.prototype.setDownloadValue = function (index) {
1068
- if (this.settings.download) {
1069
- var currentGalleryItem = this.galleryItems[index];
1070
- var hideDownloadBtn = currentGalleryItem.downloadUrl === false ||
1071
- currentGalleryItem.downloadUrl === 'false';
1072
- if (hideDownloadBtn) {
1073
- this.outer.addClass('lg-hide-download');
1074
- }
1075
- else {
1076
- var $download = this.getElementById('lg-download');
1077
- this.outer.removeClass('lg-hide-download');
1078
- $download.attr('href', currentGalleryItem.downloadUrl ||
1079
- currentGalleryItem.src);
1080
- if (currentGalleryItem.download) {
1081
- $download.attr('download', currentGalleryItem.download);
1082
- }
1083
- }
1084
- }
1085
- };
1086
- LightGallery.prototype.makeSlideAnimation = function (direction, currentSlideItem, previousSlideItem) {
1087
- var _this = this;
1088
- if (this.lGalleryOn) {
1089
- previousSlideItem.addClass('lg-slide-progress');
1090
- }
1091
- setTimeout(function () {
1092
- // remove all transitions
1093
- _this.outer.addClass('lg-no-trans');
1094
- _this.outer
1095
- .find('.lg-item')
1096
- .removeClass('lg-prev-slide lg-next-slide');
1097
- if (direction === 'prev') {
1098
- //prevslide
1099
- currentSlideItem.addClass('lg-prev-slide');
1100
- previousSlideItem.addClass('lg-next-slide');
1101
- }
1102
- else {
1103
- // next slide
1104
- currentSlideItem.addClass('lg-next-slide');
1105
- previousSlideItem.addClass('lg-prev-slide');
1106
- }
1107
- // give 50 ms for browser to add/remove class
1108
- setTimeout(function () {
1109
- _this.outer.find('.lg-item').removeClass('lg-current');
1110
- currentSlideItem.addClass('lg-current');
1111
- // reset all transitions
1112
- _this.outer.removeClass('lg-no-trans');
1113
- }, 50);
1114
- }, this.lGalleryOn ? this.settings.slideDelay : 0);
1115
- };
1116
- /**
1117
- * Goto a specific slide.
1118
- * @param {Number} index - index of the slide
1119
- * @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
1120
- * @param {Boolean} fromThumb - true if slide function called via thumbnail click
1121
- * @param {String} direction - Direction of the slide(next/prev)
1122
- * @category lGPublicMethods
1123
- * @example
1124
- * const plugin = lightGallery();
1125
- * // to go to 3rd slide
1126
- * plugin.slide(2);
1127
- *
1128
- */
1129
- LightGallery.prototype.slide = function (index, fromTouch, fromThumb, direction) {
1130
- var _this = this;
1131
- var prevIndex = this.getPreviousSlideIndex();
1132
- this.currentItemsInDom = this.organizeSlideItems(index, prevIndex);
1133
- // Prevent multiple call, Required for hsh plugin
1134
- if (this.lGalleryOn && prevIndex === index) {
1135
- return;
1136
- }
1137
- var numberOfGalleryItems = this.galleryItems.length;
1138
- if (!this.lgBusy) {
1139
- if (this.settings.counter) {
1140
- this.updateCurrentCounter(index);
1141
- }
1142
- var currentSlideItem = this.getSlideItem(index);
1143
- var previousSlideItem_1 = this.getSlideItem(prevIndex);
1144
- var currentGalleryItem = this.galleryItems[index];
1145
- var videoInfo = currentGalleryItem.__slideVideoInfo;
1146
- this.outer.attr('data-lg-slide-type', this.getSlideType(currentGalleryItem));
1147
- this.setDownloadValue(index);
1148
- if (videoInfo) {
1149
- var _a = this.mediaContainerPosition, top_3 = _a.top, bottom = _a.bottom;
1150
- var videoSize = lg_utils_1.default.getSize(this.items[index], this.outer, top_3 + bottom, videoInfo && this.settings.videoMaxSize);
1151
- this.resizeVideoSlide(index, videoSize);
1152
- }
1153
- this.LGel.trigger(lg_events_1.lGEvents.beforeSlide, {
1154
- prevIndex: prevIndex,
1155
- index: index,
1156
- fromTouch: !!fromTouch,
1157
- fromThumb: !!fromThumb,
1158
- });
1159
- this.lgBusy = true;
1160
- clearTimeout(this.hideBarTimeout);
1161
- this.arrowDisable(index);
1162
- if (!direction) {
1163
- if (index < prevIndex) {
1164
- direction = 'prev';
1165
- }
1166
- else if (index > prevIndex) {
1167
- direction = 'next';
1168
- }
1169
- }
1170
- if (!fromTouch) {
1171
- this.makeSlideAnimation(direction, currentSlideItem, previousSlideItem_1);
1172
- }
1173
- else {
1174
- this.outer
1175
- .find('.lg-item')
1176
- .removeClass('lg-prev-slide lg-current lg-next-slide');
1177
- var touchPrev = void 0;
1178
- var touchNext = void 0;
1179
- if (numberOfGalleryItems > 2) {
1180
- touchPrev = index - 1;
1181
- touchNext = index + 1;
1182
- if (index === 0 && prevIndex === numberOfGalleryItems - 1) {
1183
- // next slide
1184
- touchNext = 0;
1185
- touchPrev = numberOfGalleryItems - 1;
1186
- }
1187
- else if (index === numberOfGalleryItems - 1 &&
1188
- prevIndex === 0) {
1189
- // prev slide
1190
- touchNext = 0;
1191
- touchPrev = numberOfGalleryItems - 1;
1192
- }
1193
- }
1194
- else {
1195
- touchPrev = 0;
1196
- touchNext = 1;
1197
- }
1198
- if (direction === 'prev') {
1199
- this.getSlideItem(touchNext).addClass('lg-next-slide');
1200
- }
1201
- else {
1202
- this.getSlideItem(touchPrev).addClass('lg-prev-slide');
1203
- }
1204
- currentSlideItem.addClass('lg-current');
1205
- }
1206
- // Do not put load content in set timeout as it needs to load immediately when the gallery is opened
1207
- if (!this.lGalleryOn) {
1208
- this.loadContent(index, true);
1209
- }
1210
- else {
1211
- setTimeout(function () {
1212
- _this.loadContent(index, true);
1213
- // Add title if this.settings.appendSubHtmlTo === lg-sub-html
1214
- if (_this.settings.appendSubHtmlTo !== '.lg-item') {
1215
- _this.addHtml(index);
1216
- }
1217
- }, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
1218
- }
1219
- setTimeout(function () {
1220
- _this.lgBusy = false;
1221
- previousSlideItem_1.removeClass('lg-slide-progress');
1222
- _this.LGel.trigger(lg_events_1.lGEvents.afterSlide, {
1223
- prevIndex: prevIndex,
1224
- index: index,
1225
- fromTouch: fromTouch,
1226
- fromThumb: fromThumb,
1227
- });
1228
- }, (this.lGalleryOn ? this.settings.speed + 100 : 100) + (fromTouch ? 0 : this.settings.slideDelay));
1229
- }
1230
- this.index = index;
1231
- };
1232
- LightGallery.prototype.updateCurrentCounter = function (index) {
1233
- this.getElementById('lg-counter-current').html(index + 1 + '');
1234
- };
1235
- LightGallery.prototype.updateCounterTotal = function () {
1236
- this.getElementById('lg-counter-all').html(this.galleryItems.length + '');
1237
- };
1238
- LightGallery.prototype.getSlideType = function (item) {
1239
- if (item.__slideVideoInfo) {
1240
- return 'video';
1241
- }
1242
- else if (item.iframe) {
1243
- return 'iframe';
1244
- }
1245
- else {
1246
- return 'image';
1247
- }
1248
- };
1249
- LightGallery.prototype.touchMove = function (startCoords, endCoords, e) {
1250
- var distanceX = endCoords.pageX - startCoords.pageX;
1251
- var distanceY = endCoords.pageY - startCoords.pageY;
1252
- var allowSwipe = false;
1253
- if (this.swipeDirection) {
1254
- allowSwipe = true;
1255
- }
1256
- else {
1257
- if (Math.abs(distanceX) > 15) {
1258
- this.swipeDirection = 'horizontal';
1259
- allowSwipe = true;
1260
- }
1261
- else if (Math.abs(distanceY) > 15) {
1262
- this.swipeDirection = 'vertical';
1263
- allowSwipe = true;
1264
- }
1265
- }
1266
- if (!allowSwipe) {
1267
- return;
1268
- }
1269
- var $currentSlide = this.getSlideItem(this.index);
1270
- if (this.swipeDirection === 'horizontal') {
1271
- e === null || e === void 0 ? void 0 : e.preventDefault();
1272
- // reset opacity and transition duration
1273
- this.outer.addClass('lg-dragging');
1274
- // move current slide
1275
- this.setTranslate($currentSlide, distanceX, 0);
1276
- // move next and prev slide with current slide
1277
- var width = $currentSlide.get().offsetWidth;
1278
- var slideWidthAmount = (width * 15) / 100;
1279
- var gutter = slideWidthAmount - Math.abs((distanceX * 10) / 100);
1280
- this.setTranslate(this.outer.find('.lg-prev-slide').first(), -width + distanceX - gutter, 0);
1281
- this.setTranslate(this.outer.find('.lg-next-slide').first(), width + distanceX + gutter, 0);
1282
- }
1283
- else if (this.swipeDirection === 'vertical') {
1284
- if (this.settings.swipeToClose) {
1285
- e === null || e === void 0 ? void 0 : e.preventDefault();
1286
- this.$container.addClass('lg-dragging-vertical');
1287
- var opacity = 1 - Math.abs(distanceY) / window.innerHeight;
1288
- this.$backdrop.css('opacity', opacity);
1289
- var scale = 1 - Math.abs(distanceY) / (window.innerWidth * 2);
1290
- this.setTranslate($currentSlide, 0, distanceY, scale, scale);
1291
- if (Math.abs(distanceY) > 100) {
1292
- this.outer
1293
- .addClass('lg-hide-items')
1294
- .removeClass('lg-components-open');
1295
- }
1296
- }
1297
- }
1298
- };
1299
- LightGallery.prototype.touchEnd = function (endCoords, startCoords, event) {
1300
- var _this = this;
1301
- var distance;
1302
- // keep slide animation for any mode while dragg/swipe
1303
- if (this.settings.mode !== 'lg-slide') {
1304
- this.outer.addClass('lg-slide');
1305
- }
1306
- // set transition duration
1307
- setTimeout(function () {
1308
- _this.$container.removeClass('lg-dragging-vertical');
1309
- _this.outer
1310
- .removeClass('lg-dragging lg-hide-items')
1311
- .addClass('lg-components-open');
1312
- var triggerClick = true;
1313
- if (_this.swipeDirection === 'horizontal') {
1314
- distance = endCoords.pageX - startCoords.pageX;
1315
- var distanceAbs = Math.abs(endCoords.pageX - startCoords.pageX);
1316
- if (distance < 0 &&
1317
- distanceAbs > _this.settings.swipeThreshold) {
1318
- _this.goToNextSlide(true);
1319
- triggerClick = false;
1320
- }
1321
- else if (distance > 0 &&
1322
- distanceAbs > _this.settings.swipeThreshold) {
1323
- _this.goToPrevSlide(true);
1324
- triggerClick = false;
1325
- }
1326
- }
1327
- else if (_this.swipeDirection === 'vertical') {
1328
- distance = Math.abs(endCoords.pageY - startCoords.pageY);
1329
- if (_this.settings.closable &&
1330
- _this.settings.swipeToClose &&
1331
- distance > 100) {
1332
- _this.closeGallery();
1333
- return;
1334
- }
1335
- else {
1336
- _this.$backdrop.css('opacity', 1);
1337
- }
1338
- }
1339
- _this.outer.find('.lg-item').removeAttr('style');
1340
- if (triggerClick &&
1341
- Math.abs(endCoords.pageX - startCoords.pageX) < 5) {
1342
- // Trigger click if distance is less than 5 pix
1343
- var target = lgQuery_1.$LG(event.target);
1344
- if (_this.isPosterElement(target)) {
1345
- _this.LGel.trigger(lg_events_1.lGEvents.posterClick);
1346
- }
1347
- }
1348
- _this.swipeDirection = undefined;
1349
- });
1350
- // remove slide class once drag/swipe is completed if mode is not slide
1351
- setTimeout(function () {
1352
- if (!_this.outer.hasClass('lg-dragging') &&
1353
- _this.settings.mode !== 'lg-slide') {
1354
- _this.outer.removeClass('lg-slide');
1355
- }
1356
- }, this.settings.speed + 100);
1357
- };
1358
- LightGallery.prototype.enableSwipe = function () {
1359
- var _this = this;
1360
- var startCoords = {};
1361
- var endCoords = {};
1362
- var isMoved = false;
1363
- var isSwiping = false;
1364
- if (this.settings.enableSwipe) {
1365
- this.$inner.on('touchstart.lg', function (e) {
1366
- _this.dragOrSwipeEnabled = true;
1367
- var $item = _this.getSlideItem(_this.index);
1368
- if ((lgQuery_1.$LG(e.target).hasClass('lg-item') ||
1369
- $item.get().contains(e.target)) &&
1370
- !_this.outer.hasClass('lg-zoomed') &&
1371
- !_this.lgBusy &&
1372
- e.touches.length === 1) {
1373
- isSwiping = true;
1374
- _this.touchAction = 'swipe';
1375
- _this.manageSwipeClass();
1376
- startCoords = {
1377
- pageX: e.touches[0].pageX,
1378
- pageY: e.touches[0].pageY,
1379
- };
1380
- }
1381
- });
1382
- this.$inner.on('touchmove.lg', function (e) {
1383
- if (isSwiping &&
1384
- _this.touchAction === 'swipe' &&
1385
- e.touches.length === 1) {
1386
- endCoords = {
1387
- pageX: e.touches[0].pageX,
1388
- pageY: e.touches[0].pageY,
1389
- };
1390
- _this.touchMove(startCoords, endCoords, e);
1391
- isMoved = true;
1392
- }
1393
- });
1394
- this.$inner.on('touchend.lg', function (event) {
1395
- if (_this.touchAction === 'swipe') {
1396
- if (isMoved) {
1397
- isMoved = false;
1398
- _this.touchEnd(endCoords, startCoords, event);
1399
- }
1400
- else if (isSwiping) {
1401
- var target = lgQuery_1.$LG(event.target);
1402
- if (_this.isPosterElement(target)) {
1403
- _this.LGel.trigger(lg_events_1.lGEvents.posterClick);
1404
- }
1405
- }
1406
- _this.touchAction = undefined;
1407
- isSwiping = false;
1408
- }
1409
- });
1410
- }
1411
- };
1412
- LightGallery.prototype.enableDrag = function () {
1413
- var _this = this;
1414
- var startCoords = {};
1415
- var endCoords = {};
1416
- var isDraging = false;
1417
- var isMoved = false;
1418
- if (this.settings.enableDrag) {
1419
- this.outer.on('mousedown.lg', function (e) {
1420
- _this.dragOrSwipeEnabled = true;
1421
- var $item = _this.getSlideItem(_this.index);
1422
- if (lgQuery_1.$LG(e.target).hasClass('lg-item') ||
1423
- $item.get().contains(e.target)) {
1424
- if (!_this.outer.hasClass('lg-zoomed') && !_this.lgBusy) {
1425
- e.preventDefault();
1426
- if (!_this.lgBusy) {
1427
- _this.manageSwipeClass();
1428
- startCoords = {
1429
- pageX: e.pageX,
1430
- pageY: e.pageY,
1431
- };
1432
- isDraging = true;
1433
- // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
1434
- _this.outer.get().scrollLeft += 1;
1435
- _this.outer.get().scrollLeft -= 1;
1436
- // *
1437
- _this.outer
1438
- .removeClass('lg-grab')
1439
- .addClass('lg-grabbing');
1440
- _this.LGel.trigger(lg_events_1.lGEvents.dragStart);
1441
- }
1442
- }
1443
- }
1444
- });
1445
- lgQuery_1.$LG(window).on("mousemove.lg.global" + this.lgId, function (e) {
1446
- if (isDraging && _this.lgOpened) {
1447
- isMoved = true;
1448
- endCoords = {
1449
- pageX: e.pageX,
1450
- pageY: e.pageY,
1451
- };
1452
- _this.touchMove(startCoords, endCoords);
1453
- _this.LGel.trigger(lg_events_1.lGEvents.dragMove);
1454
- }
1455
- });
1456
- lgQuery_1.$LG(window).on("mouseup.lg.global" + this.lgId, function (event) {
1457
- if (!_this.lgOpened) {
1458
- return;
1459
- }
1460
- var target = lgQuery_1.$LG(event.target);
1461
- if (isMoved) {
1462
- isMoved = false;
1463
- _this.touchEnd(endCoords, startCoords, event);
1464
- _this.LGel.trigger(lg_events_1.lGEvents.dragEnd);
1465
- }
1466
- else if (_this.isPosterElement(target)) {
1467
- _this.LGel.trigger(lg_events_1.lGEvents.posterClick);
1468
- }
1469
- // Prevent execution on click
1470
- if (isDraging) {
1471
- isDraging = false;
1472
- _this.outer.removeClass('lg-grabbing').addClass('lg-grab');
1473
- }
1474
- });
1475
- }
1476
- };
1477
- LightGallery.prototype.triggerPosterClick = function () {
1478
- var _this = this;
1479
- this.$inner.on('click.lg', function (event) {
1480
- if (!_this.dragOrSwipeEnabled &&
1481
- _this.isPosterElement(lgQuery_1.$LG(event.target))) {
1482
- _this.LGel.trigger(lg_events_1.lGEvents.posterClick);
1483
- }
1484
- });
1485
- };
1486
- LightGallery.prototype.manageSwipeClass = function () {
1487
- var _touchNext = this.index + 1;
1488
- var _touchPrev = this.index - 1;
1489
- if (this.settings.loop && this.galleryItems.length > 2) {
1490
- if (this.index === 0) {
1491
- _touchPrev = this.galleryItems.length - 1;
1492
- }
1493
- else if (this.index === this.galleryItems.length - 1) {
1494
- _touchNext = 0;
1495
- }
1496
- }
1497
- this.outer.find('.lg-item').removeClass('lg-next-slide lg-prev-slide');
1498
- if (_touchPrev > -1) {
1499
- this.getSlideItem(_touchPrev).addClass('lg-prev-slide');
1500
- }
1501
- this.getSlideItem(_touchNext).addClass('lg-next-slide');
1502
- };
1503
- /**
1504
- * Go to next slide
1505
- * @param {Boolean} fromTouch - true if slide function called via touch event
1506
- * @category lGPublicMethods
1507
- * @example
1508
- * const plugin = lightGallery();
1509
- * plugin.goToNextSlide();
1510
- * @see <a href="/demos/methods/">Demo</a>
1511
- */
1512
- LightGallery.prototype.goToNextSlide = function (fromTouch) {
1513
- var _this = this;
1514
- var _loop = this.settings.loop;
1515
- if (fromTouch && this.galleryItems.length < 3) {
1516
- _loop = false;
1517
- }
1518
- if (!this.lgBusy) {
1519
- if (this.index + 1 < this.galleryItems.length) {
1520
- this.index++;
1521
- this.LGel.trigger(lg_events_1.lGEvents.beforeNextSlide, {
1522
- index: this.index,
1523
- });
1524
- this.slide(this.index, !!fromTouch, false, 'next');
1525
- }
1526
- else {
1527
- if (_loop) {
1528
- this.index = 0;
1529
- this.LGel.trigger(lg_events_1.lGEvents.beforeNextSlide, {
1530
- index: this.index,
1531
- });
1532
- this.slide(this.index, !!fromTouch, false, 'next');
1533
- }
1534
- else if (this.settings.slideEndAnimation && !fromTouch) {
1535
- this.outer.addClass('lg-right-end');
1536
- setTimeout(function () {
1537
- _this.outer.removeClass('lg-right-end');
1538
- }, 400);
1539
- }
1540
- }
1541
- }
1542
- };
1543
- /**
1544
- * Go to previous slides
1545
- * @param {Boolean} fromTouch - true if slide function called via touch event
1546
- * @category lGPublicMethods
1547
- * @example
1548
- * const plugin = lightGallery({});
1549
- * plugin.goToPrevSlide();
1550
- * @see <a href="/demos/methods/">Demo</a>
1551
- *
1552
- */
1553
- LightGallery.prototype.goToPrevSlide = function (fromTouch) {
1554
- var _this = this;
1555
- var _loop = this.settings.loop;
1556
- if (fromTouch && this.galleryItems.length < 3) {
1557
- _loop = false;
1558
- }
1559
- if (!this.lgBusy) {
1560
- if (this.index > 0) {
1561
- this.index--;
1562
- this.LGel.trigger(lg_events_1.lGEvents.beforePrevSlide, {
1563
- index: this.index,
1564
- fromTouch: fromTouch,
1565
- });
1566
- this.slide(this.index, !!fromTouch, false, 'prev');
1567
- }
1568
- else {
1569
- if (_loop) {
1570
- this.index = this.galleryItems.length - 1;
1571
- this.LGel.trigger(lg_events_1.lGEvents.beforePrevSlide, {
1572
- index: this.index,
1573
- fromTouch: fromTouch,
1574
- });
1575
- this.slide(this.index, !!fromTouch, false, 'prev');
1576
- }
1577
- else if (this.settings.slideEndAnimation && !fromTouch) {
1578
- this.outer.addClass('lg-left-end');
1579
- setTimeout(function () {
1580
- _this.outer.removeClass('lg-left-end');
1581
- }, 400);
1582
- }
1583
- }
1584
- }
1585
- };
1586
- LightGallery.prototype.keyPress = function () {
1587
- var _this = this;
1588
- lgQuery_1.$LG(window).on("keydown.lg.global" + this.lgId, function (e) {
1589
- if (_this.lgOpened &&
1590
- _this.settings.escKey === true &&
1591
- e.keyCode === 27) {
1592
- e.preventDefault();
1593
- if (_this.settings.allowMediaOverlap &&
1594
- _this.outer.hasClass('lg-can-toggle') &&
1595
- _this.outer.hasClass('lg-components-open')) {
1596
- _this.outer.removeClass('lg-components-open');
1597
- }
1598
- else {
1599
- _this.closeGallery();
1600
- }
1601
- }
1602
- if (_this.lgOpened && _this.galleryItems.length > 1) {
1603
- if (e.keyCode === 37) {
1604
- e.preventDefault();
1605
- _this.goToPrevSlide();
1606
- }
1607
- if (e.keyCode === 39) {
1608
- e.preventDefault();
1609
- _this.goToNextSlide();
1610
- }
1611
- }
1612
- });
1613
- };
1614
- LightGallery.prototype.arrow = function () {
1615
- var _this = this;
1616
- this.getElementById('lg-prev').on('click.lg', function () {
1617
- _this.goToPrevSlide();
1618
- });
1619
- this.getElementById('lg-next').on('click.lg', function () {
1620
- _this.goToNextSlide();
1621
- });
1622
- };
1623
- LightGallery.prototype.arrowDisable = function (index) {
1624
- // Disable arrows if settings.hideControlOnEnd is true
1625
- if (!this.settings.loop && this.settings.hideControlOnEnd) {
1626
- var $prev = this.getElementById('lg-prev');
1627
- var $next = this.getElementById('lg-next');
1628
- if (index + 1 === this.galleryItems.length) {
1629
- $next.attr('disabled', 'disabled').addClass('disabled');
1630
- }
1631
- else {
1632
- $next.removeAttr('disabled').removeClass('disabled');
1633
- }
1634
- if (index === 0) {
1635
- $prev.attr('disabled', 'disabled').addClass('disabled');
1636
- }
1637
- else {
1638
- $prev.removeAttr('disabled').removeClass('disabled');
1639
- }
1640
- }
1641
- };
1642
- LightGallery.prototype.setTranslate = function ($el, xValue, yValue, scaleX, scaleY) {
1643
- if (scaleX === void 0) { scaleX = 1; }
1644
- if (scaleY === void 0) { scaleY = 1; }
1645
- $el.css('transform', 'translate3d(' +
1646
- xValue +
1647
- 'px, ' +
1648
- yValue +
1649
- 'px, 0px) scale3d(' +
1650
- scaleX +
1651
- ', ' +
1652
- scaleY +
1653
- ', 1)');
1654
- };
1655
- LightGallery.prototype.mousewheel = function () {
1656
- var _this = this;
1657
- var lastCall = 0;
1658
- this.outer.on('wheel.lg', function (e) {
1659
- if (!e.deltaY || _this.galleryItems.length < 2) {
1660
- return;
1661
- }
1662
- e.preventDefault();
1663
- var now = new Date().getTime();
1664
- if (now - lastCall < 1000) {
1665
- return;
1666
- }
1667
- lastCall = now;
1668
- if (e.deltaY > 0) {
1669
- _this.goToNextSlide();
1670
- }
1671
- else if (e.deltaY < 0) {
1672
- _this.goToPrevSlide();
1673
- }
1674
- });
1675
- };
1676
- LightGallery.prototype.isSlideElement = function (target) {
1677
- return (target.hasClass('lg-outer') ||
1678
- target.hasClass('lg-item') ||
1679
- target.hasClass('lg-img-wrap') ||
1680
- target.hasClass('lg-img-rotate'));
1681
- };
1682
- LightGallery.prototype.isPosterElement = function (target) {
1683
- var playButton = this.getSlideItem(this.index)
1684
- .find('.lg-video-play-button')
1685
- .get();
1686
- return (target.hasClass('lg-video-poster') ||
1687
- target.hasClass('lg-video-play-button') ||
1688
- (playButton && playButton.contains(target.get())));
1689
- };
1690
- /**
1691
- * Maximize minimize inline gallery.
1692
- * @category lGPublicMethods
1693
- */
1694
- LightGallery.prototype.toggleMaximize = function () {
1695
- var _this = this;
1696
- this.getElementById('lg-maximize').on('click.lg', function () {
1697
- _this.$container.toggleClass('lg-inline');
1698
- _this.refreshOnResize();
1699
- });
1700
- };
1701
- LightGallery.prototype.invalidateItems = function () {
1702
- for (var index = 0; index < this.items.length; index++) {
1703
- var element = this.items[index];
1704
- var $element = lgQuery_1.$LG(element);
1705
- $element.off("click.lgcustom-item-" + $element.attr('data-lg-id'));
1706
- }
1707
- };
1708
- LightGallery.prototype.trapFocus = function () {
1709
- var _this = this;
1710
- this.$container.get().focus({
1711
- preventScroll: true,
1712
- });
1713
- lgQuery_1.$LG(window).on("keydown.lg.global" + this.lgId, function (e) {
1714
- if (!_this.lgOpened) {
1715
- return;
1716
- }
1717
- var isTabPressed = e.key === 'Tab' || e.keyCode === 9;
1718
- if (!isTabPressed) {
1719
- return;
1720
- }
1721
- var focusableEls = lg_utils_1.default.getFocusableElements(_this.$container.get());
1722
- var firstFocusableEl = focusableEls[0];
1723
- var lastFocusableEl = focusableEls[focusableEls.length - 1];
1724
- if (e.shiftKey) {
1725
- if (document.activeElement === firstFocusableEl) {
1726
- lastFocusableEl.focus();
1727
- e.preventDefault();
1728
- }
1729
- }
1730
- else {
1731
- if (document.activeElement === lastFocusableEl) {
1732
- firstFocusableEl.focus();
1733
- e.preventDefault();
1734
- }
1735
- }
1736
- });
1737
- };
1738
- LightGallery.prototype.manageCloseGallery = function () {
1739
- var _this = this;
1740
- if (!this.settings.closable)
1741
- return;
1742
- var mousedown = false;
1743
- this.getElementById('lg-close').on('click.lg', function () {
1744
- _this.closeGallery();
1745
- });
1746
- if (this.settings.closeOnTap) {
1747
- // If you drag the slide and release outside gallery gets close on chrome
1748
- // for preventing this check mousedown and mouseup happened on .lg-item or lg-outer
1749
- this.outer.on('mousedown.lg', function (e) {
1750
- var target = lgQuery_1.$LG(e.target);
1751
- if (_this.isSlideElement(target)) {
1752
- mousedown = true;
1753
- }
1754
- else {
1755
- mousedown = false;
1756
- }
1757
- });
1758
- this.outer.on('mousemove.lg', function () {
1759
- mousedown = false;
1760
- });
1761
- this.outer.on('mouseup.lg', function (e) {
1762
- var target = lgQuery_1.$LG(e.target);
1763
- if (_this.isSlideElement(target) && mousedown) {
1764
- if (!_this.outer.hasClass('lg-dragging')) {
1765
- _this.closeGallery();
1766
- }
1767
- }
1768
- });
1769
- }
1770
- };
1771
- /**
1772
- * Close lightGallery if it is opened.
1773
- *
1774
- * @description If closable is false in the settings, you need to pass true via closeGallery method to force close gallery
1775
- * @return returns the estimated time to close gallery completely including the close animation duration
1776
- * @category lGPublicMethods
1777
- * @example
1778
- * const plugin = lightGallery();
1779
- * plugin.closeGallery();
1780
- *
1781
- */
1782
- LightGallery.prototype.closeGallery = function (force) {
1783
- var _this = this;
1784
- if (!this.lgOpened || (!this.settings.closable && !force)) {
1785
- return 0;
1786
- }
1787
- this.LGel.trigger(lg_events_1.lGEvents.beforeClose);
1788
- if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
1789
- lgQuery_1.$LG(window).scrollTop(this.prevScrollTop);
1790
- }
1791
- var currentItem = this.items[this.index];
1792
- var transform;
1793
- if (this.zoomFromOrigin && currentItem) {
1794
- var _a = this.mediaContainerPosition, top_4 = _a.top, bottom = _a.bottom;
1795
- var _b = this.galleryItems[this.index], __slideVideoInfo = _b.__slideVideoInfo, poster = _b.poster;
1796
- var imageSize = lg_utils_1.default.getSize(currentItem, this.outer, top_4 + bottom, __slideVideoInfo && poster && this.settings.videoMaxSize);
1797
- transform = lg_utils_1.default.getTransform(currentItem, this.outer, top_4, bottom, imageSize);
1798
- }
1799
- if (this.zoomFromOrigin && transform) {
1800
- this.outer.addClass('lg-closing lg-zoom-from-image');
1801
- this.getSlideItem(this.index)
1802
- .addClass('lg-start-end-progress')
1803
- .css('transition-duration', this.settings.startAnimationDuration + 'ms')
1804
- .css('transform', transform);
1805
- }
1806
- else {
1807
- this.outer.addClass('lg-hide-items');
1808
- // lg-zoom-from-image is used for setting the opacity to 1 if zoomFromOrigin is true
1809
- // If the closing item doesn't have the lg-size attribute, remove this class to avoid the closing css conflicts
1810
- this.outer.removeClass('lg-zoom-from-image');
1811
- }
1812
- // Unbind all events added by lightGallery
1813
- // @todo
1814
- //this.$el.off('.lg.tm');
1815
- this.destroyModules();
1816
- this.lGalleryOn = false;
1817
- this.isDummyImageRemoved = false;
1818
- this.zoomFromOrigin = this.settings.zoomFromOrigin;
1819
- clearTimeout(this.hideBarTimeout);
1820
- this.hideBarTimeout = false;
1821
- lgQuery_1.$LG('html').removeClass('lg-on');
1822
- this.outer.removeClass('lg-visible lg-components-open');
1823
- // Resetting opacity to 0 isd required as vertical swipe to close function adds inline opacity.
1824
- this.$backdrop.removeClass('in').css('opacity', 0);
1825
- var removeTimeout = this.zoomFromOrigin && transform
1826
- ? Math.max(this.settings.startAnimationDuration, this.settings.backdropDuration)
1827
- : this.settings.backdropDuration;
1828
- this.$container.removeClass('lg-show-in');
1829
- // Once the closign animation is completed and gallery is invisible
1830
- setTimeout(function () {
1831
- if (_this.zoomFromOrigin && transform) {
1832
- _this.outer.removeClass('lg-zoom-from-image');
1833
- }
1834
- _this.$container.removeClass('lg-show');
1835
- // Reset scrollbar
1836
- _this.resetScrollBar();
1837
- // Need to remove inline opacity as it is used in the stylesheet as well
1838
- _this.$backdrop
1839
- .removeAttr('style')
1840
- .css('transition-duration', _this.settings.backdropDuration + 'ms');
1841
- _this.outer.removeClass("lg-closing " + _this.settings.startClass);
1842
- _this.getSlideItem(_this.index).removeClass('lg-start-end-progress');
1843
- _this.$inner.empty();
1844
- if (_this.lgOpened) {
1845
- _this.LGel.trigger(lg_events_1.lGEvents.afterClose, {
1846
- instance: _this,
1847
- });
1848
- }
1849
- if (_this.$container.get()) {
1850
- _this.$container.get().blur();
1851
- }
1852
- _this.lgOpened = false;
1853
- }, removeTimeout + 100);
1854
- return removeTimeout + 100;
1855
- };
1856
- LightGallery.prototype.initModules = function () {
1857
- this.plugins.forEach(function (module) {
1858
- try {
1859
- module.init();
1860
- }
1861
- catch (err) {
1862
- console.warn("lightGallery:- make sure lightGallery module is properly initiated");
1863
- }
1864
- });
1865
- };
1866
- LightGallery.prototype.destroyModules = function (destroy) {
1867
- this.plugins.forEach(function (module) {
1868
- try {
1869
- if (destroy) {
1870
- module.destroy();
1871
- }
1872
- else {
1873
- module.closeGallery && module.closeGallery();
1874
- }
1875
- }
1876
- catch (err) {
1877
- console.warn("lightGallery:- make sure lightGallery module is properly destroyed");
1878
- }
1879
- });
1880
- };
1881
- /**
1882
- * Refresh lightGallery with new set of children.
1883
- *
1884
- * @description This is useful to update the gallery when the child elements are changed without calling destroy method.
1885
- *
1886
- * If you are using dynamic mode, you can pass the modified array of dynamicEl as the first parameter to refresh the dynamic gallery
1887
- * @see <a href="/demos/dynamic-mode/">Demo</a>
1888
- * @category lGPublicMethods
1889
- * @example
1890
- * const plugin = lightGallery();
1891
- * // Delete or add children, then call
1892
- * plugin.refresh();
1893
- *
1894
- */
1895
- LightGallery.prototype.refresh = function (galleryItems) {
1896
- if (!this.settings.dynamic) {
1897
- this.invalidateItems();
1898
- }
1899
- if (galleryItems) {
1900
- this.galleryItems = galleryItems;
1901
- }
1902
- else {
1903
- this.galleryItems = this.getItems();
1904
- }
1905
- this.updateControls();
1906
- this.openGalleryOnItemClick();
1907
- this.LGel.trigger(lg_events_1.lGEvents.updateSlides);
1908
- };
1909
- LightGallery.prototype.updateControls = function () {
1910
- this.addSlideVideoInfo(this.galleryItems);
1911
- this.updateCounterTotal();
1912
- this.manageSingleSlideClassName();
1913
- };
1914
- LightGallery.prototype.destroyGallery = function () {
1915
- this.destroyModules(true);
1916
- if (!this.settings.dynamic) {
1917
- this.invalidateItems();
1918
- }
1919
- lgQuery_1.$LG(window).off(".lg.global" + this.lgId);
1920
- this.LGel.off('.lg');
1921
- this.$container.remove();
1922
- };
1923
- /**
1924
- * Destroy lightGallery.
1925
- * Destroy lightGallery and its plugin instances completely
1926
- *
1927
- * @description This method also calls CloseGallery function internally. Returns the time takes to completely close and destroy the instance.
1928
- * In case if you want to re-initialize lightGallery right after destroying it, initialize it only once the destroy process is completed.
1929
- * You can use refresh method most of the times.
1930
- * @category lGPublicMethods
1931
- * @example
1932
- * const plugin = lightGallery();
1933
- * plugin.destroy();
1934
- *
1935
- */
1936
- LightGallery.prototype.destroy = function () {
1937
- var closeTimeout = this.closeGallery(true);
1938
- if (closeTimeout) {
1939
- setTimeout(this.destroyGallery.bind(this), closeTimeout);
1940
- }
1941
- else {
1942
- this.destroyGallery();
1943
- }
1944
- return closeTimeout;
1945
- };
1946
- return LightGallery;
1947
- }());
1948
- exports.LightGallery = LightGallery;
1949
- //# sourceMappingURL=lightgallery.js.map