lightgallery 2.9.0 → 3.0.0-beta.3
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.
- package/LICENSE +690 -0
- package/README.md +31 -21
- package/dist/README.md +229 -0
- package/{css → dist/css}/lg-autoplay.css +7 -4
- package/{css → dist/css}/lg-autoplay.css.map +1 -1
- package/{css → dist/css}/lg-comments.css +0 -6
- package/{css → dist/css}/lg-comments.css.map +1 -1
- package/dist/css/lg-fullscreen.css +11 -0
- package/dist/css/lg-fullscreen.css.map +1 -0
- package/dist/css/lg-justified.css +37 -0
- package/dist/css/lg-justified.css.map +1 -0
- package/{css → dist/css}/lg-pager.css.map +1 -1
- package/{css → dist/css}/lg-rotate.css +0 -16
- package/{css → dist/css}/lg-rotate.css.map +1 -1
- package/dist/css/lg-rtl.css +94 -0
- package/dist/css/lg-rtl.css.map +1 -0
- package/{css → dist/css}/lg-share.css +4 -32
- package/dist/css/lg-share.css.map +1 -0
- package/{css → dist/css}/lg-thumbnail.css +7 -3
- package/dist/css/lg-thumbnail.css.map +1 -0
- package/{css → dist/css}/lg-transitions.css +10 -0
- package/dist/css/lg-transitions.css.map +1 -0
- package/{css → dist/css}/lg-zoom.css +20 -9
- package/dist/css/lg-zoom.css.map +1 -0
- package/{css → dist/css}/lightgallery-bundle.css +150 -118
- package/dist/css/lightgallery-bundle.css.map +1 -0
- package/dist/css/lightgallery-bundle.min.css +1 -0
- package/{css → dist/css}/lightgallery-core.css +49 -7
- package/dist/css/lightgallery-core.css.map +1 -0
- package/{css → dist/css}/lightgallery.css +105 -44
- package/dist/css/lightgallery.css.map +1 -0
- package/dist/lightgallery.es5.js +3797 -0
- package/dist/lightgallery.es5.js.map +1 -0
- package/dist/lightgallery.min.js +1 -0
- package/dist/lightgallery.umd.js +3800 -0
- package/dist/lightgallery.umd.js.map +1 -0
- package/dist/package.json +33 -0
- package/dist/plugins/autoplay/lg-autoplay.es5.js +193 -0
- package/dist/plugins/autoplay/lg-autoplay.es5.js.map +1 -0
- package/dist/plugins/autoplay/lg-autoplay.min.js +1 -0
- package/dist/plugins/autoplay/lg-autoplay.umd.js +196 -0
- package/dist/plugins/autoplay/lg-autoplay.umd.js.map +1 -0
- package/dist/plugins/autoplay/package.json +7 -0
- package/dist/plugins/comment/lg-comment.es5.js +136 -0
- package/dist/plugins/comment/lg-comment.es5.js.map +1 -0
- package/dist/plugins/comment/lg-comment.min.js +1 -0
- package/dist/plugins/comment/lg-comment.umd.js +139 -0
- package/dist/plugins/comment/lg-comment.umd.js.map +1 -0
- package/dist/plugins/comment/package.json +7 -0
- package/dist/plugins/fullscreen/lg-fullscreen.es5.js +114 -0
- package/dist/plugins/fullscreen/lg-fullscreen.es5.js.map +1 -0
- package/dist/plugins/fullscreen/lg-fullscreen.min.js +1 -0
- package/dist/plugins/fullscreen/lg-fullscreen.umd.js +117 -0
- package/dist/plugins/fullscreen/lg-fullscreen.umd.js.map +1 -0
- package/dist/plugins/fullscreen/package.json +7 -0
- package/dist/plugins/hash/lg-hash.es5.js +207 -0
- package/dist/plugins/hash/lg-hash.es5.js.map +1 -0
- package/dist/plugins/hash/lg-hash.min.js +1 -0
- package/dist/plugins/hash/lg-hash.umd.js +210 -0
- package/dist/plugins/hash/lg-hash.umd.js.map +1 -0
- package/dist/plugins/hash/package.json +7 -0
- package/dist/plugins/justified/lg-justified.es5.js +415 -0
- package/dist/plugins/justified/lg-justified.es5.js.map +1 -0
- package/dist/plugins/justified/lg-justified.min.js +1 -0
- package/dist/plugins/justified/lg-justified.umd.js +418 -0
- package/dist/plugins/justified/lg-justified.umd.js.map +1 -0
- package/dist/plugins/justified/package.json +7 -0
- package/dist/plugins/mediumZoom/lg-medium-zoom.es5.js +95 -0
- package/dist/plugins/mediumZoom/lg-medium-zoom.es5.js.map +1 -0
- package/dist/plugins/mediumZoom/lg-medium-zoom.min.js +1 -0
- package/dist/plugins/mediumZoom/lg-medium-zoom.umd.js +98 -0
- package/dist/plugins/mediumZoom/lg-medium-zoom.umd.js.map +1 -0
- package/dist/plugins/mediumZoom/package.json +7 -0
- package/dist/plugins/originCrop/lg-origin-crop.es5.js +622 -0
- package/dist/plugins/originCrop/lg-origin-crop.es5.js.map +1 -0
- package/dist/plugins/originCrop/lg-origin-crop.min.js +1 -0
- package/dist/plugins/originCrop/lg-origin-crop.umd.js +625 -0
- package/dist/plugins/originCrop/lg-origin-crop.umd.js.map +1 -0
- package/dist/plugins/pager/lg-pager.es5.js +96 -0
- package/dist/plugins/pager/lg-pager.es5.js.map +1 -0
- package/dist/plugins/pager/lg-pager.min.js +1 -0
- package/dist/plugins/pager/lg-pager.umd.js +99 -0
- package/dist/plugins/pager/lg-pager.umd.js.map +1 -0
- package/dist/plugins/pager/package.json +7 -0
- package/dist/plugins/relativeCaption/lg-relative-caption.es5.js +98 -0
- package/dist/plugins/relativeCaption/lg-relative-caption.es5.js.map +1 -0
- package/dist/plugins/relativeCaption/lg-relative-caption.min.js +1 -0
- package/dist/plugins/relativeCaption/lg-relative-caption.umd.js +101 -0
- package/dist/plugins/relativeCaption/lg-relative-caption.umd.js.map +1 -0
- package/dist/plugins/relativeCaption/package.json +7 -0
- package/dist/plugins/rotate/lg-rotate.es5.js +226 -0
- package/dist/plugins/rotate/lg-rotate.es5.js.map +1 -0
- package/dist/plugins/rotate/lg-rotate.min.js +1 -0
- package/dist/plugins/rotate/lg-rotate.umd.js +229 -0
- package/dist/plugins/rotate/lg-rotate.umd.js.map +1 -0
- package/dist/plugins/rotate/package.json +7 -0
- package/dist/plugins/share/lg-share.es5.js +309 -0
- package/dist/plugins/share/lg-share.es5.js.map +1 -0
- package/dist/plugins/share/lg-share.min.js +1 -0
- package/dist/plugins/share/lg-share.umd.js +312 -0
- package/dist/plugins/share/lg-share.umd.js.map +1 -0
- package/dist/plugins/share/package.json +7 -0
- package/dist/plugins/thumbnail/lg-thumbnail.es5.js +792 -0
- package/dist/plugins/thumbnail/lg-thumbnail.es5.js.map +1 -0
- package/dist/plugins/thumbnail/lg-thumbnail.min.js +1 -0
- package/dist/plugins/thumbnail/lg-thumbnail.umd.js +795 -0
- package/dist/plugins/thumbnail/lg-thumbnail.umd.js.map +1 -0
- package/dist/plugins/thumbnail/package.json +7 -0
- package/dist/plugins/video/lg-video.es5.js +518 -0
- package/dist/plugins/video/lg-video.es5.js.map +1 -0
- package/dist/plugins/video/lg-video.min.js +1 -0
- package/dist/plugins/video/lg-video.umd.js +521 -0
- package/dist/plugins/video/lg-video.umd.js.map +1 -0
- package/dist/plugins/video/package.json +7 -0
- package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +72 -0
- package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js.map +1 -0
- package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +1 -0
- package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +75 -0
- package/dist/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js.map +1 -0
- package/dist/plugins/vimeoThumbnail/package.json +7 -0
- package/dist/plugins/zoom/lg-zoom.es5.js +1412 -0
- package/dist/plugins/zoom/lg-zoom.es5.js.map +1 -0
- package/dist/plugins/zoom/lg-zoom.min.js +1 -0
- package/dist/plugins/zoom/lg-zoom.umd.js +1415 -0
- package/dist/plugins/zoom/lg-zoom.umd.js.map +1 -0
- package/dist/plugins/zoom/package.json +7 -0
- package/{scss → dist/scss}/_lg-theme-default.scss +68 -18
- package/{scss → dist/scss}/_lg-variables.scss +0 -1
- package/{scss → dist/scss}/lg-autoplay.scss +10 -4
- package/{scss → dist/scss}/lg-comments.scss +0 -8
- package/dist/scss/lg-fullscreen.scss +15 -0
- package/dist/scss/lg-justified.scss +63 -0
- package/{scss → dist/scss}/lg-rotate.scss +0 -24
- package/dist/scss/lg-rtl.scss +145 -0
- package/{scss → dist/scss}/lg-share.scss +6 -33
- package/{scss → dist/scss}/lg-thumbnail.scss +16 -5
- package/{scss → dist/scss}/lg-zoom.scss +46 -9
- package/{scss → dist/scss}/lightgallery-bundle.scss +0 -1
- package/{scss → dist/scss}/lightgallery-core.scss +73 -6
- package/{scss → dist/scss}/lightgallery.scss +0 -1
- package/{scss → dist/scss}/transitions/_lg-scale-up.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-slide-circular-vertical.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-slide-circular.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-soft-zoom.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-zoom-in-big.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-zoom-in-out.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-zoom-in.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-zoom-out-big.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-zoom-out-in.scss +6 -0
- package/{scss → dist/scss}/transitions/_lg-zoom-out.scss +6 -0
- package/dist/types/headless/announce.d.ts +22 -0
- package/dist/types/headless/emitter.d.ts +14 -0
- package/dist/types/headless/gestures.d.ts +128 -0
- package/dist/types/headless/hash-driver.d.ts +77 -0
- package/dist/types/headless/icons.d.ts +56 -0
- package/dist/types/headless/index.d.ts +34 -0
- package/dist/types/headless/items.d.ts +92 -0
- package/dist/types/headless/justified-layout.d.ts +71 -0
- package/dist/types/headless/license.d.ts +35 -0
- package/dist/types/headless/origin-crop.d.ts +135 -0
- package/dist/types/headless/origin.d.ts +65 -0
- package/dist/types/headless/plugin-slices.d.ts +64 -0
- package/dist/types/headless/preload.d.ts +36 -0
- package/dist/types/headless/responsive.d.ts +90 -0
- package/dist/types/headless/settings.d.ts +268 -0
- package/dist/types/headless/share-urls.d.ts +60 -0
- package/dist/types/headless/spring.d.ts +42 -0
- package/dist/types/headless/state.d.ts +63 -0
- package/dist/types/headless/thumb-math.d.ts +85 -0
- package/dist/types/headless/toolbar-overflow.d.ts +61 -0
- package/dist/types/headless/transition.d.ts +33 -0
- package/dist/types/headless/velocity.d.ts +31 -0
- package/dist/types/headless/video-urls.d.ts +64 -0
- package/dist/types/headless/zoom-math.d.ts +89 -0
- package/{index.d.ts → dist/types/index.d.ts} +9 -4
- package/{lg-events.d.ts → dist/types/lg-events.d.ts} +300 -300
- package/dist/types/lg-icons.d.ts +27 -0
- package/{lg-plugin.d.ts → dist/types/lg-plugin.d.ts} +7 -7
- package/{lg-settings.d.ts → dist/types/lg-settings.d.ts} +549 -425
- package/dist/types/lg-spring-runner.d.ts +14 -0
- package/dist/types/lg-toolbar-overflow.d.ts +36 -0
- package/{lg-utils.d.ts → dist/types/lg-utils.d.ts} +236 -228
- package/{lgQuery.d.ts → dist/types/lgQuery.d.ts} +56 -56
- package/{lightgallery.d.ts → dist/types/lightgallery.d.ts} +384 -305
- package/{plugins → dist/types/plugins}/autoplay/lg-autoplay-settings.d.ts +41 -38
- package/{plugins → dist/types/plugins}/autoplay/lg-autoplay.d.ts +22 -22
- package/{plugins → dist/types/plugins}/comment/lg-comment-settings.d.ts +36 -33
- package/{plugins → dist/types/plugins}/comment/lg-comment.d.ts +25 -25
- package/{plugins → dist/types/plugins}/fullscreen/lg-fullscreen-settings.d.ts +17 -14
- package/{plugins → dist/types/plugins}/fullscreen/lg-fullscreen.d.ts +16 -16
- package/dist/types/plugins/hash/lg-hash-settings.d.ts +28 -0
- package/{plugins → dist/types/plugins}/hash/lg-hash.d.ts +25 -23
- package/dist/types/plugins/justified/lg-justified-settings.d.ts +42 -0
- package/dist/types/plugins/justified/lg-justified.d.ts +55 -0
- package/{plugins → dist/types/plugins}/mediumZoom/lg-medium-zoom-settings.d.ts +16 -16
- package/{plugins → dist/types/plugins}/mediumZoom/lg-medium-zoom.d.ts +12 -12
- package/dist/types/plugins/originCrop/lg-origin-crop-settings.d.ts +12 -0
- package/dist/types/plugins/originCrop/lg-origin-crop.d.ts +79 -0
- package/{plugins → dist/types/plugins}/pager/lg-pager-settings.d.ts +7 -7
- package/{plugins → dist/types/plugins}/pager/lg-pager.d.ts +13 -13
- package/{plugins → dist/types/plugins}/relativeCaption/lg-relative-caption-settings.d.ts +7 -7
- package/{plugins → dist/types/plugins}/relativeCaption/lg-relative-caption.d.ts +14 -14
- package/{plugins → dist/types/plugins}/rotate/lg-rotate-settings.d.ts +47 -45
- package/{plugins → dist/types/plugins}/rotate/lg-rotate.d.ts +25 -24
- package/{plugins → dist/types/plugins}/share/lg-fb-share-utils.d.ts +2 -2
- package/{plugins → dist/types/plugins}/share/lg-pinterest-share-utils.d.ts +2 -2
- package/{plugins → dist/types/plugins}/share/lg-share-settings.d.ts +71 -56
- package/dist/types/plugins/share/lg-share.d.ts +33 -0
- package/dist/types/plugins/share/lg-twitter-share-utils.d.ts +4 -0
- package/{plugins → dist/types/plugins}/share/types.d.ts +6 -6
- package/{plugins → dist/types/plugins}/thumbnail/lg-thumbnail-settings.d.ts +85 -70
- package/dist/types/plugins/thumbnail/lg-thumbnail.d.ts +88 -0
- package/{plugins → dist/types/plugins}/video/lg-video-settings.d.ts +94 -71
- package/{plugins → dist/types/plugins}/video/lg-video.d.ts +116 -104
- package/{plugins → dist/types/plugins}/video/types.d.ts +8 -8
- package/{plugins → dist/types/plugins}/vimeoThumbnail/lg-vimeo-thumbnail-settings.d.ts +11 -11
- package/{plugins → dist/types/plugins}/vimeoThumbnail/lg-vimeo-thumbnail.d.ts +14 -14
- package/{plugins → dist/types/plugins}/zoom/lg-zoom-settings.d.ts +54 -51
- package/{plugins → dist/types/plugins}/zoom/lg-zoom.d.ts +145 -108
- package/{types.d.ts → dist/types/types.d.ts} +40 -40
- package/package.json +222 -8
- package/angular/10/README.md +0 -24
- package/angular/10/bundles/lightgallery-angular-10.umd.js +0 -289
- package/angular/10/bundles/lightgallery-angular-10.umd.js.map +0 -1
- package/angular/10/bundles/lightgallery-angular-10.umd.min.js +0 -2
- package/angular/10/bundles/lightgallery-angular-10.umd.min.js.map +0 -1
- package/angular/10/esm2015/lib/lightgallery-angular.component.js +0 -225
- package/angular/10/esm2015/lib/lightgallery-angular.module.js +0 -17
- package/angular/10/esm2015/lib/lightgallery-angular.service.js +0 -14
- package/angular/10/esm2015/lightgallery-angular-10.js +0 -5
- package/angular/10/esm2015/public-api.js +0 -7
- package/angular/10/fesm2015/lightgallery-angular-10.js +0 -261
- package/angular/10/fesm2015/lightgallery-angular-10.js.map +0 -1
- package/angular/10/lib/lightgallery-angular.component.d.ts +0 -39
- package/angular/10/lib/lightgallery-angular.component.d.ts.map +0 -1
- package/angular/10/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/10/lib/lightgallery-angular.module.d.ts.map +0 -1
- package/angular/10/lib/lightgallery-angular.service.d.ts +0 -7
- package/angular/10/lib/lightgallery-angular.service.d.ts.map +0 -1
- package/angular/10/lightgallery-angular-10.d.ts +0 -6
- package/angular/10/lightgallery-angular-10.d.ts.map +0 -1
- package/angular/10/package.json +0 -21
- package/angular/10/public-api.d.ts +0 -4
- package/angular/10/public-api.d.ts.map +0 -1
- package/angular/11/README.md +0 -24
- package/angular/11/bundles/lightgallery-angular-11.umd.js +0 -290
- package/angular/11/bundles/lightgallery-angular-11.umd.js.map +0 -1
- package/angular/11/bundles/lightgallery-angular-11.umd.min.js +0 -2
- package/angular/11/bundles/lightgallery-angular-11.umd.min.js.map +0 -1
- package/angular/11/esm2015/lib/lightgallery-angular.component.js +0 -225
- package/angular/11/esm2015/lib/lightgallery-angular.module.js +0 -18
- package/angular/11/esm2015/lib/lightgallery-angular.service.js +0 -14
- package/angular/11/esm2015/lightgallery-angular-11.js +0 -5
- package/angular/11/esm2015/public-api.js +0 -7
- package/angular/11/fesm2015/lightgallery-angular-11.js +0 -262
- package/angular/11/fesm2015/lightgallery-angular-11.js.map +0 -1
- package/angular/11/lib/lightgallery-angular.component.d.ts +0 -39
- package/angular/11/lib/lightgallery-angular.component.d.ts.map +0 -1
- package/angular/11/lib/lightgallery-angular.module.d.ts +0 -8
- package/angular/11/lib/lightgallery-angular.module.d.ts.map +0 -1
- package/angular/11/lib/lightgallery-angular.service.d.ts +0 -7
- package/angular/11/lib/lightgallery-angular.service.d.ts.map +0 -1
- package/angular/11/lightgallery-angular-11.d.ts +0 -6
- package/angular/11/lightgallery-angular-11.d.ts.map +0 -1
- package/angular/11/package.json +0 -21
- package/angular/11/public-api.d.ts +0 -4
- package/angular/11/public-api.d.ts.map +0 -1
- package/angular/12/README.md +0 -24
- package/angular/12/bundles/lightgallery-angular-12.umd.js +0 -296
- package/angular/12/bundles/lightgallery-angular-12.umd.js.map +0 -1
- package/angular/12/esm2015/lib/lightgallery-angular.component.js +0 -221
- package/angular/12/esm2015/lib/lightgallery-angular.module.js +0 -17
- package/angular/12/esm2015/lib/lightgallery-angular.service.js +0 -14
- package/angular/12/esm2015/lightgallery-angular-12.js +0 -5
- package/angular/12/esm2015/public-api.js +0 -7
- package/angular/12/fesm2015/lightgallery-angular-12.js +0 -258
- package/angular/12/fesm2015/lightgallery-angular-12.js.map +0 -1
- package/angular/12/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/12/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/12/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/12/lightgallery-angular-12.d.ts +0 -5
- package/angular/12/package.json +0 -18
- package/angular/12/public-api.d.ts +0 -3
- package/angular/13/README.md +0 -24
- package/angular/13/esm2020/lib/lightgallery-angular.component.mjs +0 -221
- package/angular/13/esm2020/lib/lightgallery-angular.module.mjs +0 -17
- package/angular/13/esm2020/lib/lightgallery-angular.service.mjs +0 -14
- package/angular/13/esm2020/lightgallery-angular-13.mjs +0 -5
- package/angular/13/esm2020/public-api.mjs +0 -7
- package/angular/13/fesm2015/lightgallery-angular-13.mjs +0 -258
- package/angular/13/fesm2015/lightgallery-angular-13.mjs.map +0 -1
- package/angular/13/fesm2020/lightgallery-angular-13.mjs +0 -258
- package/angular/13/fesm2020/lightgallery-angular-13.mjs.map +0 -1
- package/angular/13/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/13/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/13/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/13/lightgallery-angular-13.d.ts +0 -5
- package/angular/13/package.json +0 -31
- package/angular/13/public-api.d.ts +0 -3
- package/angular/14/README.md +0 -24
- package/angular/14/esm2020/lib/lightgallery-angular.component.mjs +0 -217
- package/angular/14/esm2020/lib/lightgallery-angular.module.mjs +0 -17
- package/angular/14/esm2020/lib/lightgallery-angular.service.mjs +0 -14
- package/angular/14/esm2020/lightgallery-angular-14.mjs +0 -5
- package/angular/14/esm2020/public-api.mjs +0 -7
- package/angular/14/fesm2015/lightgallery-angular-14.mjs +0 -254
- package/angular/14/fesm2015/lightgallery-angular-14.mjs.map +0 -1
- package/angular/14/fesm2020/lightgallery-angular-14.mjs +0 -254
- package/angular/14/fesm2020/lightgallery-angular-14.mjs.map +0 -1
- package/angular/14/index.d.ts +0 -5
- package/angular/14/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/14/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/14/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/14/package.json +0 -31
- package/angular/14/public-api.d.ts +0 -3
- package/angular/15/README.md +0 -24
- package/angular/15/esm2022/lib/lightgallery-angular.component.mjs +0 -218
- package/angular/15/esm2022/lib/lightgallery-angular.module.mjs +0 -18
- package/angular/15/esm2022/lib/lightgallery-angular.service.mjs +0 -15
- package/angular/15/esm2022/lightgallery-angular-15.mjs +0 -5
- package/angular/15/esm2022/public-api.mjs +0 -7
- package/angular/15/fesm2022/lightgallery-angular-15.mjs +0 -254
- package/angular/15/fesm2022/lightgallery-angular-15.mjs.map +0 -1
- package/angular/15/index.d.ts +0 -5
- package/angular/15/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/15/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/15/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/15/package.json +0 -25
- package/angular/15/public-api.d.ts +0 -3
- package/angular/16/README.md +0 -24
- package/angular/16/esm2022/lib/lightgallery-angular.component.mjs +0 -218
- package/angular/16/esm2022/lib/lightgallery-angular.module.mjs +0 -18
- package/angular/16/esm2022/lib/lightgallery-angular.service.mjs +0 -15
- package/angular/16/esm2022/lightgallery-angular-16.mjs +0 -5
- package/angular/16/esm2022/public-api.mjs +0 -7
- package/angular/16/fesm2022/lightgallery-angular-16.mjs +0 -254
- package/angular/16/fesm2022/lightgallery-angular-16.mjs.map +0 -1
- package/angular/16/index.d.ts +0 -5
- package/angular/16/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/16/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/16/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/16/package.json +0 -25
- package/angular/16/public-api.d.ts +0 -3
- package/angular/9/README.md +0 -24
- package/angular/9/bundles/lightgallery-angular-9.umd.js +0 -271
- package/angular/9/bundles/lightgallery-angular-9.umd.js.map +0 -1
- package/angular/9/bundles/lightgallery-angular-9.umd.min.js +0 -2
- package/angular/9/bundles/lightgallery-angular-9.umd.min.js.map +0 -1
- package/angular/9/esm2015/lib/lightgallery-angular.component.js +0 -225
- package/angular/9/esm2015/lib/lightgallery-angular.module.js +0 -17
- package/angular/9/esm2015/lib/lightgallery-angular.service.js +0 -14
- package/angular/9/esm2015/lightgallery-angular-9.js +0 -5
- package/angular/9/esm2015/public-api.js +0 -7
- package/angular/9/esm5/lib/lightgallery-angular.component.js +0 -228
- package/angular/9/esm5/lib/lightgallery-angular.module.js +0 -21
- package/angular/9/esm5/lib/lightgallery-angular.service.js +0 -17
- package/angular/9/esm5/lightgallery-angular-9.js +0 -5
- package/angular/9/esm5/public-api.js +0 -7
- package/angular/9/fesm2015/lightgallery-angular-9.js +0 -261
- package/angular/9/fesm2015/lightgallery-angular-9.js.map +0 -1
- package/angular/9/fesm5/lightgallery-angular-9.js +0 -268
- package/angular/9/fesm5/lightgallery-angular-9.js.map +0 -1
- package/angular/9/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/9/lib/lightgallery-angular.module.d.ts +0 -6
- package/angular/9/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/9/lightgallery-angular-9.d.ts +0 -5
- package/angular/9/package.json +0 -23
- package/angular/9/public-api.d.ts +0 -3
- package/angular/README.md +0 -24
- package/angular/esm2022/lib/lightgallery-angular.component.mjs +0 -218
- package/angular/esm2022/lib/lightgallery-angular.module.mjs +0 -18
- package/angular/esm2022/lib/lightgallery-angular.service.mjs +0 -15
- package/angular/esm2022/lightgallery-angular.mjs +0 -5
- package/angular/esm2022/public-api.mjs +0 -7
- package/angular/fesm2022/lightgallery-angular.mjs +0 -254
- package/angular/fesm2022/lightgallery-angular.mjs.map +0 -1
- package/angular/index.d.ts +0 -5
- package/angular/lib/lightgallery-angular.component.d.ts +0 -38
- package/angular/lib/lightgallery-angular.module.d.ts +0 -7
- package/angular/lib/lightgallery-angular.service.d.ts +0 -6
- package/angular/package.json +0 -25
- package/angular/public-api.d.ts +0 -3
- package/css/lg-fullscreen.css +0 -8
- package/css/lg-fullscreen.css.map +0 -1
- package/css/lg-share.css.map +0 -1
- package/css/lg-thumbnail.css.map +0 -1
- package/css/lg-transitions.css.map +0 -1
- package/css/lg-zoom.css.map +0 -1
- package/css/lightgallery-bundle.css.map +0 -1
- package/css/lightgallery-bundle.min.css +0 -1
- package/css/lightgallery-core.css.map +0 -1
- package/css/lightgallery.css.map +0 -1
- package/fonts/lg.svg +0 -54
- package/fonts/lg.ttf +0 -0
- package/fonts/lg.woff +0 -0
- package/fonts/lg.woff2 +0 -0
- package/lib/index.js +0 -8
- package/lib/index.js.map +0 -1
- package/lib/lg-events.js +0 -37
- package/lib/lg-events.js.map +0 -1
- package/lib/lg-plugin.js +0 -13
- package/lib/lg-plugin.js.map +0 -1
- package/lib/lg-settings.js +0 -83
- package/lib/lg-settings.js.map +0 -1
- package/lib/lg-utils.js +0 -328
- package/lib/lg-utils.js.map +0 -1
- package/lib/lgQuery.js +0 -385
- package/lib/lgQuery.js.map +0 -1
- package/lib/lightgallery.js +0 -1949
- package/lib/lightgallery.js.map +0 -1
- package/lib/plugins/autoplay/lg-autoplay-settings.js +0 -16
- package/lib/plugins/autoplay/lg-autoplay-settings.js.map +0 -1
- package/lib/plugins/autoplay/lg-autoplay.js +0 -184
- package/lib/plugins/autoplay/lg-autoplay.js.map +0 -1
- package/lib/plugins/comment/lg-comment-settings.js +0 -17
- package/lib/plugins/comment/lg-comment-settings.js.map +0 -1
- package/lib/plugins/comment/lg-comment.js +0 -140
- package/lib/plugins/comment/lg-comment.js.map +0 -1
- package/lib/plugins/fullscreen/lg-fullscreen-settings.js +0 -10
- package/lib/plugins/fullscreen/lg-fullscreen-settings.js.map +0 -1
- package/lib/plugins/fullscreen/lg-fullscreen.js +0 -108
- package/lib/plugins/fullscreen/lg-fullscreen.js.map +0 -1
- package/lib/plugins/hash/lg-hash-settings.js +0 -9
- package/lib/plugins/hash/lg-hash-settings.js.map +0 -1
- package/lib/plugins/hash/lg-hash.js +0 -139
- package/lib/plugins/hash/lg-hash.js.map +0 -1
- package/lib/plugins/mediumZoom/lg-medium-zoom-settings.js +0 -9
- package/lib/plugins/mediumZoom/lg-medium-zoom-settings.js.map +0 -1
- package/lib/plugins/mediumZoom/lg-medium-zoom.js +0 -73
- package/lib/plugins/mediumZoom/lg-medium-zoom.js.map +0 -1
- package/lib/plugins/pager/lg-pager-settings.js +0 -7
- package/lib/plugins/pager/lg-pager-settings.js.map +0 -1
- package/lib/plugins/pager/lg-pager.js +0 -82
- package/lib/plugins/pager/lg-pager.js.map +0 -1
- package/lib/plugins/relativeCaption/lg-relative-caption-settings.js +0 -7
- package/lib/plugins/relativeCaption/lg-relative-caption-settings.js.map +0 -1
- package/lib/plugins/relativeCaption/lg-relative-caption.js +0 -97
- package/lib/plugins/relativeCaption/lg-relative-caption.js.map +0 -1
- package/lib/plugins/rotate/lg-rotate-settings.js +0 -18
- package/lib/plugins/rotate/lg-rotate-settings.js.map +0 -1
- package/lib/plugins/rotate/lg-rotate.js +0 -206
- package/lib/plugins/rotate/lg-rotate.js.map +0 -1
- package/lib/plugins/share/lg-fb-share-utils.js +0 -10
- package/lib/plugins/share/lg-fb-share-utils.js.map +0 -1
- package/lib/plugins/share/lg-pinterest-share-utils.js +0 -17
- package/lib/plugins/share/lg-pinterest-share-utils.js.map +0 -1
- package/lib/plugins/share/lg-share-settings.js +0 -15
- package/lib/plugins/share/lg-share-settings.js.map +0 -1
- package/lib/plugins/share/lg-share.js +0 -130
- package/lib/plugins/share/lg-share.js.map +0 -1
- package/lib/plugins/share/lg-twitter-share-utils.js +0 -11
- package/lib/plugins/share/lg-twitter-share-utils.js.map +0 -1
- package/lib/plugins/share/types.js +0 -3
- package/lib/plugins/share/types.js.map +0 -1
- package/lib/plugins/thumbnail/lg-thumbnail-settings.js +0 -23
- package/lib/plugins/thumbnail/lg-thumbnail-settings.js.map +0 -1
- package/lib/plugins/thumbnail/lg-thumbnail.js +0 -414
- package/lib/plugins/thumbnail/lg-thumbnail.js.map +0 -1
- package/lib/plugins/video/lg-video-settings.js +0 -15
- package/lib/plugins/video/lg-video-settings.js.map +0 -1
- package/lib/plugins/video/lg-video-utils.js +0 -84
- package/lib/plugins/video/lg-video-utils.js.map +0 -1
- package/lib/plugins/video/lg-video.js +0 -411
- package/lib/plugins/video/lg-video.js.map +0 -1
- package/lib/plugins/video/types.js +0 -3
- package/lib/plugins/video/types.js.map +0 -1
- package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail-settings.js +0 -8
- package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail-settings.js.map +0 -1
- package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail.js +0 -122
- package/lib/plugins/vimeoThumbnail/lg-vimeo-thumbnail.js.map +0 -1
- package/lib/plugins/zoom/lg-zoom-settings.js +0 -21
- package/lib/plugins/zoom/lg-zoom-settings.js.map +0 -1
- package/lib/plugins/zoom/lg-zoom.js +0 -909
- package/lib/plugins/zoom/lg-zoom.js.map +0 -1
- package/lib/types.js +0 -3
- package/lib/types.js.map +0 -1
- package/lightgallery-2.9.0.tgz +0 -0
- package/lightgallery.es5.js +0 -2786
- package/lightgallery.es5.js.map +0 -1
- package/lightgallery.min.js +0 -8
- package/lightgallery.umd.js +0 -2794
- package/lightgallery.umd.js.map +0 -1
- package/lit/custom-elements.json +0 -82
- package/lit/lightgallery.esm.js +0 -59
- package/lit/lightgallery.umd.js +0 -37
- package/lit/package.json +0 -8
- package/plugins/autoplay/lg-autoplay.es5.js +0 -250
- package/plugins/autoplay/lg-autoplay.es5.js.map +0 -1
- package/plugins/autoplay/lg-autoplay.min.js +0 -8
- package/plugins/autoplay/lg-autoplay.umd.js +0 -258
- package/plugins/autoplay/lg-autoplay.umd.js.map +0 -1
- package/plugins/autoplay/package.json +0 -7
- package/plugins/comment/lg-comment.es5.js +0 -205
- package/plugins/comment/lg-comment.es5.js.map +0 -1
- package/plugins/comment/lg-comment.min.js +0 -8
- package/plugins/comment/lg-comment.umd.js +0 -213
- package/plugins/comment/lg-comment.umd.js.map +0 -1
- package/plugins/comment/package.json +0 -7
- package/plugins/fullscreen/lg-fullscreen.es5.js +0 -135
- package/plugins/fullscreen/lg-fullscreen.es5.js.map +0 -1
- package/plugins/fullscreen/lg-fullscreen.min.js +0 -8
- package/plugins/fullscreen/lg-fullscreen.umd.js +0 -143
- package/plugins/fullscreen/lg-fullscreen.umd.js.map +0 -1
- package/plugins/fullscreen/package.json +0 -7
- package/plugins/hash/lg-hash-settings.d.ts +0 -16
- package/plugins/hash/lg-hash.es5.js +0 -198
- package/plugins/hash/lg-hash.es5.js.map +0 -1
- package/plugins/hash/lg-hash.min.js +0 -8
- package/plugins/hash/lg-hash.umd.js +0 -206
- package/plugins/hash/lg-hash.umd.js.map +0 -1
- package/plugins/hash/package.json +0 -7
- package/plugins/mediumZoom/lg-medium-zoom.es5.js +0 -132
- package/plugins/mediumZoom/lg-medium-zoom.es5.js.map +0 -1
- package/plugins/mediumZoom/lg-medium-zoom.min.js +0 -8
- package/plugins/mediumZoom/lg-medium-zoom.umd.js +0 -140
- package/plugins/mediumZoom/lg-medium-zoom.umd.js.map +0 -1
- package/plugins/mediumZoom/package.json +0 -7
- package/plugins/pager/lg-pager.es5.js +0 -139
- package/plugins/pager/lg-pager.es5.js.map +0 -1
- package/plugins/pager/lg-pager.min.js +0 -8
- package/plugins/pager/lg-pager.umd.js +0 -147
- package/plugins/pager/lg-pager.umd.js.map +0 -1
- package/plugins/pager/package.json +0 -7
- package/plugins/relativeCaption/lg-relative-caption.es5.js +0 -154
- package/plugins/relativeCaption/lg-relative-caption.es5.js.map +0 -1
- package/plugins/relativeCaption/lg-relative-caption.min.js +0 -8
- package/plugins/relativeCaption/lg-relative-caption.umd.js +0 -162
- package/plugins/relativeCaption/lg-relative-caption.umd.js.map +0 -1
- package/plugins/relativeCaption/package.json +0 -7
- package/plugins/rotate/lg-rotate.es5.js +0 -274
- package/plugins/rotate/lg-rotate.es5.js.map +0 -1
- package/plugins/rotate/lg-rotate.min.js +0 -8
- package/plugins/rotate/lg-rotate.umd.js +0 -282
- package/plugins/rotate/lg-rotate.umd.js.map +0 -1
- package/plugins/rotate/package.json +0 -7
- package/plugins/share/lg-share.d.ts +0 -15
- package/plugins/share/lg-share.es5.js +0 -219
- package/plugins/share/lg-share.es5.js.map +0 -1
- package/plugins/share/lg-share.min.js +0 -8
- package/plugins/share/lg-share.umd.js +0 -227
- package/plugins/share/lg-share.umd.js.map +0 -1
- package/plugins/share/lg-twitter-share-utils.d.ts +0 -2
- package/plugins/share/package.json +0 -7
- package/plugins/thumbnail/lg-thumbnail.d.ts +0 -48
- package/plugins/thumbnail/lg-thumbnail.es5.js +0 -487
- package/plugins/thumbnail/lg-thumbnail.es5.js.map +0 -1
- package/plugins/thumbnail/lg-thumbnail.min.js +0 -8
- package/plugins/thumbnail/lg-thumbnail.umd.js +0 -495
- package/plugins/thumbnail/lg-thumbnail.umd.js.map +0 -1
- package/plugins/thumbnail/package.json +0 -7
- package/plugins/video/lg-video-utils.d.ts +0 -10
- package/plugins/video/lg-video.es5.js +0 -545
- package/plugins/video/lg-video.es5.js.map +0 -1
- package/plugins/video/lg-video.min.js +0 -8
- package/plugins/video/lg-video.umd.js +0 -553
- package/plugins/video/lg-video.umd.js.map +0 -1
- package/plugins/video/package.json +0 -7
- package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js +0 -182
- package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.es5.js.map +0 -1
- package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.min.js +0 -8
- package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js +0 -190
- package/plugins/vimeoThumbnail/lg-vimeo-thumbnail.umd.js.map +0 -1
- package/plugins/vimeoThumbnail/package.json +0 -7
- package/plugins/zoom/lg-zoom.es5.js +0 -980
- package/plugins/zoom/lg-zoom.es5.js.map +0 -1
- package/plugins/zoom/lg-zoom.min.js +0 -8
- package/plugins/zoom/lg-zoom.umd.js +0 -988
- package/plugins/zoom/lg-zoom.umd.js.map +0 -1
- package/plugins/zoom/package.json +0 -7
- package/react/Lightgallery.d.ts +0 -33
- package/react/Lightgallery.es5.js +0 -2988
- package/react/Lightgallery.es5.js.map +0 -1
- package/react/Lightgallery.umd.js +0 -2994
- package/react/Lightgallery.umd.js.map +0 -1
- package/react/package.json +0 -7
- package/scss/_lg-fonts.scss +0 -27
- package/scss/lg-fullscreen.scss +0 -9
- package/vue/LightGallery.vue.d.ts +0 -37
- package/vue/LightGalleryVue.common.js +0 -9343
- package/vue/LightGalleryVue.common.js.map +0 -1
- package/vue/LightGalleryVue.umd.js +0 -9353
- package/vue/LightGalleryVue.umd.js.map +0 -1
- package/vue/LightGalleryVue.umd.min.js +0 -8
- package/vue/LightGalleryVue.umd.min.js.map +0 -1
- package/vue/package.json +0 -7
- /package/{css → dist/css}/lg-medium-zoom.css +0 -0
- /package/{css → dist/css}/lg-medium-zoom.css.map +0 -0
- /package/{css → dist/css}/lg-pager.css +0 -0
- /package/{css → dist/css}/lg-relative-caption.css +0 -0
- /package/{css → dist/css}/lg-relative-caption.css.map +0 -0
- /package/{css → dist/css}/lg-video.css +0 -0
- /package/{css → dist/css}/lg-video.css.map +0 -0
- /package/{images → dist/images}/loading.gif +0 -0
- /package/{scss → dist/scss}/_lg-mixins.scss +0 -0
- /package/{scss → dist/scss}/lg-medium-zoom.scss +0 -0
- /package/{scss → dist/scss}/lg-pager.scss +0 -0
- /package/{scss → dist/scss}/lg-relative-caption.scss +0 -0
- /package/{scss → dist/scss}/lg-transitions.scss +0 -0
- /package/{scss → dist/scss}/lg-video.scss +0 -0
- /package/{scss → dist/scss}/transitions/_index.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-lollipop-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-lollipop.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-rotate-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-rotate.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-cross-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-cross.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-y-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-only-y.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-only.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-cross-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-cross.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver-rev.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew-ver.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-skew.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-vertical-growth.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-slide-vertical.scss +0 -0
- /package/{scss → dist/scss}/transitions/_lg-tube.scss +0 -0
|
@@ -0,0 +1,3800 @@
|
|
|
1
|
+
(function(global, factory) {
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.lightGallery = factory());
|
|
3
|
+
})(this, function() {
|
|
4
|
+
"use strict";/*!
|
|
5
|
+
* lightgallery | 3.0.0-beta.3 | October 1st 2026
|
|
6
|
+
* http://www.lightgalleryjs.com/
|
|
7
|
+
* Copyright (c) 2020 Sachin Neravath;
|
|
8
|
+
* @license GPLv3
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
function getVideoInfo(src, hasHtml5Video) {
|
|
12
|
+
if (!src) {
|
|
13
|
+
return hasHtml5Video ? { html5: true } : void 0;
|
|
14
|
+
}
|
|
15
|
+
const youtube = src.match(
|
|
16
|
+
/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-_%]+)([&|?][\S]*)*/i
|
|
17
|
+
);
|
|
18
|
+
if (youtube) {
|
|
19
|
+
return { youtube: [...youtube] };
|
|
20
|
+
}
|
|
21
|
+
const vimeo = src.match(
|
|
22
|
+
/\/\/(?:www\.)?(?:player\.)?vimeo.com\/(?:video\/)?([0-9a-z\-_]+)(.*)?/i
|
|
23
|
+
);
|
|
24
|
+
if (vimeo) {
|
|
25
|
+
return { vimeo: [...vimeo] };
|
|
26
|
+
}
|
|
27
|
+
const wistia = src.match(
|
|
28
|
+
/https?:\/\/(.+)?(wistia\.com|wi\.st)\/(medias|embed)\/([0-9a-z\-_]+)(.*)/
|
|
29
|
+
);
|
|
30
|
+
if (wistia) {
|
|
31
|
+
return { wistia: [...wistia] };
|
|
32
|
+
}
|
|
33
|
+
return hasHtml5Video ? { html5: true } : void 0;
|
|
34
|
+
}
|
|
35
|
+
function getYouTubePosterUrl(videoInfo) {
|
|
36
|
+
if (!(videoInfo == null ? void 0 : videoInfo.youtube)) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
return `//img.youtube.com/vi/${videoInfo.youtube[1]}/maxresdefault.jpg`;
|
|
40
|
+
}
|
|
41
|
+
function getFacadePoster(item, videoInfo, loadYouTubePoster) {
|
|
42
|
+
if (!videoInfo || videoInfo.html5) {
|
|
43
|
+
return item.poster || void 0;
|
|
44
|
+
}
|
|
45
|
+
return item.poster || (loadYouTubePoster ? getYouTubePosterUrl(videoInfo) : void 0) || item.thumb || void 0;
|
|
46
|
+
}
|
|
47
|
+
const TESTING_LICENSE_KEY = "0000-0000-000-0000";
|
|
48
|
+
const LICENSE_KEY_PREFIX = "LIG";
|
|
49
|
+
const LICENSE_DOCS = "https://www.lightgalleryjs.com/docs/license/";
|
|
50
|
+
function checkLicenseKey(licenseKey) {
|
|
51
|
+
const key = (licenseKey != null ? licenseKey : "").trim();
|
|
52
|
+
if (!key) {
|
|
53
|
+
return {
|
|
54
|
+
level: "error",
|
|
55
|
+
message: `lightGallery: please provide a valid license key. See ${LICENSE_DOCS}`
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (key === TESTING_LICENSE_KEY) {
|
|
59
|
+
return {
|
|
60
|
+
level: "warn",
|
|
61
|
+
message: `lightGallery: ${key} license key is not valid for production use. See ${LICENSE_DOCS}`
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (!key.startsWith(LICENSE_KEY_PREFIX)) {
|
|
65
|
+
return {
|
|
66
|
+
level: "warn",
|
|
67
|
+
message: `lightGallery: this license key is for v1 or v2 and is not valid for v3. Please upgrade to a v3 license. See ${LICENSE_DOCS}`
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
let pageLicenseKey;
|
|
73
|
+
const loggedNotices = /* @__PURE__ */ new Set();
|
|
74
|
+
function setLicenseKey(licenseKey) {
|
|
75
|
+
pageLicenseKey = licenseKey;
|
|
76
|
+
}
|
|
77
|
+
function resolveLicenseKey(instanceKey) {
|
|
78
|
+
const own = (instanceKey != null ? instanceKey : "").trim();
|
|
79
|
+
if (pageLicenseKey !== void 0 && (!own || own === TESTING_LICENSE_KEY)) {
|
|
80
|
+
return pageLicenseKey;
|
|
81
|
+
}
|
|
82
|
+
return instanceKey != null ? instanceKey : TESTING_LICENSE_KEY;
|
|
83
|
+
}
|
|
84
|
+
function takeLicenseNotice(instanceKey) {
|
|
85
|
+
const notice = checkLicenseKey(resolveLicenseKey(instanceKey));
|
|
86
|
+
if (!notice || loggedNotices.has(notice.message)) return null;
|
|
87
|
+
loggedNotices.add(notice.message);
|
|
88
|
+
return notice;
|
|
89
|
+
}
|
|
90
|
+
function formatSlideAnnouncement(options) {
|
|
91
|
+
const base = options.template.replace("{index}", String(options.index)).replace("{total}", String(options.total));
|
|
92
|
+
const caption = (options.caption || "").replace(/\s+/g, " ").trim();
|
|
93
|
+
return caption ? `${base}, ${caption}` : base;
|
|
94
|
+
}
|
|
95
|
+
const SPRING_SETTLE_DAMPING = 1;
|
|
96
|
+
const SPRING_NATURAL_FREQUENCY = 12;
|
|
97
|
+
const DECELERATION_RATE = 0.995;
|
|
98
|
+
function project(velocity, decelerationRate = DECELERATION_RATE) {
|
|
99
|
+
return velocity * decelerationRate / (1 - decelerationRate);
|
|
100
|
+
}
|
|
101
|
+
function stepSpring(state, target, dtMs, {
|
|
102
|
+
dampingRatio = SPRING_SETTLE_DAMPING,
|
|
103
|
+
naturalFrequency = SPRING_NATURAL_FREQUENCY
|
|
104
|
+
} = {}) {
|
|
105
|
+
const t = dtMs / 1e3;
|
|
106
|
+
const w0 = naturalFrequency;
|
|
107
|
+
const zeta = Math.min(dampingRatio, 1);
|
|
108
|
+
const x0 = state.position - target;
|
|
109
|
+
const v0 = state.velocity * 1e3;
|
|
110
|
+
const decay = Math.exp(-zeta * w0 * t);
|
|
111
|
+
let x;
|
|
112
|
+
let v;
|
|
113
|
+
if (zeta < 1) {
|
|
114
|
+
const wd = w0 * Math.sqrt(1 - zeta * zeta);
|
|
115
|
+
const a = x0;
|
|
116
|
+
const b = (v0 + zeta * w0 * x0) / wd;
|
|
117
|
+
const cos = Math.cos(wd * t);
|
|
118
|
+
const sin = Math.sin(wd * t);
|
|
119
|
+
x = decay * (a * cos + b * sin);
|
|
120
|
+
v = decay * ((b * wd - zeta * w0 * a) * cos - (a * wd + zeta * w0 * b) * sin);
|
|
121
|
+
} else {
|
|
122
|
+
const b = v0 + w0 * x0;
|
|
123
|
+
x = decay * (x0 + b * t);
|
|
124
|
+
v = decay * (b - w0 * (x0 + b * t));
|
|
125
|
+
}
|
|
126
|
+
return { position: target + x, velocity: v / 1e3 };
|
|
127
|
+
}
|
|
128
|
+
function isSpringSettled(state, target, restDelta = 0.3, restVelocity = 0.012) {
|
|
129
|
+
return Math.abs(state.position - target) < restDelta && Math.abs(state.velocity) < restVelocity;
|
|
130
|
+
}
|
|
131
|
+
const SWIPE_AXIS_THRESHOLD = 10;
|
|
132
|
+
const FLICK_VELOCITY = 0.5;
|
|
133
|
+
const FLICK_MIN_DISTANCE = 20;
|
|
134
|
+
const VERTICAL_CLOSE_THRESHOLD = 100;
|
|
135
|
+
const VERTICAL_CLOSE_RATIO = 0.4;
|
|
136
|
+
const VERTICAL_CLOSE_MIN_DRAG = 40;
|
|
137
|
+
const SLIDE_EDGE_FRICTION = 0.35;
|
|
138
|
+
function getEdgeFrictionedDelta(deltaX, hasPrev, hasNext, direction = "ltr") {
|
|
139
|
+
const [towardPrev, towardNext] = direction === "rtl" ? [hasNext, hasPrev] : [hasPrev, hasNext];
|
|
140
|
+
if (deltaX > 0 && !towardPrev || deltaX < 0 && !towardNext) {
|
|
141
|
+
return deltaX * SLIDE_EDGE_FRICTION;
|
|
142
|
+
}
|
|
143
|
+
return deltaX;
|
|
144
|
+
}
|
|
145
|
+
function getSwipeAxis(deltaX, deltaY, current) {
|
|
146
|
+
if (current) {
|
|
147
|
+
return current;
|
|
148
|
+
}
|
|
149
|
+
if (Math.abs(deltaX) > SWIPE_AXIS_THRESHOLD) {
|
|
150
|
+
return "horizontal";
|
|
151
|
+
}
|
|
152
|
+
if (Math.abs(deltaY) > SWIPE_AXIS_THRESHOLD) {
|
|
153
|
+
return "vertical";
|
|
154
|
+
}
|
|
155
|
+
return void 0;
|
|
156
|
+
}
|
|
157
|
+
function getHorizontalDragTransforms(deltaX, slideWidth, direction = "ltr") {
|
|
158
|
+
const slideWidthAmount = slideWidth * 15 / 100;
|
|
159
|
+
const gutter = slideWidthAmount - Math.abs(deltaX * 10 / 100);
|
|
160
|
+
const before = `translate3d(${-slideWidth + deltaX - gutter}px, 0px, 0px)`;
|
|
161
|
+
const after = `translate3d(${slideWidth + deltaX + gutter}px, 0px, 0px)`;
|
|
162
|
+
return {
|
|
163
|
+
current: `translate3d(${deltaX}px, 0px, 0px)`,
|
|
164
|
+
// In RTL the prev slide rests to the physical right (lg-rtl.css
|
|
165
|
+
// flips the resting positions the same way).
|
|
166
|
+
prev: direction === "rtl" ? after : before,
|
|
167
|
+
next: direction === "rtl" ? before : after
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function getVerticalDragEffects(deltaY, viewportWidth, viewportHeight) {
|
|
171
|
+
const distance = Math.abs(deltaY);
|
|
172
|
+
const scale = 1 - distance / (viewportWidth * 2);
|
|
173
|
+
return {
|
|
174
|
+
backdropOpacity: 1 - distance / viewportHeight,
|
|
175
|
+
transform: `translate3d(0px, ${deltaY}px, 0px) scale3d(${scale}, ${scale}, 1)`,
|
|
176
|
+
hideUi: distance > VERTICAL_CLOSE_THRESHOLD
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function getSwipeReleaseVerdict({
|
|
180
|
+
deltaX,
|
|
181
|
+
velocityX,
|
|
182
|
+
threshold,
|
|
183
|
+
flickVelocity = FLICK_VELOCITY,
|
|
184
|
+
viewportWidth,
|
|
185
|
+
direction = "ltr"
|
|
186
|
+
}) {
|
|
187
|
+
const distance = Math.abs(deltaX);
|
|
188
|
+
const directionMatches = deltaX !== 0 && Math.sign(velocityX) === Math.sign(deltaX);
|
|
189
|
+
const projected = deltaX + project(velocityX);
|
|
190
|
+
const passes = distance > threshold || distance > FLICK_MIN_DISTANCE && directionMatches && Math.abs(velocityX) > flickVelocity || viewportWidth !== void 0 && distance > FLICK_MIN_DISTANCE && directionMatches && Math.abs(projected) > viewportWidth / 2;
|
|
191
|
+
if (!passes) {
|
|
192
|
+
return "stay";
|
|
193
|
+
}
|
|
194
|
+
const towardNext = direction === "rtl" ? deltaX > 0 : deltaX < 0;
|
|
195
|
+
return towardNext ? "next" : "prev";
|
|
196
|
+
}
|
|
197
|
+
function shouldCloseOnVerticalDrag(deltaY, velocityY, viewportHeight, options) {
|
|
198
|
+
if (!options.closable || !options.swipeToClose || deltaY === 0) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
if (Math.abs(deltaY) < VERTICAL_CLOSE_MIN_DRAG) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const projected = deltaY + project(velocityY);
|
|
205
|
+
return Math.sign(projected) === Math.sign(deltaY) && Math.abs(projected) > VERTICAL_CLOSE_RATIO * viewportHeight;
|
|
206
|
+
}
|
|
207
|
+
function resolveSwipeTarget(verdict, currentIndex, slidesCount, loop) {
|
|
208
|
+
if (verdict === "stay") {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
const touchLoop = loop && slidesCount >= 3;
|
|
212
|
+
if (verdict === "next") {
|
|
213
|
+
if (currentIndex + 1 < slidesCount) {
|
|
214
|
+
return currentIndex + 1;
|
|
215
|
+
}
|
|
216
|
+
return touchLoop ? 0 : null;
|
|
217
|
+
}
|
|
218
|
+
if (currentIndex > 0) {
|
|
219
|
+
return currentIndex - 1;
|
|
220
|
+
}
|
|
221
|
+
return touchLoop ? slidesCount - 1 : null;
|
|
222
|
+
}
|
|
223
|
+
function parseImageSize(lgSize, viewportWidth) {
|
|
224
|
+
if (!lgSize) {
|
|
225
|
+
return void 0;
|
|
226
|
+
}
|
|
227
|
+
let size = lgSize;
|
|
228
|
+
const responsiveSizes = lgSize.split(",");
|
|
229
|
+
if (responsiveSizes[1]) {
|
|
230
|
+
for (let i = 0; i < responsiveSizes.length; i++) {
|
|
231
|
+
const candidate = responsiveSizes[i].trim();
|
|
232
|
+
const responsiveWidth = parseInt(candidate.split("-")[2], 10);
|
|
233
|
+
if (responsiveWidth > viewportWidth) {
|
|
234
|
+
size = candidate;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
if (i === responsiveSizes.length - 1) {
|
|
238
|
+
size = candidate;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const parts = size.trim().split("-");
|
|
243
|
+
const width = parseInt(parts[0], 10);
|
|
244
|
+
const height = parseInt(parts[1], 10);
|
|
245
|
+
if (!Number.isFinite(width) || !Number.isFinite(height)) {
|
|
246
|
+
return void 0;
|
|
247
|
+
}
|
|
248
|
+
return { width, height };
|
|
249
|
+
}
|
|
250
|
+
function fitImageSize(size, containerWidth, containerHeight) {
|
|
251
|
+
const maxWidth = Math.min(containerWidth, size.width);
|
|
252
|
+
const maxHeight = Math.min(containerHeight, size.height);
|
|
253
|
+
const ratio = Math.min(maxWidth / size.width, maxHeight / size.height);
|
|
254
|
+
return { width: size.width * ratio, height: size.height * ratio };
|
|
255
|
+
}
|
|
256
|
+
function isUsableOriginRect(rect) {
|
|
257
|
+
return !!rect && Number.isFinite(rect.left) && Number.isFinite(rect.top) && rect.width > 0 && rect.height > 0;
|
|
258
|
+
}
|
|
259
|
+
const CENTER_CLOSE_SCALE = 0.5;
|
|
260
|
+
function getCenterCloseTransform(scale = CENTER_CLOSE_SCALE) {
|
|
261
|
+
return `translate3d(0, 0, 0) scale3d(${scale}, ${scale}, 1)`;
|
|
262
|
+
}
|
|
263
|
+
function getOriginTransform(input) {
|
|
264
|
+
const { triggerRect, containerRect, top, bottom, imageSize } = input;
|
|
265
|
+
const availableWidth = containerRect.width;
|
|
266
|
+
const availableHeight = containerRect.height - (top + bottom);
|
|
267
|
+
const x = (availableWidth - triggerRect.width) / 2 - triggerRect.left + containerRect.left;
|
|
268
|
+
const y = (availableHeight - triggerRect.height) / 2 - triggerRect.top + top;
|
|
269
|
+
const scaleX = triggerRect.width / imageSize.width;
|
|
270
|
+
const scaleY = triggerRect.height / imageSize.height;
|
|
271
|
+
return `translate3d(${-x}px, ${-y}px, 0) scale3d(${scaleX}, ${scaleY}, 1)`;
|
|
272
|
+
}
|
|
273
|
+
const coreDefaultIcons = {
|
|
274
|
+
close: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M810 664.667l-238-238 238-238-60-60-238 238-238-238-60 60 238 238-238 238 60 60 238-238 238 238z"/></svg>',
|
|
275
|
+
// Three dots for the toolbar's More options menu button.
|
|
276
|
+
more: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><circle cx="232" cy="512" r="80"/><circle cx="512" cy="512" r="80"/><circle cx="792" cy="512" r="80"/></svg>',
|
|
277
|
+
prev: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M426.667 768q17.667 0 30.167-12.5t12.5-30.167q0-18-12.667-30.333l-225.667-225.667h665q17.667 0 30.167-12.5t12.5-30.167-12.5-30.167-30.167-12.5h-665l225.667-225.667q12.667-12.333 12.667-30.333 0-17.667-12.5-30.167t-30.167-12.5q-18 0-30.333 12.333l-298.667 298.667q-12.333 13-12.333 30.333t12.333 30.333l298.667 298.667q12.667 12.333 30.333 12.333z"/></svg>',
|
|
278
|
+
next: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M597.333 768q18 0 30.333-12.333l298.667-298.667q12.333-12.333 12.333-30.333t-12.333-30.333l-298.667-298.667q-12.333-12.333-30.333-12.333-18.333 0-30.5 12.167t-12.167 30.5q0 18 12.333 30.333l226 225.667h-665q-17.667 0-30.167 12.5t-12.5 30.167 12.5 30.167 30.167 12.5h665l-226 225.667q-12.333 12.333-12.333 30.333 0 18.333 12.167 30.5t30.5 12.167z"/></svg>',
|
|
279
|
+
download: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M170 128.667h684v-86h-684v86zM682 384.667l-170-172-170 172h128v426h84v-426h128z"/></svg>',
|
|
280
|
+
maximize: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M793.003 768l-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0l225.835 225.835v-153.003c0-23.552 19.115-42.667 42.667-42.667s42.667 19.115 42.667 42.667v256c0 5.803-1.152 11.307-3.243 16.341s-5.163 9.728-9.216 13.781c-0.043 0.043-0.043 0.043-0.085 0.085-3.925 3.925-8.619 7.083-13.781 9.216-5.035 2.091-10.539 3.243-16.341 3.243h-256c-23.552 0-42.667-19.115-42.667-42.667s19.115-42.667 42.667-42.667zM230.997 85.334l225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835v153.003c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667v-256c0-23.552 19.115-42.667 42.667-42.667h256c23.552 0 42.667 19.115 42.667 42.667s-19.115 42.667-42.667 42.667z"/></svg>',
|
|
281
|
+
minimize: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M700.331 554.667l225.835 225.835c16.683 16.683 16.683 43.691 0 60.331s-43.691 16.683-60.331 0l-225.835-225.835v153.003c0 23.552-19.115 42.667-42.667 42.667s-42.667-19.115-42.667-42.667v-256c0-5.803 1.152-11.307 3.243-16.341s5.163-9.728 9.216-13.781c0.043-0.043 0.043-0.043 0.085-0.085 3.925-3.925 8.619-7.083 13.781-9.216 5.035-2.091 10.539-3.243 16.341-3.243h256c23.552 0 42.667 19.115 42.667 42.667s-19.115 42.667-42.667 42.667zM158.165 12.502l225.835 225.835v-153.003c0-23.552 19.115-42.667 42.667-42.667s42.667 19.115 42.667 42.667v256c0 5.803-1.152 11.307-3.243 16.341s-5.163 9.728-9.216 13.781c-0.043 0.043-0.043 0.043-0.085 0.085-4.096 4.053-8.789 7.125-13.781 9.216-5.035 2.091-10.539 3.243-16.341 3.243h-256c-23.552 0-42.667-19.115-42.667-42.667s19.115-42.667 42.667-42.667h153.003l-225.835-225.835c-16.683-16.683-16.683-43.691 0-60.331s43.691-16.683 60.331 0z"/></svg>'
|
|
282
|
+
};
|
|
283
|
+
var __defProp$1 = Object.defineProperty;
|
|
284
|
+
var __defProps$1 = Object.defineProperties;
|
|
285
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
286
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
287
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
288
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
289
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
290
|
+
var __spreadValues$1 = (a, b) => {
|
|
291
|
+
for (var prop in b || (b = {}))
|
|
292
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
293
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
294
|
+
if (__getOwnPropSymbols$1)
|
|
295
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
296
|
+
if (__propIsEnum$1.call(b, prop))
|
|
297
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
298
|
+
}
|
|
299
|
+
return a;
|
|
300
|
+
};
|
|
301
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
302
|
+
const TOOLBAR_PINNED = Number.POSITIVE_INFINITY;
|
|
303
|
+
const TOOLBAR_DEFAULT_PRIORITY = 20;
|
|
304
|
+
const PRIORITY_BY_CLASS = [
|
|
305
|
+
["lg-close", TOOLBAR_PINNED],
|
|
306
|
+
["lg-share", 30],
|
|
307
|
+
["lg-autoplay-button", 30],
|
|
308
|
+
["lg-download", 30],
|
|
309
|
+
["lg-fullscreen", 20],
|
|
310
|
+
["lg-toggle-thumb", 20],
|
|
311
|
+
["lg-comment-toggle", 20],
|
|
312
|
+
["lg-maximize", 10],
|
|
313
|
+
["lg-rotate-left", 10],
|
|
314
|
+
["lg-rotate-right", 10],
|
|
315
|
+
["lg-flip-hor", 10],
|
|
316
|
+
["lg-flip-ver", 10],
|
|
317
|
+
// Gesture duplicates go first: pinch and double-tap do the same.
|
|
318
|
+
["lg-zoom-in", 0],
|
|
319
|
+
["lg-zoom-out", 0],
|
|
320
|
+
["lg-actual-size", 0]
|
|
321
|
+
];
|
|
322
|
+
function getToolbarItemPriority(classList) {
|
|
323
|
+
const classes = new Set(classList);
|
|
324
|
+
for (const [className, priority] of PRIORITY_BY_CLASS) {
|
|
325
|
+
if (classes.has(className)) {
|
|
326
|
+
return priority;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return TOOLBAR_DEFAULT_PRIORITY;
|
|
330
|
+
}
|
|
331
|
+
function getToolbarOverflow({
|
|
332
|
+
available,
|
|
333
|
+
reserved,
|
|
334
|
+
moreWidth,
|
|
335
|
+
items
|
|
336
|
+
}) {
|
|
337
|
+
if (available <= 0) {
|
|
338
|
+
return [];
|
|
339
|
+
}
|
|
340
|
+
const total = items.reduce((sum, item) => sum + item.width, 0);
|
|
341
|
+
if (reserved + total <= available) {
|
|
342
|
+
return [];
|
|
343
|
+
}
|
|
344
|
+
const candidates = items.map((item, index) => __spreadProps$1(__spreadValues$1({}, item), { index })).filter((item) => item.priority !== TOOLBAR_PINNED).sort((a, b) => a.priority - b.priority || b.index - a.index);
|
|
345
|
+
let used = reserved + moreWidth + total;
|
|
346
|
+
const moved = [];
|
|
347
|
+
for (const item of candidates) {
|
|
348
|
+
if (used <= available) {
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
moved.push(item.index);
|
|
352
|
+
used -= item.width;
|
|
353
|
+
}
|
|
354
|
+
return moved.sort((a, b) => a - b);
|
|
355
|
+
}
|
|
356
|
+
const BACKDROP_CLASS_NAMES = [
|
|
357
|
+
"lg-outer",
|
|
358
|
+
"lg-item",
|
|
359
|
+
"lg-img-wrap",
|
|
360
|
+
"lg-img-rotate"
|
|
361
|
+
];
|
|
362
|
+
function consumeBackdropPress(event) {
|
|
363
|
+
var _a;
|
|
364
|
+
const classList = (_a = event.target) == null ? void 0 : _a.classList;
|
|
365
|
+
if (!classList || !BACKDROP_CLASS_NAMES.some((name) => classList.contains(name))) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
event.preventDefault();
|
|
369
|
+
event.stopPropagation();
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
function onTransitionSettle(element, property, fallbackMs, callback) {
|
|
373
|
+
let settled = false;
|
|
374
|
+
let timer;
|
|
375
|
+
const isOwn = (event) => event.target === element && event.propertyName === property;
|
|
376
|
+
const dispose = () => {
|
|
377
|
+
clearTimeout(timer);
|
|
378
|
+
element.removeEventListener("transitionstart", onStart);
|
|
379
|
+
element.removeEventListener("transitionend", onEnd);
|
|
380
|
+
};
|
|
381
|
+
const settle = () => {
|
|
382
|
+
if (settled) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
settled = true;
|
|
386
|
+
dispose();
|
|
387
|
+
callback();
|
|
388
|
+
};
|
|
389
|
+
const onStart = (event) => {
|
|
390
|
+
if (isOwn(event)) {
|
|
391
|
+
clearTimeout(timer);
|
|
392
|
+
timer = setTimeout(settle, fallbackMs);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const onEnd = (event) => {
|
|
396
|
+
if (isOwn(event)) {
|
|
397
|
+
settle();
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
element.addEventListener("transitionstart", onStart);
|
|
401
|
+
element.addEventListener("transitionend", onEnd);
|
|
402
|
+
timer = setTimeout(settle, fallbackMs);
|
|
403
|
+
return () => {
|
|
404
|
+
settled = true;
|
|
405
|
+
dispose();
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
const DECODE_TIMEOUT_MS = 500;
|
|
409
|
+
function awaitDecode(img, timeoutMs = DECODE_TIMEOUT_MS) {
|
|
410
|
+
if (typeof img.decode !== "function") {
|
|
411
|
+
return Promise.resolve();
|
|
412
|
+
}
|
|
413
|
+
return new Promise((resolve) => {
|
|
414
|
+
let done = false;
|
|
415
|
+
const finish = () => {
|
|
416
|
+
if (!done) {
|
|
417
|
+
done = true;
|
|
418
|
+
clearTimeout(timer);
|
|
419
|
+
resolve();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
423
|
+
img.decode().then(finish, finish);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
const VELOCITY_WINDOW_MS = 100;
|
|
427
|
+
const MIN_DISPLACEMENT = 1;
|
|
428
|
+
const MIN_WINDOW_SPAN_MS = 5;
|
|
429
|
+
function pushVelocitySample(samples, sample, windowMs = VELOCITY_WINDOW_MS) {
|
|
430
|
+
return [...samples.filter((s) => sample.t - s.t <= windowMs), sample];
|
|
431
|
+
}
|
|
432
|
+
function getWindowedVelocity(samples, releaseTime, windowMs = VELOCITY_WINDOW_MS) {
|
|
433
|
+
const recent = samples.filter((s) => releaseTime - s.t <= windowMs);
|
|
434
|
+
if (recent.length < 2) {
|
|
435
|
+
return { x: 0, y: 0 };
|
|
436
|
+
}
|
|
437
|
+
const first = recent[0];
|
|
438
|
+
const last = recent[recent.length - 1];
|
|
439
|
+
const dt = last.t - first.t;
|
|
440
|
+
if (dt < MIN_WINDOW_SPAN_MS) {
|
|
441
|
+
return { x: 0, y: 0 };
|
|
442
|
+
}
|
|
443
|
+
const dx = last.x - first.x;
|
|
444
|
+
const dy = last.y - first.y;
|
|
445
|
+
return {
|
|
446
|
+
x: Math.abs(dx) > MIN_DISPLACEMENT ? dx / dt : 0,
|
|
447
|
+
y: Math.abs(dy) > MIN_DISPLACEMENT ? dy / dt : 0
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
const lGEvents = {
|
|
451
|
+
afterAppendSlide: "lgAfterAppendSlide",
|
|
452
|
+
init: "lgInit",
|
|
453
|
+
hasVideo: "lgHasVideo",
|
|
454
|
+
containerResize: "lgContainerResize",
|
|
455
|
+
updateSlides: "lgUpdateSlides",
|
|
456
|
+
afterAppendSubHtml: "lgAfterAppendSubHtml",
|
|
457
|
+
beforeOpen: "lgBeforeOpen",
|
|
458
|
+
afterOpen: "lgAfterOpen",
|
|
459
|
+
slideItemLoad: "lgSlideItemLoad",
|
|
460
|
+
beforeSlide: "lgBeforeSlide",
|
|
461
|
+
afterSlide: "lgAfterSlide",
|
|
462
|
+
posterClick: "lgPosterClick",
|
|
463
|
+
dragStart: "lgDragStart",
|
|
464
|
+
dragMove: "lgDragMove",
|
|
465
|
+
dragEnd: "lgDragEnd",
|
|
466
|
+
beforeNextSlide: "lgBeforeNextSlide",
|
|
467
|
+
beforePrevSlide: "lgBeforePrevSlide",
|
|
468
|
+
beforeClose: "lgBeforeClose",
|
|
469
|
+
afterClose: "lgAfterClose"
|
|
470
|
+
};
|
|
471
|
+
const lightGalleryCoreSettings = {
|
|
472
|
+
mode: "lg-slide",
|
|
473
|
+
easing: "ease",
|
|
474
|
+
speed: 400,
|
|
475
|
+
licenseKey: "0000-0000-000-0000",
|
|
476
|
+
height: "100%",
|
|
477
|
+
width: "100%",
|
|
478
|
+
addClass: "",
|
|
479
|
+
startClass: "lg-start-zoom",
|
|
480
|
+
backdropDuration: 300,
|
|
481
|
+
container: "",
|
|
482
|
+
startAnimationDuration: 400,
|
|
483
|
+
zoomFromOrigin: true,
|
|
484
|
+
hideBarsDelay: 0,
|
|
485
|
+
showBarsAfter: 1e4,
|
|
486
|
+
slideDelay: 0,
|
|
487
|
+
allowMediaOverlap: false,
|
|
488
|
+
videoMaxSize: "1280-720",
|
|
489
|
+
loadYouTubePoster: true,
|
|
490
|
+
defaultCaptionHeight: 0,
|
|
491
|
+
ariaLabelledby: "",
|
|
492
|
+
ariaDescribedby: "",
|
|
493
|
+
ariaAnnouncements: true,
|
|
494
|
+
resetScrollPosition: true,
|
|
495
|
+
hideScrollbar: false,
|
|
496
|
+
closable: true,
|
|
497
|
+
swipeToClose: true,
|
|
498
|
+
closeOnTap: true,
|
|
499
|
+
showCloseIcon: true,
|
|
500
|
+
showMaximizeIcon: false,
|
|
501
|
+
loop: true,
|
|
502
|
+
escKey: true,
|
|
503
|
+
keyPress: true,
|
|
504
|
+
trapFocus: true,
|
|
505
|
+
controls: true,
|
|
506
|
+
slideEndAnimation: true,
|
|
507
|
+
hideControlOnEnd: false,
|
|
508
|
+
mousewheel: false,
|
|
509
|
+
direction: "ltr",
|
|
510
|
+
getCaptionFromTitleOrAlt: true,
|
|
511
|
+
appendSubHtmlTo: ".lg-sub-html",
|
|
512
|
+
subHtmlSelectorRelative: false,
|
|
513
|
+
preload: 2,
|
|
514
|
+
numberOfSlideItemsInDom: 10,
|
|
515
|
+
selector: "",
|
|
516
|
+
selectWithin: "",
|
|
517
|
+
nextHtml: "",
|
|
518
|
+
prevHtml: "",
|
|
519
|
+
index: 0,
|
|
520
|
+
iframeWidth: "100%",
|
|
521
|
+
iframeHeight: "100%",
|
|
522
|
+
iframeMaxWidth: "100%",
|
|
523
|
+
iframeMaxHeight: "100%",
|
|
524
|
+
download: true,
|
|
525
|
+
counter: true,
|
|
526
|
+
appendCounterTo: ".lg-toolbar",
|
|
527
|
+
swipeThreshold: 50,
|
|
528
|
+
flickVelocity: 0.5,
|
|
529
|
+
pinchToClose: true,
|
|
530
|
+
enableSwipe: true,
|
|
531
|
+
enableDrag: true,
|
|
532
|
+
dynamic: false,
|
|
533
|
+
dynamicEl: [],
|
|
534
|
+
extraProps: [],
|
|
535
|
+
exThumbImage: "",
|
|
536
|
+
toolbarOverflow: true,
|
|
537
|
+
showGestureButtons: true,
|
|
538
|
+
isMobile: void 0,
|
|
539
|
+
mobileSettings: {
|
|
540
|
+
controls: false,
|
|
541
|
+
showCloseIcon: false,
|
|
542
|
+
download: false,
|
|
543
|
+
showGestureButtons: false
|
|
544
|
+
},
|
|
545
|
+
plugins: [],
|
|
546
|
+
strings: {
|
|
547
|
+
closeGallery: "Close gallery",
|
|
548
|
+
toggleMaximize: "Toggle maximize",
|
|
549
|
+
previousSlide: "Previous slide",
|
|
550
|
+
nextSlide: "Next slide",
|
|
551
|
+
download: "Download",
|
|
552
|
+
playVideo: "Play video",
|
|
553
|
+
mediaLoadingFailed: "Oops... Failed to load content...",
|
|
554
|
+
galleryLabel: "Gallery",
|
|
555
|
+
slideAnnouncement: "Image {index} of {total}",
|
|
556
|
+
moreOptions: "More options",
|
|
557
|
+
share: "Share",
|
|
558
|
+
toggleThumbnails: "Toggle thumbnails",
|
|
559
|
+
toggleAutoplay: "Toggle Autoplay",
|
|
560
|
+
toggleFullscreen: "Toggle Fullscreen",
|
|
561
|
+
zoomIn: "Zoom in",
|
|
562
|
+
zoomOut: "Zoom out",
|
|
563
|
+
viewActualSize: "View actual size",
|
|
564
|
+
rotateLeft: "Rotate left",
|
|
565
|
+
rotateRight: "Rotate right",
|
|
566
|
+
flipHorizontal: "Flip horizontal",
|
|
567
|
+
flipVertical: "Flip vertical",
|
|
568
|
+
toggleComments: "Toggle Comments"
|
|
569
|
+
},
|
|
570
|
+
icons: {}
|
|
571
|
+
};
|
|
572
|
+
const schedule = typeof requestAnimationFrame === "function" ? (callback) => requestAnimationFrame(callback) : (callback) => window.setTimeout(callback, 16);
|
|
573
|
+
const cancel = typeof cancelAnimationFrame === "function" ? (handle) => cancelAnimationFrame(handle) : (handle) => window.clearTimeout(handle);
|
|
574
|
+
function toolbarButtons(toolbar, more) {
|
|
575
|
+
return Array.from(toolbar.querySelectorAll(".lg-icon")).filter(
|
|
576
|
+
(button) => {
|
|
577
|
+
var _a;
|
|
578
|
+
return button !== more && !button.closest(".lg-toolbar-menu, .lg-dropdown") && !((_a = button.parentElement) == null ? void 0 : _a.closest(".lg-icon"));
|
|
579
|
+
}
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
function visibleIconMarkup(button) {
|
|
583
|
+
var _a, _b, _c;
|
|
584
|
+
const icons = Array.from(button.querySelectorAll(".lg-ci"));
|
|
585
|
+
if (!icons.length) {
|
|
586
|
+
return (_b = (_a = button.querySelector("svg")) == null ? void 0 : _a.outerHTML) != null ? _b : "";
|
|
587
|
+
}
|
|
588
|
+
const shown = (_c = icons.find(
|
|
589
|
+
(icon) => window.getComputedStyle(icon).display !== "none"
|
|
590
|
+
)) != null ? _c : icons[0];
|
|
591
|
+
return shown.outerHTML;
|
|
592
|
+
}
|
|
593
|
+
class ToolbarOverflow {
|
|
594
|
+
constructor(toolbar, options) {
|
|
595
|
+
this.toolbar = toolbar;
|
|
596
|
+
this.options = options;
|
|
597
|
+
this.menu = null;
|
|
598
|
+
this.frame = 0;
|
|
599
|
+
this.movedSignature = "";
|
|
600
|
+
this.widths = /* @__PURE__ */ new WeakMap();
|
|
601
|
+
this.requestUpdate = () => {
|
|
602
|
+
if (this.frame) {
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
this.frame = schedule(() => {
|
|
606
|
+
this.frame = 0;
|
|
607
|
+
this.update();
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
this.onMoreClick = () => {
|
|
611
|
+
if (this.menu) {
|
|
612
|
+
this.close(true);
|
|
613
|
+
} else {
|
|
614
|
+
this.open();
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
this.onMenuKeydown = (event) => {
|
|
618
|
+
var _a, _b, _c, _d;
|
|
619
|
+
const items = this.items();
|
|
620
|
+
const index = items.indexOf(document.activeElement);
|
|
621
|
+
switch (event.key) {
|
|
622
|
+
case "Escape":
|
|
623
|
+
this.close(true);
|
|
624
|
+
break;
|
|
625
|
+
case "ArrowDown":
|
|
626
|
+
(_a = items[(index + 1) % items.length]) == null ? void 0 : _a.focus();
|
|
627
|
+
break;
|
|
628
|
+
case "ArrowUp":
|
|
629
|
+
(_b = items[(index - 1 + items.length) % items.length]) == null ? void 0 : _b.focus();
|
|
630
|
+
break;
|
|
631
|
+
case "Home":
|
|
632
|
+
(_c = items[0]) == null ? void 0 : _c.focus();
|
|
633
|
+
break;
|
|
634
|
+
case "End":
|
|
635
|
+
(_d = items[items.length - 1]) == null ? void 0 : _d.focus();
|
|
636
|
+
break;
|
|
637
|
+
case "ArrowLeft":
|
|
638
|
+
case "ArrowRight":
|
|
639
|
+
break;
|
|
640
|
+
case "Tab":
|
|
641
|
+
this.close(false);
|
|
642
|
+
return;
|
|
643
|
+
default:
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
event.preventDefault();
|
|
647
|
+
event.stopPropagation();
|
|
648
|
+
};
|
|
649
|
+
this.onDocumentPointerDown = (event) => {
|
|
650
|
+
var _a;
|
|
651
|
+
const target = event.target;
|
|
652
|
+
if (target && (((_a = this.menu) == null ? void 0 : _a.contains(target)) || this.more.contains(target))) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
consumeBackdropPress(event);
|
|
656
|
+
this.close(false);
|
|
657
|
+
};
|
|
658
|
+
const more = document.createElement("button");
|
|
659
|
+
more.type = "button";
|
|
660
|
+
more.id = options.id;
|
|
661
|
+
more.className = "lg-more lg-icon";
|
|
662
|
+
more.hidden = true;
|
|
663
|
+
more.setAttribute("aria-label", options.label);
|
|
664
|
+
more.setAttribute("aria-haspopup", "menu");
|
|
665
|
+
more.setAttribute("aria-expanded", "false");
|
|
666
|
+
more.addEventListener("click", this.onMoreClick);
|
|
667
|
+
const close = toolbar.querySelector(".lg-close");
|
|
668
|
+
if (close) {
|
|
669
|
+
close.insertAdjacentElement("afterend", more);
|
|
670
|
+
} else {
|
|
671
|
+
toolbar.insertBefore(more, toolbar.firstChild);
|
|
672
|
+
}
|
|
673
|
+
this.more = more;
|
|
674
|
+
if (typeof ResizeObserver === "function") {
|
|
675
|
+
this.resizeObserver = new ResizeObserver(this.requestUpdate);
|
|
676
|
+
this.resizeObserver.observe(toolbar);
|
|
677
|
+
}
|
|
678
|
+
if (typeof MutationObserver === "function") {
|
|
679
|
+
this.mutationObserver = new MutationObserver((records) => {
|
|
680
|
+
if (records.some(
|
|
681
|
+
(record) => {
|
|
682
|
+
var _a, _b;
|
|
683
|
+
return !((_b = (_a = record.target).closest) == null ? void 0 : _b.call(
|
|
684
|
+
_a,
|
|
685
|
+
".lg-toolbar-menu"
|
|
686
|
+
));
|
|
687
|
+
}
|
|
688
|
+
)) {
|
|
689
|
+
this.requestUpdate();
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
this.mutationObserver.observe(toolbar, {
|
|
693
|
+
childList: true,
|
|
694
|
+
subtree: true
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
/** Re-measure the row and move buttons in or out of the menu. */
|
|
699
|
+
update() {
|
|
700
|
+
var _a, _b;
|
|
701
|
+
const buttons = toolbarButtons(this.toolbar, this.more);
|
|
702
|
+
buttons.forEach((button) => {
|
|
703
|
+
if (!button.hasAttribute("data-lg-overflow")) {
|
|
704
|
+
const width = button.offsetWidth;
|
|
705
|
+
if (width) {
|
|
706
|
+
this.widths.set(button, width);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
const fallback = (_a = buttons.map((button) => this.widths.get(button)).find((width) => !!width)) != null ? _a : 0;
|
|
711
|
+
const counter = this.toolbar.querySelector(".lg-counter");
|
|
712
|
+
const moved = getToolbarOverflow({
|
|
713
|
+
available: this.toolbar.clientWidth,
|
|
714
|
+
reserved: counter ? counter.offsetWidth : 0,
|
|
715
|
+
moreWidth: (_b = this.widths.get(this.more)) != null ? _b : fallback,
|
|
716
|
+
items: buttons.map((button) => {
|
|
717
|
+
var _a2;
|
|
718
|
+
return {
|
|
719
|
+
width: (_a2 = this.widths.get(button)) != null ? _a2 : fallback,
|
|
720
|
+
priority: getToolbarItemPriority(Array.from(button.classList))
|
|
721
|
+
};
|
|
722
|
+
})
|
|
723
|
+
});
|
|
724
|
+
const overflow = new Set(moved);
|
|
725
|
+
buttons.forEach((button, index) => {
|
|
726
|
+
if (overflow.has(index)) {
|
|
727
|
+
button.setAttribute("data-lg-overflow", "");
|
|
728
|
+
} else {
|
|
729
|
+
button.removeAttribute("data-lg-overflow");
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
this.more.hidden = overflow.size === 0;
|
|
733
|
+
if (!this.more.hidden && this.more.offsetWidth) {
|
|
734
|
+
this.widths.set(this.more, this.more.offsetWidth);
|
|
735
|
+
}
|
|
736
|
+
const signature = `${buttons.length}:${moved.join(",")}`;
|
|
737
|
+
const changed = signature !== this.movedSignature;
|
|
738
|
+
this.movedSignature = signature;
|
|
739
|
+
if (!overflow.size) {
|
|
740
|
+
this.close(false);
|
|
741
|
+
} else if (this.menu && changed) {
|
|
742
|
+
this.renderMenu();
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
/** Close the menu; optionally hand focus back to the More button. */
|
|
746
|
+
close(returnFocus) {
|
|
747
|
+
if (!this.menu) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
this.menu.removeEventListener("keydown", this.onMenuKeydown);
|
|
751
|
+
this.menu.remove();
|
|
752
|
+
this.menu = null;
|
|
753
|
+
document.removeEventListener(
|
|
754
|
+
"pointerdown",
|
|
755
|
+
this.onDocumentPointerDown,
|
|
756
|
+
true
|
|
757
|
+
);
|
|
758
|
+
this.more.setAttribute("aria-expanded", "false");
|
|
759
|
+
this.more.removeAttribute("aria-controls");
|
|
760
|
+
if (returnFocus) {
|
|
761
|
+
this.more.focus();
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
destroy() {
|
|
765
|
+
var _a, _b;
|
|
766
|
+
this.close(false);
|
|
767
|
+
cancel(this.frame);
|
|
768
|
+
(_a = this.resizeObserver) == null ? void 0 : _a.disconnect();
|
|
769
|
+
(_b = this.mutationObserver) == null ? void 0 : _b.disconnect();
|
|
770
|
+
toolbarButtons(this.toolbar, this.more).forEach(
|
|
771
|
+
(button) => button.removeAttribute("data-lg-overflow")
|
|
772
|
+
);
|
|
773
|
+
this.more.remove();
|
|
774
|
+
}
|
|
775
|
+
open() {
|
|
776
|
+
var _a;
|
|
777
|
+
const menu = document.createElement("div");
|
|
778
|
+
menu.id = `${this.options.id}-menu`;
|
|
779
|
+
menu.className = "lg-toolbar-menu";
|
|
780
|
+
menu.setAttribute("role", "menu");
|
|
781
|
+
menu.setAttribute("aria-label", this.options.label);
|
|
782
|
+
menu.addEventListener("keydown", this.onMenuKeydown);
|
|
783
|
+
this.menu = menu;
|
|
784
|
+
this.renderMenu();
|
|
785
|
+
this.toolbar.appendChild(menu);
|
|
786
|
+
this.more.setAttribute("aria-expanded", "true");
|
|
787
|
+
this.more.setAttribute("aria-controls", menu.id);
|
|
788
|
+
document.addEventListener(
|
|
789
|
+
"pointerdown",
|
|
790
|
+
this.onDocumentPointerDown,
|
|
791
|
+
true
|
|
792
|
+
);
|
|
793
|
+
(_a = this.items()[0]) == null ? void 0 : _a.focus();
|
|
794
|
+
}
|
|
795
|
+
renderMenu() {
|
|
796
|
+
const menu = this.menu;
|
|
797
|
+
if (!menu) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
menu.textContent = "";
|
|
801
|
+
toolbarButtons(this.toolbar, this.more).filter((button) => button.hasAttribute("data-lg-overflow")).forEach((button) => {
|
|
802
|
+
var _a;
|
|
803
|
+
const item = document.createElement("button");
|
|
804
|
+
item.type = "button";
|
|
805
|
+
item.className = "lg-toolbar-menu-item";
|
|
806
|
+
item.setAttribute("role", "menuitem");
|
|
807
|
+
const icon = document.createElement("span");
|
|
808
|
+
icon.className = "lg-toolbar-menu-icon";
|
|
809
|
+
icon.setAttribute("aria-hidden", "true");
|
|
810
|
+
icon.innerHTML = visibleIconMarkup(button);
|
|
811
|
+
const label = document.createElement("span");
|
|
812
|
+
label.textContent = (_a = button.getAttribute("aria-label")) != null ? _a : "";
|
|
813
|
+
item.append(icon, label);
|
|
814
|
+
item.addEventListener("click", () => {
|
|
815
|
+
this.close(true);
|
|
816
|
+
button.click();
|
|
817
|
+
});
|
|
818
|
+
menu.appendChild(item);
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
items() {
|
|
822
|
+
return this.menu ? Array.from(
|
|
823
|
+
this.menu.querySelectorAll('[role="menuitem"]')
|
|
824
|
+
) : [];
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
const ICON_TARGETS = [
|
|
828
|
+
{ selector: ".lg-close", names: ["close"] },
|
|
829
|
+
{ selector: ".lg-prev", names: ["prev"] },
|
|
830
|
+
{ selector: ".lg-next", names: ["next"] },
|
|
831
|
+
{ selector: ".lg-download", names: ["download"] },
|
|
832
|
+
{ selector: ".lg-more", names: ["more"] },
|
|
833
|
+
// Shown while `.lg-inline` (prompting maximize) / after maximizing.
|
|
834
|
+
{ selector: ".lg-maximize", names: ["maximize", "minimize"] },
|
|
835
|
+
// The actual-size button's CLASS toggles between the two zoom
|
|
836
|
+
// classes as the zoom state changes (2.x swapped the glyph that
|
|
837
|
+
// way), it carries BOTH zoom icons and the class picks one in
|
|
838
|
+
// CSS. Listed before the class-based zoom targets so the id match
|
|
839
|
+
// claims it first (the pass skips already-processed elements).
|
|
840
|
+
{ selector: '[id^="lg-actual-size-"]', names: ["zoomIn", "zoomOut"] },
|
|
841
|
+
{ selector: ".lg-zoom-in", names: ["zoomIn"] },
|
|
842
|
+
{ selector: ".lg-zoom-out", names: ["zoomOut"] },
|
|
843
|
+
// No '.lg-actual-size' target: vanilla's actual-size BUTTON never
|
|
844
|
+
// carries that class (it rides the zoom classes above; the outer
|
|
845
|
+
// gets `lg-actual-size` as a zoom-state class after build). The
|
|
846
|
+
// `actualSize` name serves the framework ports' static button.
|
|
847
|
+
{ selector: ".lg-rotate-left", names: ["rotateLeft"] },
|
|
848
|
+
{ selector: ".lg-rotate-right", names: ["rotateRight"] },
|
|
849
|
+
{ selector: ".lg-flip-hor", names: ["flipHorizontal"] },
|
|
850
|
+
{ selector: ".lg-flip-ver", names: ["flipVertical"] },
|
|
851
|
+
{ selector: ".lg-share", names: ["share"] },
|
|
852
|
+
{ selector: ".lg-share-facebook .lg-icon", names: ["shareFacebook"] },
|
|
853
|
+
{ selector: ".lg-share-twitter .lg-icon", names: ["shareX"] },
|
|
854
|
+
{ selector: ".lg-share-pinterest .lg-icon", names: ["sharePinterest"] },
|
|
855
|
+
// Shown while idle (prompting play) / while `.lg-show-autoplay`.
|
|
856
|
+
{
|
|
857
|
+
selector: ".lg-autoplay-button",
|
|
858
|
+
names: ["autoplayPlay", "autoplayPause"]
|
|
859
|
+
},
|
|
860
|
+
// Shown while windowed / while `.lg-fullscreen-on`.
|
|
861
|
+
{ selector: ".lg-fullscreen", names: ["fullscreen", "fullscreenExit"] },
|
|
862
|
+
{ selector: ".lg-comment-toggle", names: ["comment"] },
|
|
863
|
+
{ selector: ".lg-comment-close", names: ["commentClose"] },
|
|
864
|
+
{ selector: ".lg-toggle-thumb", names: ["toggleThumbnails"] }
|
|
865
|
+
];
|
|
866
|
+
const toKebab = (name) => name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
|
|
867
|
+
function getCustomIconMarkup(icons, names) {
|
|
868
|
+
if (!names.every((name) => icons[name])) {
|
|
869
|
+
return "";
|
|
870
|
+
}
|
|
871
|
+
return names.map(
|
|
872
|
+
(name) => `<span class="lg-ci lg-ci-${toKebab(
|
|
873
|
+
name
|
|
874
|
+
)}" aria-hidden="true">${icons[name]}</span>`
|
|
875
|
+
).join("");
|
|
876
|
+
}
|
|
877
|
+
function applyCustomIcons(container, defaults, overrides) {
|
|
878
|
+
ICON_TARGETS.forEach(({ selector, names }) => {
|
|
879
|
+
const source = overrides && names.every((name) => overrides[name]) ? overrides : defaults;
|
|
880
|
+
const markup = getCustomIconMarkup(source, names);
|
|
881
|
+
if (!markup) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
container.querySelectorAll(selector).forEach((element) => {
|
|
885
|
+
if (element.classList.contains("lg-icon-custom")) {
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
element.classList.add("lg-icon-custom");
|
|
889
|
+
element.insertAdjacentHTML("afterbegin", markup);
|
|
890
|
+
});
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
const MAX_FRAME_MS = 64;
|
|
894
|
+
function runSprings(tracks, onFrame, onDone) {
|
|
895
|
+
let raf = 0;
|
|
896
|
+
let last = Date.now();
|
|
897
|
+
const states = tracks.map((t) => ({
|
|
898
|
+
position: t.from,
|
|
899
|
+
velocity: t.velocity
|
|
900
|
+
}));
|
|
901
|
+
const frame = () => {
|
|
902
|
+
const now = Date.now();
|
|
903
|
+
const dt = Math.min(Math.max(now - last, 0), MAX_FRAME_MS);
|
|
904
|
+
last = now;
|
|
905
|
+
let settled = true;
|
|
906
|
+
tracks.forEach((t, i) => {
|
|
907
|
+
states[i] = stepSpring(states[i], t.target, dt, t);
|
|
908
|
+
if (!isSpringSettled(states[i], t.target)) {
|
|
909
|
+
settled = false;
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
if (settled) {
|
|
913
|
+
onFrame(tracks.map((t) => t.target));
|
|
914
|
+
onDone == null ? void 0 : onDone();
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
onFrame(states.map((s) => s.position));
|
|
918
|
+
raf = requestAnimationFrame(frame);
|
|
919
|
+
};
|
|
920
|
+
raf = requestAnimationFrame(frame);
|
|
921
|
+
return () => cancelAnimationFrame(raf);
|
|
922
|
+
}
|
|
923
|
+
const _lgQuery = class _lgQuery2 {
|
|
924
|
+
constructor(selector) {
|
|
925
|
+
this.cssVenderPrefixes = [
|
|
926
|
+
"TransitionDuration",
|
|
927
|
+
"TransitionTimingFunction",
|
|
928
|
+
"Transform",
|
|
929
|
+
"Transition"
|
|
930
|
+
];
|
|
931
|
+
this.selector = this._getSelector(selector);
|
|
932
|
+
this.firstElement = this._getFirstEl();
|
|
933
|
+
return this;
|
|
934
|
+
}
|
|
935
|
+
static generateUUID() {
|
|
936
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
|
937
|
+
/[xy]/g,
|
|
938
|
+
function(c) {
|
|
939
|
+
const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
|
|
940
|
+
return v.toString(16);
|
|
941
|
+
}
|
|
942
|
+
);
|
|
943
|
+
}
|
|
944
|
+
_getSelector(selector, context = document) {
|
|
945
|
+
if (typeof selector !== "string") {
|
|
946
|
+
return selector;
|
|
947
|
+
}
|
|
948
|
+
context = context || document;
|
|
949
|
+
const fl = selector.substring(0, 1);
|
|
950
|
+
if (fl === "#") {
|
|
951
|
+
return context.querySelector(selector);
|
|
952
|
+
} else {
|
|
953
|
+
return context.querySelectorAll(selector);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
_each(func) {
|
|
957
|
+
if (!this.selector) {
|
|
958
|
+
return this;
|
|
959
|
+
}
|
|
960
|
+
if (this.selector.length !== void 0) {
|
|
961
|
+
[].forEach.call(this.selector, func);
|
|
962
|
+
} else {
|
|
963
|
+
func(this.selector, 0);
|
|
964
|
+
}
|
|
965
|
+
return this;
|
|
966
|
+
}
|
|
967
|
+
_setCssVendorPrefix(el, cssProperty, value) {
|
|
968
|
+
if (cssProperty.startsWith("--")) {
|
|
969
|
+
el.style.setProperty(cssProperty, String(value));
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const property = cssProperty.replace(/-([a-z])/gi, function(s, group1) {
|
|
973
|
+
return group1.toUpperCase();
|
|
974
|
+
});
|
|
975
|
+
if (this.cssVenderPrefixes.indexOf(property) !== -1) {
|
|
976
|
+
el.style[property.charAt(0).toLowerCase() + property.slice(1)] = value;
|
|
977
|
+
el.style["webkit" + property] = value;
|
|
978
|
+
el.style["moz" + property] = value;
|
|
979
|
+
el.style["ms" + property] = value;
|
|
980
|
+
el.style["o" + property] = value;
|
|
981
|
+
} else {
|
|
982
|
+
el.style[property] = value;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
_getFirstEl() {
|
|
986
|
+
if (this.selector && this.selector.length !== void 0) {
|
|
987
|
+
return this.selector[0];
|
|
988
|
+
} else {
|
|
989
|
+
return this.selector;
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
isEventMatched(event, eventName) {
|
|
993
|
+
const eventNamespace = eventName.split(".");
|
|
994
|
+
return event.split(".").filter((e) => e).every((e) => {
|
|
995
|
+
return eventNamespace.indexOf(e) !== -1;
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
attr(attr, value) {
|
|
999
|
+
if (value === void 0) {
|
|
1000
|
+
if (!this.firstElement) {
|
|
1001
|
+
return "";
|
|
1002
|
+
}
|
|
1003
|
+
return this.firstElement.getAttribute(attr);
|
|
1004
|
+
}
|
|
1005
|
+
this._each((el) => {
|
|
1006
|
+
el.setAttribute(attr, value);
|
|
1007
|
+
});
|
|
1008
|
+
return this;
|
|
1009
|
+
}
|
|
1010
|
+
find(selector) {
|
|
1011
|
+
return $LG(this._getSelector(selector, this.selector));
|
|
1012
|
+
}
|
|
1013
|
+
first() {
|
|
1014
|
+
if (this.selector && this.selector.length !== void 0) {
|
|
1015
|
+
return $LG(this.selector[0]);
|
|
1016
|
+
} else {
|
|
1017
|
+
return $LG(this.selector);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
eq(index) {
|
|
1021
|
+
return $LG(this.selector[index]);
|
|
1022
|
+
}
|
|
1023
|
+
parent() {
|
|
1024
|
+
return $LG(this.selector.parentElement);
|
|
1025
|
+
}
|
|
1026
|
+
get() {
|
|
1027
|
+
return this._getFirstEl();
|
|
1028
|
+
}
|
|
1029
|
+
removeAttr(attributes) {
|
|
1030
|
+
const attrs = attributes.split(" ");
|
|
1031
|
+
this._each((el) => {
|
|
1032
|
+
attrs.forEach((attr) => el.removeAttribute(attr));
|
|
1033
|
+
});
|
|
1034
|
+
return this;
|
|
1035
|
+
}
|
|
1036
|
+
wrap(className) {
|
|
1037
|
+
if (!this.firstElement) {
|
|
1038
|
+
return this;
|
|
1039
|
+
}
|
|
1040
|
+
const wrapper = document.createElement("div");
|
|
1041
|
+
wrapper.className = className;
|
|
1042
|
+
this.firstElement.parentNode.insertBefore(wrapper, this.firstElement);
|
|
1043
|
+
this.firstElement.parentNode.removeChild(this.firstElement);
|
|
1044
|
+
wrapper.appendChild(this.firstElement);
|
|
1045
|
+
return this;
|
|
1046
|
+
}
|
|
1047
|
+
addClass(classNames = "") {
|
|
1048
|
+
this._each((el) => {
|
|
1049
|
+
classNames.split(" ").forEach((className) => {
|
|
1050
|
+
if (className) {
|
|
1051
|
+
el.classList.add(className);
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
});
|
|
1055
|
+
return this;
|
|
1056
|
+
}
|
|
1057
|
+
removeClass(classNames) {
|
|
1058
|
+
this._each((el) => {
|
|
1059
|
+
classNames.split(" ").forEach((className) => {
|
|
1060
|
+
if (className) {
|
|
1061
|
+
el.classList.remove(className);
|
|
1062
|
+
}
|
|
1063
|
+
});
|
|
1064
|
+
});
|
|
1065
|
+
return this;
|
|
1066
|
+
}
|
|
1067
|
+
hasClass(className) {
|
|
1068
|
+
if (!this.firstElement) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
return this.firstElement.classList.contains(className);
|
|
1072
|
+
}
|
|
1073
|
+
hasAttribute(attribute) {
|
|
1074
|
+
if (!this.firstElement) {
|
|
1075
|
+
return false;
|
|
1076
|
+
}
|
|
1077
|
+
return this.firstElement.hasAttribute(attribute);
|
|
1078
|
+
}
|
|
1079
|
+
toggleClass(className) {
|
|
1080
|
+
if (!this.firstElement) {
|
|
1081
|
+
return this;
|
|
1082
|
+
}
|
|
1083
|
+
if (this.hasClass(className)) {
|
|
1084
|
+
this.removeClass(className);
|
|
1085
|
+
} else {
|
|
1086
|
+
this.addClass(className);
|
|
1087
|
+
}
|
|
1088
|
+
return this;
|
|
1089
|
+
}
|
|
1090
|
+
css(property, value) {
|
|
1091
|
+
this._each((el) => {
|
|
1092
|
+
this._setCssVendorPrefix(el, property, value);
|
|
1093
|
+
});
|
|
1094
|
+
return this;
|
|
1095
|
+
}
|
|
1096
|
+
// Need to pass separate namespaces for separate elements
|
|
1097
|
+
on(events, listener) {
|
|
1098
|
+
if (!this.selector) {
|
|
1099
|
+
return this;
|
|
1100
|
+
}
|
|
1101
|
+
events.split(" ").forEach((event) => {
|
|
1102
|
+
if (!Array.isArray(_lgQuery2.eventListeners[event])) {
|
|
1103
|
+
_lgQuery2.eventListeners[event] = [];
|
|
1104
|
+
}
|
|
1105
|
+
_lgQuery2.eventListeners[event].push(listener);
|
|
1106
|
+
this.selector.addEventListener(event.split(".")[0], listener);
|
|
1107
|
+
});
|
|
1108
|
+
return this;
|
|
1109
|
+
}
|
|
1110
|
+
// @todo - test this
|
|
1111
|
+
once(event, listener) {
|
|
1112
|
+
this.on(event, () => {
|
|
1113
|
+
this.off(event);
|
|
1114
|
+
listener(event);
|
|
1115
|
+
});
|
|
1116
|
+
return this;
|
|
1117
|
+
}
|
|
1118
|
+
off(event) {
|
|
1119
|
+
if (!this.selector) {
|
|
1120
|
+
return this;
|
|
1121
|
+
}
|
|
1122
|
+
Object.keys(_lgQuery2.eventListeners).forEach((eventName) => {
|
|
1123
|
+
if (this.isEventMatched(event, eventName)) {
|
|
1124
|
+
_lgQuery2.eventListeners[eventName].forEach((listener) => {
|
|
1125
|
+
this.selector.removeEventListener(
|
|
1126
|
+
eventName.split(".")[0],
|
|
1127
|
+
listener
|
|
1128
|
+
);
|
|
1129
|
+
});
|
|
1130
|
+
_lgQuery2.eventListeners[eventName] = [];
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
return this;
|
|
1134
|
+
}
|
|
1135
|
+
trigger(event, detail) {
|
|
1136
|
+
if (!this.firstElement) {
|
|
1137
|
+
return this;
|
|
1138
|
+
}
|
|
1139
|
+
const customEvent = new CustomEvent(event.split(".")[0], {
|
|
1140
|
+
detail: detail || null
|
|
1141
|
+
});
|
|
1142
|
+
this.firstElement.dispatchEvent(customEvent);
|
|
1143
|
+
return this;
|
|
1144
|
+
}
|
|
1145
|
+
// Does not support IE
|
|
1146
|
+
load(url) {
|
|
1147
|
+
fetch(url).then((res) => res.text()).then((html) => {
|
|
1148
|
+
this.selector.innerHTML = html;
|
|
1149
|
+
});
|
|
1150
|
+
return this;
|
|
1151
|
+
}
|
|
1152
|
+
html(html) {
|
|
1153
|
+
if (html === void 0) {
|
|
1154
|
+
if (!this.firstElement) {
|
|
1155
|
+
return "";
|
|
1156
|
+
}
|
|
1157
|
+
return this.firstElement.innerHTML;
|
|
1158
|
+
}
|
|
1159
|
+
this._each((el) => {
|
|
1160
|
+
el.innerHTML = html;
|
|
1161
|
+
});
|
|
1162
|
+
return this;
|
|
1163
|
+
}
|
|
1164
|
+
append(html) {
|
|
1165
|
+
this._each((el) => {
|
|
1166
|
+
if (typeof html === "string") {
|
|
1167
|
+
el.insertAdjacentHTML("beforeend", html);
|
|
1168
|
+
} else {
|
|
1169
|
+
el.appendChild(html);
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
return this;
|
|
1173
|
+
}
|
|
1174
|
+
prepend(html) {
|
|
1175
|
+
this._each((el) => {
|
|
1176
|
+
if (typeof html === "string") {
|
|
1177
|
+
el.insertAdjacentHTML("afterbegin", html);
|
|
1178
|
+
} else if (html instanceof HTMLElement) {
|
|
1179
|
+
el.insertBefore(html.cloneNode(true), el.firstChild);
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
return this;
|
|
1183
|
+
}
|
|
1184
|
+
remove() {
|
|
1185
|
+
this._each((el) => {
|
|
1186
|
+
el.parentNode.removeChild(el);
|
|
1187
|
+
});
|
|
1188
|
+
return this;
|
|
1189
|
+
}
|
|
1190
|
+
empty() {
|
|
1191
|
+
this._each((el) => {
|
|
1192
|
+
el.innerHTML = "";
|
|
1193
|
+
});
|
|
1194
|
+
return this;
|
|
1195
|
+
}
|
|
1196
|
+
scrollTop(scrollTop) {
|
|
1197
|
+
if (scrollTop !== void 0) {
|
|
1198
|
+
window.scrollTo(window.scrollX, scrollTop);
|
|
1199
|
+
return this;
|
|
1200
|
+
} else {
|
|
1201
|
+
return window.scrollY;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
scrollLeft(scrollLeft) {
|
|
1205
|
+
if (scrollLeft !== void 0) {
|
|
1206
|
+
window.scrollTo(scrollLeft, window.scrollY);
|
|
1207
|
+
return this;
|
|
1208
|
+
} else {
|
|
1209
|
+
return window.scrollX;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
offset() {
|
|
1213
|
+
if (!this.firstElement) {
|
|
1214
|
+
return {
|
|
1215
|
+
left: 0,
|
|
1216
|
+
top: 0
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
const rect = this.firstElement.getBoundingClientRect();
|
|
1220
|
+
const bodyMarginLeft = $LG("body").style().marginLeft;
|
|
1221
|
+
return {
|
|
1222
|
+
left: rect.left - parseFloat(bodyMarginLeft) + this.scrollLeft(),
|
|
1223
|
+
top: rect.top + this.scrollTop()
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
style() {
|
|
1227
|
+
if (!this.firstElement) {
|
|
1228
|
+
return {};
|
|
1229
|
+
}
|
|
1230
|
+
return this.firstElement.currentStyle || window.getComputedStyle(this.firstElement);
|
|
1231
|
+
}
|
|
1232
|
+
// Width without padding and border even if box-sizing is used.
|
|
1233
|
+
width() {
|
|
1234
|
+
const style = this.style();
|
|
1235
|
+
return this.firstElement.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
|
1236
|
+
}
|
|
1237
|
+
// Height without padding and border even if box-sizing is used.
|
|
1238
|
+
height() {
|
|
1239
|
+
const style = this.style();
|
|
1240
|
+
return this.firstElement.clientHeight - parseFloat(style.paddingTop) - parseFloat(style.paddingBottom);
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
_lgQuery.eventListeners = {};
|
|
1244
|
+
let lgQuery = _lgQuery;
|
|
1245
|
+
function $LG(selector) {
|
|
1246
|
+
return new lgQuery(selector);
|
|
1247
|
+
}
|
|
1248
|
+
const defaultDynamicOptions = [
|
|
1249
|
+
"src",
|
|
1250
|
+
"sources",
|
|
1251
|
+
"subHtml",
|
|
1252
|
+
"subHtmlUrl",
|
|
1253
|
+
"html",
|
|
1254
|
+
"video",
|
|
1255
|
+
"poster",
|
|
1256
|
+
"slideName",
|
|
1257
|
+
"responsive",
|
|
1258
|
+
"srcset",
|
|
1259
|
+
"sizes",
|
|
1260
|
+
"iframe",
|
|
1261
|
+
"downloadUrl",
|
|
1262
|
+
"download",
|
|
1263
|
+
"width",
|
|
1264
|
+
"shareUrl",
|
|
1265
|
+
"facebookShareUrl",
|
|
1266
|
+
"tweetText",
|
|
1267
|
+
"iframeTitle",
|
|
1268
|
+
"twitterShareUrl",
|
|
1269
|
+
"pinterestShareUrl",
|
|
1270
|
+
"pinterestText",
|
|
1271
|
+
"fbHtml",
|
|
1272
|
+
"disqusIdentifier",
|
|
1273
|
+
"disqusUrl"
|
|
1274
|
+
];
|
|
1275
|
+
function convertToData(attr) {
|
|
1276
|
+
if (attr === "href") {
|
|
1277
|
+
return "src";
|
|
1278
|
+
}
|
|
1279
|
+
attr = attr.replace("data-", "");
|
|
1280
|
+
attr = attr.charAt(0).toLowerCase() + attr.slice(1);
|
|
1281
|
+
attr = attr.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
1282
|
+
return attr;
|
|
1283
|
+
}
|
|
1284
|
+
const utils = {
|
|
1285
|
+
/**
|
|
1286
|
+
* Fetches HTML content from a given URL and inserts it into a specified element.
|
|
1287
|
+
*
|
|
1288
|
+
* @param url - The URL to fetch the HTML content from.
|
|
1289
|
+
* @param element - The DOM element (jQuery object) to insert the HTML content into.
|
|
1290
|
+
* @param insertMethod - The method to insert the HTML ('append' or 'replace').
|
|
1291
|
+
*/
|
|
1292
|
+
fetchCaptionFromUrl(url, element, insertMethod) {
|
|
1293
|
+
fetch(url).then((response) => response.text()).then((htmlContent) => {
|
|
1294
|
+
if (insertMethod === "append") {
|
|
1295
|
+
const contentDiv = `<div class="lg-sub-html">${htmlContent}</div>`;
|
|
1296
|
+
element.append(contentDiv);
|
|
1297
|
+
} else {
|
|
1298
|
+
element.html(htmlContent);
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
},
|
|
1302
|
+
/**
|
|
1303
|
+
* get possible width and height from the lgSize attribute. Used for ZoomFromOrigin option
|
|
1304
|
+
*/
|
|
1305
|
+
getSize(el, container, spacing = 0, defaultLgSize) {
|
|
1306
|
+
const LGel = $LG(el);
|
|
1307
|
+
const lgSize = LGel.attr("data-lg-size") || defaultLgSize;
|
|
1308
|
+
const parsed = parseImageSize(lgSize, window.innerWidth);
|
|
1309
|
+
if (!parsed) {
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
return fitImageSize(
|
|
1313
|
+
parsed,
|
|
1314
|
+
container.width(),
|
|
1315
|
+
container.height() - spacing
|
|
1316
|
+
);
|
|
1317
|
+
},
|
|
1318
|
+
/**
|
|
1319
|
+
* @desc Get transform value based on the imageSize. Used for ZoomFromOrigin option
|
|
1320
|
+
* @param {jQuery Element}
|
|
1321
|
+
* @returns {String} Transform CSS string
|
|
1322
|
+
*/
|
|
1323
|
+
getTransform(el, container, top, bottom, imageSize) {
|
|
1324
|
+
if (!imageSize || imageSize.width <= 0 || imageSize.height <= 0) {
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
const LGel = $LG(el).find("img").first();
|
|
1328
|
+
if (!LGel.get()) {
|
|
1329
|
+
return;
|
|
1330
|
+
}
|
|
1331
|
+
const containerRect = container.get().getBoundingClientRect();
|
|
1332
|
+
const rect = LGel.get().getBoundingClientRect();
|
|
1333
|
+
const triggerRect = {
|
|
1334
|
+
left: rect.left,
|
|
1335
|
+
top: rect.top,
|
|
1336
|
+
width: rect.width,
|
|
1337
|
+
height: rect.height
|
|
1338
|
+
};
|
|
1339
|
+
if (!isUsableOriginRect(triggerRect)) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
return getOriginTransform({
|
|
1343
|
+
triggerRect,
|
|
1344
|
+
containerRect: {
|
|
1345
|
+
left: containerRect.left,
|
|
1346
|
+
top: containerRect.top,
|
|
1347
|
+
width: containerRect.width,
|
|
1348
|
+
// Element height, not rect height, includes the mobile
|
|
1349
|
+
// safari bottom bar handling this always had.
|
|
1350
|
+
height: container.height()
|
|
1351
|
+
},
|
|
1352
|
+
top,
|
|
1353
|
+
bottom,
|
|
1354
|
+
imageSize
|
|
1355
|
+
});
|
|
1356
|
+
},
|
|
1357
|
+
getIframeMarkup(iframeWidth, iframeHeight, iframeMaxWidth, iframeMaxHeight, src, iframeTitle) {
|
|
1358
|
+
const title = iframeTitle ? 'title="' + iframeTitle + '"' : "";
|
|
1359
|
+
return `<div class="lg-media-cont lg-has-iframe" style="width:${iframeWidth}; max-width:${iframeMaxWidth}; height: ${iframeHeight}; max-height:${iframeMaxHeight}">
|
|
1360
|
+
<iframe class="lg-object" frameborder="0" ${title} src="${src}" allowfullscreen="true"></iframe>
|
|
1361
|
+
</div>`;
|
|
1362
|
+
},
|
|
1363
|
+
getImgMarkup(index, src, altAttr, srcset, sizes, sources) {
|
|
1364
|
+
const srcsetAttr = srcset ? `srcset="${srcset}"` : "";
|
|
1365
|
+
const sizesAttr = sizes ? `sizes="${sizes}"` : "";
|
|
1366
|
+
const imgMarkup = `<img ${altAttr} ${srcsetAttr} ${sizesAttr} class="lg-object lg-image" data-index="${index}" src="${src}" />`;
|
|
1367
|
+
let sourceTag = "";
|
|
1368
|
+
if (sources) {
|
|
1369
|
+
const sourceObj = typeof sources === "string" ? JSON.parse(sources) : sources;
|
|
1370
|
+
sourceTag = sourceObj.map((source) => {
|
|
1371
|
+
let attrs = "";
|
|
1372
|
+
Object.keys(source).forEach((key) => {
|
|
1373
|
+
attrs += ` ${key}="${source[key]}"`;
|
|
1374
|
+
});
|
|
1375
|
+
return `<source ${attrs}></source>`;
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
return `${sourceTag}${imgMarkup}`;
|
|
1379
|
+
},
|
|
1380
|
+
// Get src from responsive src
|
|
1381
|
+
getResponsiveSrc(srcItms) {
|
|
1382
|
+
const rsWidth = [];
|
|
1383
|
+
const rsSrc = [];
|
|
1384
|
+
let src = "";
|
|
1385
|
+
for (let i = 0; i < srcItms.length; i++) {
|
|
1386
|
+
const _src = srcItms[i].split(" ");
|
|
1387
|
+
if (_src[0] === "") {
|
|
1388
|
+
_src.splice(0, 1);
|
|
1389
|
+
}
|
|
1390
|
+
rsSrc.push(_src[0]);
|
|
1391
|
+
rsWidth.push(_src[1]);
|
|
1392
|
+
}
|
|
1393
|
+
const wWidth = window.innerWidth;
|
|
1394
|
+
for (let j = 0; j < rsWidth.length; j++) {
|
|
1395
|
+
if (parseInt(rsWidth[j], 10) > wWidth) {
|
|
1396
|
+
src = rsSrc[j];
|
|
1397
|
+
break;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
return src;
|
|
1401
|
+
},
|
|
1402
|
+
isImageLoaded(img) {
|
|
1403
|
+
if (!img) return false;
|
|
1404
|
+
if (!img.complete) {
|
|
1405
|
+
return false;
|
|
1406
|
+
}
|
|
1407
|
+
if (img.naturalWidth === 0) {
|
|
1408
|
+
return false;
|
|
1409
|
+
}
|
|
1410
|
+
return true;
|
|
1411
|
+
},
|
|
1412
|
+
getVideoPosterMarkup(_poster, dummyImg, videoContStyle, playVideoString, _isVideo) {
|
|
1413
|
+
let videoClass = "";
|
|
1414
|
+
if (_isVideo && _isVideo.youtube) {
|
|
1415
|
+
videoClass = "lg-has-youtube";
|
|
1416
|
+
} else if (_isVideo && _isVideo.vimeo) {
|
|
1417
|
+
videoClass = "lg-has-vimeo";
|
|
1418
|
+
} else if (_isVideo && _isVideo.wistia) {
|
|
1419
|
+
videoClass = "lg-has-wistia";
|
|
1420
|
+
} else {
|
|
1421
|
+
videoClass = "lg-has-html5";
|
|
1422
|
+
}
|
|
1423
|
+
let _dummy = dummyImg;
|
|
1424
|
+
if (typeof dummyImg !== "string") {
|
|
1425
|
+
_dummy = dummyImg.outerHTML;
|
|
1426
|
+
}
|
|
1427
|
+
return `<div class="lg-video-cont ${videoClass}" style="${videoContStyle}">
|
|
1428
|
+
<div class="lg-video-play-button">
|
|
1429
|
+
<svg
|
|
1430
|
+
viewBox="0 0 20 20"
|
|
1431
|
+
preserveAspectRatio="xMidYMid"
|
|
1432
|
+
focusable="false"
|
|
1433
|
+
aria-labelledby="${playVideoString}"
|
|
1434
|
+
role="img"
|
|
1435
|
+
class="lg-video-play-icon"
|
|
1436
|
+
>
|
|
1437
|
+
<title>${playVideoString}</title>
|
|
1438
|
+
<polygon class="lg-video-play-icon-inner" points="1,0 20,10 1,20"></polygon>
|
|
1439
|
+
</svg>
|
|
1440
|
+
<svg class="lg-video-play-icon-bg" viewBox="0 0 50 50" focusable="false">
|
|
1441
|
+
<circle cx="50%" cy="50%" r="20"></circle></svg>
|
|
1442
|
+
<svg class="lg-video-play-icon-circle" viewBox="0 0 50 50" focusable="false">
|
|
1443
|
+
<circle cx="50%" cy="50%" r="20"></circle>
|
|
1444
|
+
</svg>
|
|
1445
|
+
</div>
|
|
1446
|
+
${_dummy}
|
|
1447
|
+
<img class="lg-object lg-video-poster" src="${_poster}" />
|
|
1448
|
+
</div>`;
|
|
1449
|
+
},
|
|
1450
|
+
getFocusableElements(container) {
|
|
1451
|
+
const elements = container.querySelectorAll(
|
|
1452
|
+
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'
|
|
1453
|
+
);
|
|
1454
|
+
const visibleElements = [].filter.call(
|
|
1455
|
+
elements,
|
|
1456
|
+
(element) => {
|
|
1457
|
+
const style = window.getComputedStyle(element);
|
|
1458
|
+
return style.display !== "none" && style.visibility !== "hidden" && // Hidden or moved into the toolbar's More menu, whatever
|
|
1459
|
+
// the stylesheet says about their display.
|
|
1460
|
+
!element.closest("[hidden], [data-lg-overflow]");
|
|
1461
|
+
}
|
|
1462
|
+
);
|
|
1463
|
+
return visibleElements;
|
|
1464
|
+
},
|
|
1465
|
+
/**
|
|
1466
|
+
* @desc Create dynamic elements array from gallery items when dynamic option is false
|
|
1467
|
+
* It helps to avoid frequent DOM interaction
|
|
1468
|
+
* and avoid multiple checks for dynamic elments
|
|
1469
|
+
*
|
|
1470
|
+
* @returns {Array} dynamicEl
|
|
1471
|
+
*/
|
|
1472
|
+
getDynamicOptions(items, extraProps, getCaptionFromTitleOrAlt, exThumbImage) {
|
|
1473
|
+
const dynamicElements = [];
|
|
1474
|
+
const availableDynamicOptions = [
|
|
1475
|
+
...defaultDynamicOptions,
|
|
1476
|
+
...extraProps
|
|
1477
|
+
];
|
|
1478
|
+
[].forEach.call(items, (item) => {
|
|
1479
|
+
const dynamicEl = {};
|
|
1480
|
+
for (let i = 0; i < item.attributes.length; i++) {
|
|
1481
|
+
const attr = item.attributes[i];
|
|
1482
|
+
if (attr.specified) {
|
|
1483
|
+
const dynamicAttr = convertToData(attr.name);
|
|
1484
|
+
let label = "";
|
|
1485
|
+
if (availableDynamicOptions.indexOf(dynamicAttr) > -1) {
|
|
1486
|
+
label = dynamicAttr;
|
|
1487
|
+
}
|
|
1488
|
+
if (label) {
|
|
1489
|
+
dynamicEl[label] = attr.value;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
if (typeof dynamicEl.sources === "string") {
|
|
1494
|
+
try {
|
|
1495
|
+
dynamicEl.sources = JSON.parse(dynamicEl.sources);
|
|
1496
|
+
} catch (e) {
|
|
1497
|
+
console.warn(
|
|
1498
|
+
"lightGallery :- data-sources must be a JSON array of picture source objects. See https://www.lightgalleryjs.com/docs/responsive-loading/"
|
|
1499
|
+
);
|
|
1500
|
+
delete dynamicEl.sources;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
const currentItem = $LG(item);
|
|
1504
|
+
const alt = currentItem.find("img").first().attr("alt");
|
|
1505
|
+
const title = currentItem.attr("title");
|
|
1506
|
+
const thumb = exThumbImage ? currentItem.attr(exThumbImage) : currentItem.find("img").first().attr("src");
|
|
1507
|
+
dynamicEl.thumb = thumb;
|
|
1508
|
+
if (getCaptionFromTitleOrAlt && !dynamicEl.subHtml) {
|
|
1509
|
+
dynamicEl.subHtml = title || alt || "";
|
|
1510
|
+
}
|
|
1511
|
+
dynamicEl.alt = alt || title || "";
|
|
1512
|
+
dynamicElements.push(dynamicEl);
|
|
1513
|
+
});
|
|
1514
|
+
return dynamicElements;
|
|
1515
|
+
},
|
|
1516
|
+
isMobile() {
|
|
1517
|
+
return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
|
|
1518
|
+
},
|
|
1519
|
+
/**
|
|
1520
|
+
* @desc Check the given src is video
|
|
1521
|
+
* @param {String} src
|
|
1522
|
+
* @return {Object} video type
|
|
1523
|
+
* Ex:{ youtube : ["//www.youtube.com/watch?v=c0asJgSyxcY", "c0asJgSyxcY"] }
|
|
1524
|
+
*
|
|
1525
|
+
* @todo - this information can be moved to dynamicEl to avoid frequent calls
|
|
1526
|
+
*/
|
|
1527
|
+
isVideo(src, isHTML5VIdeo, index) {
|
|
1528
|
+
if (!src) {
|
|
1529
|
+
if (isHTML5VIdeo) {
|
|
1530
|
+
return {
|
|
1531
|
+
html5: true
|
|
1532
|
+
};
|
|
1533
|
+
} else {
|
|
1534
|
+
console.error(
|
|
1535
|
+
"lightGallery :- data-src is not provided on slide item " + (index + 1) + ". Please make sure the selector property is properly configured. More info - https://www.lightgalleryjs.com/demos/html-markup/"
|
|
1536
|
+
);
|
|
1537
|
+
return;
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
return getVideoInfo(src, false);
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
var __defProp = Object.defineProperty;
|
|
1544
|
+
var __defProps = Object.defineProperties;
|
|
1545
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1546
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1547
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1548
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1549
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1550
|
+
var __spreadValues = (a, b) => {
|
|
1551
|
+
for (var prop in b || (b = {}))
|
|
1552
|
+
if (__hasOwnProp.call(b, prop))
|
|
1553
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1554
|
+
if (__getOwnPropSymbols)
|
|
1555
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
1556
|
+
if (__propIsEnum.call(b, prop))
|
|
1557
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1558
|
+
}
|
|
1559
|
+
return a;
|
|
1560
|
+
};
|
|
1561
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1562
|
+
let lgId = 0;
|
|
1563
|
+
class LightGallery {
|
|
1564
|
+
constructor(element, options) {
|
|
1565
|
+
this.lgOpened = false;
|
|
1566
|
+
this.index = 0;
|
|
1567
|
+
this.plugins = [];
|
|
1568
|
+
this.lGalleryOn = false;
|
|
1569
|
+
this.lgBusy = false;
|
|
1570
|
+
this.defaultIcons = __spreadValues({}, coreDefaultIcons);
|
|
1571
|
+
this.swipeSamples = [];
|
|
1572
|
+
this.currentItemsInDom = [];
|
|
1573
|
+
this.prevScrollTop = 0;
|
|
1574
|
+
this.bodyPaddingRight = 0;
|
|
1575
|
+
this.isDummyImageRemoved = false;
|
|
1576
|
+
this.dragOrSwipeEnabled = false;
|
|
1577
|
+
this.mediaContainerPosition = {
|
|
1578
|
+
top: 0,
|
|
1579
|
+
bottom: 0
|
|
1580
|
+
};
|
|
1581
|
+
if (!element) {
|
|
1582
|
+
return this;
|
|
1583
|
+
}
|
|
1584
|
+
lgId++;
|
|
1585
|
+
this.lgId = lgId;
|
|
1586
|
+
this.el = element;
|
|
1587
|
+
this.LGel = $LG(element);
|
|
1588
|
+
this.generateSettings(options);
|
|
1589
|
+
this.buildModules();
|
|
1590
|
+
if (this.settings.dynamic && this.settings.dynamicEl !== void 0 && !Array.isArray(this.settings.dynamicEl)) {
|
|
1591
|
+
throw "When using dynamic mode, you must also define dynamicEl as an Array.";
|
|
1592
|
+
}
|
|
1593
|
+
this.galleryItems = this.getItems();
|
|
1594
|
+
this.normalizeSettings();
|
|
1595
|
+
this.init();
|
|
1596
|
+
this.validateLicense();
|
|
1597
|
+
return this;
|
|
1598
|
+
}
|
|
1599
|
+
generateSettings(options) {
|
|
1600
|
+
var _a;
|
|
1601
|
+
this.settings = __spreadProps(__spreadValues(__spreadValues({}, lightGalleryCoreSettings), options), {
|
|
1602
|
+
// Strings merge per-key (headless resolveSettings parity), // a partial override keeps every other default.
|
|
1603
|
+
strings: __spreadValues(__spreadValues({}, lightGalleryCoreSettings.strings), (_a = options == null ? void 0 : options.strings) != null ? _a : {})
|
|
1604
|
+
});
|
|
1605
|
+
if (this.settings.isMobile && typeof this.settings.isMobile === "function" ? this.settings.isMobile() : utils.isMobile()) {
|
|
1606
|
+
const mobileSettings = __spreadValues({}, this.settings.mobileSettings);
|
|
1607
|
+
this.settings = __spreadValues(__spreadValues({}, this.settings), mobileSettings);
|
|
1608
|
+
}
|
|
1609
|
+
if (typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
1610
|
+
this.settings = __spreadProps(__spreadValues({}, this.settings), {
|
|
1611
|
+
speed: 0,
|
|
1612
|
+
backdropDuration: 0,
|
|
1613
|
+
startAnimationDuration: 0,
|
|
1614
|
+
zoomFromOrigin: false,
|
|
1615
|
+
slideEndAnimation: false
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
normalizeSettings() {
|
|
1620
|
+
if (this.settings.direction === "auto") {
|
|
1621
|
+
this.settings.direction = typeof window !== "undefined" && typeof window.getComputedStyle === "function" && window.getComputedStyle(this.el).direction === "rtl" ? "rtl" : "ltr";
|
|
1622
|
+
}
|
|
1623
|
+
if (this.settings.slideEndAnimation) {
|
|
1624
|
+
this.settings.hideControlOnEnd = false;
|
|
1625
|
+
}
|
|
1626
|
+
if (!this.settings.closable) {
|
|
1627
|
+
this.settings.swipeToClose = false;
|
|
1628
|
+
}
|
|
1629
|
+
this.zoomFromOrigin = this.settings.zoomFromOrigin;
|
|
1630
|
+
if (this.settings.dynamic) {
|
|
1631
|
+
this.zoomFromOrigin = false;
|
|
1632
|
+
}
|
|
1633
|
+
if (this.settings.container) {
|
|
1634
|
+
const { container } = this.settings;
|
|
1635
|
+
if (typeof container === "function") {
|
|
1636
|
+
this.settings.container = container();
|
|
1637
|
+
} else if (typeof container === "string") {
|
|
1638
|
+
const el = document.querySelector(container);
|
|
1639
|
+
this.settings.container = el != null ? el : document.body;
|
|
1640
|
+
}
|
|
1641
|
+
} else {
|
|
1642
|
+
this.settings.container = document.body;
|
|
1643
|
+
}
|
|
1644
|
+
this.settings.preload = Math.min(
|
|
1645
|
+
this.settings.preload,
|
|
1646
|
+
this.galleryItems.length
|
|
1647
|
+
);
|
|
1648
|
+
}
|
|
1649
|
+
init() {
|
|
1650
|
+
this.addSlideVideoInfo(this.galleryItems);
|
|
1651
|
+
this.buildStructure();
|
|
1652
|
+
this.LGel.trigger(lGEvents.init, {
|
|
1653
|
+
instance: this
|
|
1654
|
+
});
|
|
1655
|
+
if (this.settings.keyPress) {
|
|
1656
|
+
this.keyPress();
|
|
1657
|
+
}
|
|
1658
|
+
setTimeout(() => {
|
|
1659
|
+
this.enableDrag();
|
|
1660
|
+
this.enableSwipe();
|
|
1661
|
+
this.triggerPosterClick();
|
|
1662
|
+
}, 50);
|
|
1663
|
+
this.arrow();
|
|
1664
|
+
if (this.settings.mousewheel) {
|
|
1665
|
+
this.mousewheel();
|
|
1666
|
+
}
|
|
1667
|
+
if (!this.settings.dynamic) {
|
|
1668
|
+
this.openGalleryOnItemClick();
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
openGalleryOnItemClick() {
|
|
1672
|
+
for (let index = 0; index < this.items.length; index++) {
|
|
1673
|
+
const element = this.items[index];
|
|
1674
|
+
const $element = $LG(element);
|
|
1675
|
+
const uuid = lgQuery.generateUUID();
|
|
1676
|
+
$element.attr("data-lg-id", uuid).on(`click.lgcustom-item-${uuid}`, (e) => {
|
|
1677
|
+
e.preventDefault();
|
|
1678
|
+
const currentItemIndex = this.settings.index || index;
|
|
1679
|
+
this.openGallery(currentItemIndex, element);
|
|
1680
|
+
});
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* Module constructor
|
|
1685
|
+
* Modules are build incrementally.
|
|
1686
|
+
* Gallery should be opened only once all the modules are initialized.
|
|
1687
|
+
* use moduleBuildTimeout to make sure this
|
|
1688
|
+
*/
|
|
1689
|
+
buildModules() {
|
|
1690
|
+
this.settings.plugins.forEach((plugin) => {
|
|
1691
|
+
this.plugins.push(new plugin(this, $LG));
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
validateLicense() {
|
|
1695
|
+
const notice = takeLicenseNotice(this.settings.licenseKey);
|
|
1696
|
+
if (notice) console[notice.level](notice.message);
|
|
1697
|
+
}
|
|
1698
|
+
getSlideItem(index) {
|
|
1699
|
+
return $LG(this.getSlideItemId(index));
|
|
1700
|
+
}
|
|
1701
|
+
getSlideItemId(index) {
|
|
1702
|
+
return `#lg-item-${this.lgId}-${index}`;
|
|
1703
|
+
}
|
|
1704
|
+
getIdName(id) {
|
|
1705
|
+
return `${id}-${this.lgId}`;
|
|
1706
|
+
}
|
|
1707
|
+
getElementById(id) {
|
|
1708
|
+
return $LG(`#${this.getIdName(id)}`);
|
|
1709
|
+
}
|
|
1710
|
+
manageSingleSlideClassName() {
|
|
1711
|
+
if (this.galleryItems.length < 2) {
|
|
1712
|
+
this.outer.addClass("lg-single-item");
|
|
1713
|
+
} else {
|
|
1714
|
+
this.outer.removeClass("lg-single-item");
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
buildStructure() {
|
|
1718
|
+
const container = this.$container && this.$container.get();
|
|
1719
|
+
if (container) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
let controls = "";
|
|
1723
|
+
let subHtmlCont = "";
|
|
1724
|
+
if (this.settings.controls) {
|
|
1725
|
+
controls = `<button type="button" id="${this.getIdName(
|
|
1726
|
+
"lg-prev"
|
|
1727
|
+
)}" aria-label="${this.settings.strings["previousSlide"]}" class="lg-prev lg-icon"> ${this.settings.prevHtml} </button>
|
|
1728
|
+
<button type="button" id="${this.getIdName(
|
|
1729
|
+
"lg-next"
|
|
1730
|
+
)}" aria-label="${this.settings.strings["nextSlide"]}" class="lg-next lg-icon"> ${this.settings.nextHtml} </button>`;
|
|
1731
|
+
}
|
|
1732
|
+
if (this.settings.appendSubHtmlTo !== ".lg-item") {
|
|
1733
|
+
subHtmlCont = this.settings.ariaAnnouncements ? '<div class="lg-sub-html"></div>' : '<div class="lg-sub-html" role="status" aria-live="polite"></div>';
|
|
1734
|
+
}
|
|
1735
|
+
let addClasses = "";
|
|
1736
|
+
if (this.settings.allowMediaOverlap) {
|
|
1737
|
+
addClasses += "lg-media-overlap ";
|
|
1738
|
+
}
|
|
1739
|
+
const ariaLabelledby = this.settings.ariaLabelledby ? 'aria-labelledby="' + this.settings.ariaLabelledby + '"' : `aria-label="${this.settings.strings["galleryLabel"]}"`;
|
|
1740
|
+
const ariaDescribedby = this.settings.ariaDescribedby ? 'aria-describedby="' + this.settings.ariaDescribedby + '"' : "";
|
|
1741
|
+
const containerClassName = `lg-container ${this.settings.addClass} ${document.body !== this.settings.container ? "lg-inline" : ""}`;
|
|
1742
|
+
const closeIcon = this.settings.closable && this.settings.showCloseIcon ? `<button type="button" aria-label="${this.settings.strings["closeGallery"]}" id="${this.getIdName(
|
|
1743
|
+
"lg-close"
|
|
1744
|
+
)}" class="lg-close lg-icon"></button>` : "";
|
|
1745
|
+
const maximizeIcon = this.settings.showMaximizeIcon ? `<button type="button" aria-label="${this.settings.strings["toggleMaximize"]}" id="${this.getIdName(
|
|
1746
|
+
"lg-maximize"
|
|
1747
|
+
)}" class="lg-maximize lg-icon"></button>` : "";
|
|
1748
|
+
const template = `
|
|
1749
|
+
<div class="${containerClassName}" id="${this.getIdName(
|
|
1750
|
+
"lg-container"
|
|
1751
|
+
)}" tabindex="-1" aria-modal="true" ${ariaLabelledby} ${ariaDescribedby} role="dialog" dir="${this.getDirection()}"
|
|
1752
|
+
>
|
|
1753
|
+
<div id="${this.getIdName(
|
|
1754
|
+
"lg-backdrop"
|
|
1755
|
+
)}" class="lg-backdrop"></div>
|
|
1756
|
+
${this.settings.ariaAnnouncements ? `<div id="${this.getIdName(
|
|
1757
|
+
"lg-announcer"
|
|
1758
|
+
)}" class="lg-announcer" role="status" aria-live="polite"></div>` : ""}
|
|
1759
|
+
|
|
1760
|
+
<div id="${this.getIdName(
|
|
1761
|
+
"lg-outer"
|
|
1762
|
+
)}" class="lg-outer lg-use-css3 lg-css3 lg-hide-items ${addClasses} ">
|
|
1763
|
+
|
|
1764
|
+
<div id="${this.getIdName("lg-content")}" class="lg-content">
|
|
1765
|
+
<div id="${this.getIdName("lg-inner")}" class="lg-inner">
|
|
1766
|
+
</div>
|
|
1767
|
+
${controls}
|
|
1768
|
+
</div>
|
|
1769
|
+
<div id="${this.getIdName(
|
|
1770
|
+
"lg-toolbar"
|
|
1771
|
+
)}" class="lg-toolbar lg-group">
|
|
1772
|
+
${maximizeIcon}
|
|
1773
|
+
${closeIcon}
|
|
1774
|
+
</div>
|
|
1775
|
+
${this.settings.appendSubHtmlTo === ".lg-outer" ? subHtmlCont : ""}
|
|
1776
|
+
<div id="${this.getIdName(
|
|
1777
|
+
"lg-components"
|
|
1778
|
+
)}" class="lg-components">
|
|
1779
|
+
${this.settings.appendSubHtmlTo === ".lg-sub-html" ? subHtmlCont : ""}
|
|
1780
|
+
</div>
|
|
1781
|
+
</div>
|
|
1782
|
+
</div>
|
|
1783
|
+
`;
|
|
1784
|
+
$LG(this.settings.container).append(template);
|
|
1785
|
+
if (document.body !== this.settings.container) {
|
|
1786
|
+
$LG(this.settings.container).css("position", "relative");
|
|
1787
|
+
}
|
|
1788
|
+
this.outer = this.getElementById("lg-outer");
|
|
1789
|
+
this.$lgComponents = this.getElementById("lg-components");
|
|
1790
|
+
this.$backdrop = this.getElementById("lg-backdrop");
|
|
1791
|
+
this.$container = this.getElementById("lg-container");
|
|
1792
|
+
this.$inner = this.getElementById("lg-inner");
|
|
1793
|
+
this.$content = this.getElementById("lg-content");
|
|
1794
|
+
this.$toolbar = this.getElementById("lg-toolbar");
|
|
1795
|
+
this.$backdrop.css(
|
|
1796
|
+
"transition-duration",
|
|
1797
|
+
this.settings.backdropDuration + "ms"
|
|
1798
|
+
);
|
|
1799
|
+
let outerClassNames = `${this.settings.mode} `;
|
|
1800
|
+
this.manageSingleSlideClassName();
|
|
1801
|
+
if (this.settings.enableDrag) {
|
|
1802
|
+
outerClassNames += "lg-grab ";
|
|
1803
|
+
}
|
|
1804
|
+
this.outer.addClass(outerClassNames);
|
|
1805
|
+
this.$inner.css("transition-timing-function", this.settings.easing);
|
|
1806
|
+
this.$inner.css("transition-duration", this.settings.speed + "ms");
|
|
1807
|
+
this.$inner.css("--lg-speed", this.settings.speed + "ms");
|
|
1808
|
+
if (this.settings.download) {
|
|
1809
|
+
this.$toolbar.append(
|
|
1810
|
+
`<a id="${this.getIdName(
|
|
1811
|
+
"lg-download"
|
|
1812
|
+
)}" target="_blank" rel="noopener" aria-label="${this.settings.strings["download"]}" download class="lg-download lg-icon"></a>`
|
|
1813
|
+
);
|
|
1814
|
+
}
|
|
1815
|
+
this.counter();
|
|
1816
|
+
$LG(window).on(
|
|
1817
|
+
`resize.lg.global${this.lgId} orientationchange.lg.global${this.lgId}`,
|
|
1818
|
+
() => {
|
|
1819
|
+
this.refreshOnResize();
|
|
1820
|
+
}
|
|
1821
|
+
);
|
|
1822
|
+
this.hideBars();
|
|
1823
|
+
this.manageCloseGallery();
|
|
1824
|
+
this.toggleMaximize();
|
|
1825
|
+
this.initModules();
|
|
1826
|
+
if (this.settings.toolbarOverflow) {
|
|
1827
|
+
this.toolbarOverflow = new ToolbarOverflow(this.$toolbar.get(), {
|
|
1828
|
+
id: this.getIdName("lg-more"),
|
|
1829
|
+
label: this.settings.strings.moreOptions
|
|
1830
|
+
});
|
|
1831
|
+
const update = () => {
|
|
1832
|
+
var _a;
|
|
1833
|
+
return (_a = this.toolbarOverflow) == null ? void 0 : _a.update();
|
|
1834
|
+
};
|
|
1835
|
+
this.LGel.on(`${lGEvents.afterOpen}.lg`, update);
|
|
1836
|
+
this.LGel.on(`${lGEvents.afterSlide}.lg`, update);
|
|
1837
|
+
this.LGel.on(`${lGEvents.containerResize}.lg`, update);
|
|
1838
|
+
this.LGel.on(
|
|
1839
|
+
`${lGEvents.beforeClose}.lg`,
|
|
1840
|
+
() => {
|
|
1841
|
+
var _a;
|
|
1842
|
+
return (_a = this.toolbarOverflow) == null ? void 0 : _a.close(false);
|
|
1843
|
+
}
|
|
1844
|
+
);
|
|
1845
|
+
}
|
|
1846
|
+
applyCustomIcons(
|
|
1847
|
+
this.$container.get(),
|
|
1848
|
+
this.defaultIcons,
|
|
1849
|
+
this.settings.icons
|
|
1850
|
+
);
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Merge a plugin's built-in icon SVGs into the default set (called
|
|
1854
|
+
* from plugin `init()`, before the icon pass runs). Consumer
|
|
1855
|
+
* `settings.icons` still win over anything registered here.
|
|
1856
|
+
*/
|
|
1857
|
+
registerDefaultIcons(icons) {
|
|
1858
|
+
this.defaultIcons = __spreadValues(__spreadValues({}, this.defaultIcons), icons);
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Cache the fitted (contain) size of a slide's media. Every consumer
|
|
1862
|
+
* of `currentImageSize` measures against the CURRENT slide: the
|
|
1863
|
+
* actual-size zoom divides the natural width by it, and the
|
|
1864
|
+
* zoom-from-origin close flight positions against it. Recomputed on
|
|
1865
|
+
* every slide change, not just at open — one cached landscape size
|
|
1866
|
+
* makes a portrait slide zoom to the wrong scale and then snap to
|
|
1867
|
+
* its real size when the natural-px swap lands.
|
|
1868
|
+
*/
|
|
1869
|
+
updateCurrentImageSize(index) {
|
|
1870
|
+
const { __slideVideoInfo } = this.galleryItems[index];
|
|
1871
|
+
const { top, bottom } = this.mediaContainerPosition;
|
|
1872
|
+
this.currentImageSize = utils.getSize(
|
|
1873
|
+
this.items[index],
|
|
1874
|
+
this.outer,
|
|
1875
|
+
top + bottom,
|
|
1876
|
+
__slideVideoInfo && this.settings.videoMaxSize
|
|
1877
|
+
);
|
|
1878
|
+
}
|
|
1879
|
+
refreshOnResize() {
|
|
1880
|
+
if (this.lgOpened) {
|
|
1881
|
+
const currentGalleryItem = this.galleryItems[this.index];
|
|
1882
|
+
const { __slideVideoInfo } = currentGalleryItem;
|
|
1883
|
+
this.mediaContainerPosition = this.getMediaContainerPosition();
|
|
1884
|
+
this.updateCurrentImageSize(this.index);
|
|
1885
|
+
if (__slideVideoInfo) {
|
|
1886
|
+
this.resizeVideoSlide(this.index, this.currentImageSize);
|
|
1887
|
+
}
|
|
1888
|
+
if (this.zoomFromOrigin && !this.isDummyImageRemoved) {
|
|
1889
|
+
const imgStyle = this.getDummyImgStyles(this.currentImageSize);
|
|
1890
|
+
this.outer.find(".lg-current .lg-dummy-img").first().attr("style", imgStyle);
|
|
1891
|
+
}
|
|
1892
|
+
this.LGel.trigger(lGEvents.containerResize);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
resizeVideoSlide(index, imageSize) {
|
|
1896
|
+
const lgVideoStyle = this.getVideoContStyle(imageSize);
|
|
1897
|
+
const currentSlide = this.getSlideItem(index);
|
|
1898
|
+
currentSlide.find(".lg-video-cont").attr("style", lgVideoStyle);
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Update slides dynamically.
|
|
1902
|
+
* Add, edit or delete slides dynamically when lightGallery is opened.
|
|
1903
|
+
* Modify the current gallery items and pass it via updateSlides method
|
|
1904
|
+
* @note
|
|
1905
|
+
* - Do not mutate existing lightGallery items directly.
|
|
1906
|
+
* - Always pass new list of gallery items
|
|
1907
|
+
* - You need to take care of thumbnails outside the gallery if any
|
|
1908
|
+
* - user this method only if you want to update slides when the gallery is opened. Otherwise, use `refresh()` method.
|
|
1909
|
+
* @param items Gallery items
|
|
1910
|
+
* @param index After the update operation, which slide gallery should navigate to
|
|
1911
|
+
* @category lGPublicMethods
|
|
1912
|
+
* @example
|
|
1913
|
+
* const plugin = lightGallery();
|
|
1914
|
+
*
|
|
1915
|
+
* // Adding slides dynamically
|
|
1916
|
+
* let galleryItems = [
|
|
1917
|
+
* // Access existing lightGallery items
|
|
1918
|
+
* // galleryItems are automatically generated internally from the gallery HTML markup
|
|
1919
|
+
* // or directly from galleryItems when dynamic gallery is used
|
|
1920
|
+
* ...plugin.galleryItems,
|
|
1921
|
+
* ...[
|
|
1922
|
+
* {
|
|
1923
|
+
* src: 'img/img-1.png',
|
|
1924
|
+
* thumb: 'img/thumb1.png',
|
|
1925
|
+
* },
|
|
1926
|
+
* ],
|
|
1927
|
+
* ];
|
|
1928
|
+
* plugin.updateSlides(
|
|
1929
|
+
* galleryItems,
|
|
1930
|
+
* plugin.index,
|
|
1931
|
+
* );
|
|
1932
|
+
*
|
|
1933
|
+
*
|
|
1934
|
+
* // Remove slides dynamically
|
|
1935
|
+
* galleryItems = JSON.parse(
|
|
1936
|
+
* JSON.stringify(updateSlideInstance.galleryItems),
|
|
1937
|
+
* );
|
|
1938
|
+
* galleryItems.shift();
|
|
1939
|
+
* updateSlideInstance.updateSlides(galleryItems, 1);
|
|
1940
|
+
* @see <a href="/demos/update-slides/">Demo</a>
|
|
1941
|
+
*/
|
|
1942
|
+
updateSlides(items, index) {
|
|
1943
|
+
if (this.index > items.length - 1) {
|
|
1944
|
+
this.index = items.length - 1;
|
|
1945
|
+
}
|
|
1946
|
+
if (items.length === 1) {
|
|
1947
|
+
this.index = 0;
|
|
1948
|
+
}
|
|
1949
|
+
if (!items.length) {
|
|
1950
|
+
this.closeGallery();
|
|
1951
|
+
return;
|
|
1952
|
+
}
|
|
1953
|
+
const currentSrc = this.galleryItems[index].src;
|
|
1954
|
+
this.galleryItems = items;
|
|
1955
|
+
this.updateControls();
|
|
1956
|
+
this.$inner.empty();
|
|
1957
|
+
this.currentItemsInDom = [];
|
|
1958
|
+
let _index = 0;
|
|
1959
|
+
this.galleryItems.some((galleryItem, itemIndex) => {
|
|
1960
|
+
if (galleryItem.src === currentSrc) {
|
|
1961
|
+
_index = itemIndex;
|
|
1962
|
+
return true;
|
|
1963
|
+
}
|
|
1964
|
+
return false;
|
|
1965
|
+
});
|
|
1966
|
+
this.currentItemsInDom = this.organizeSlideItems(_index, -1);
|
|
1967
|
+
this.loadContent(_index, true);
|
|
1968
|
+
this.getSlideItem(_index).addClass("lg-current");
|
|
1969
|
+
this.index = _index;
|
|
1970
|
+
this.updateCurrentCounter(_index);
|
|
1971
|
+
this.LGel.trigger(lGEvents.updateSlides);
|
|
1972
|
+
}
|
|
1973
|
+
// Get gallery items based on multiple conditions
|
|
1974
|
+
getItems() {
|
|
1975
|
+
this.items = [];
|
|
1976
|
+
if (!this.settings.dynamic) {
|
|
1977
|
+
if (this.settings.selector === "this") {
|
|
1978
|
+
this.items.push(this.el);
|
|
1979
|
+
} else if (this.settings.selector) {
|
|
1980
|
+
if (typeof this.settings.selector === "string") {
|
|
1981
|
+
if (this.settings.selectWithin) {
|
|
1982
|
+
const selectWithin = $LG(this.settings.selectWithin);
|
|
1983
|
+
this.items = selectWithin.find(this.settings.selector).get();
|
|
1984
|
+
} else {
|
|
1985
|
+
this.items = this.el.querySelectorAll(
|
|
1986
|
+
this.settings.selector
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1989
|
+
} else {
|
|
1990
|
+
this.items = this.settings.selector;
|
|
1991
|
+
}
|
|
1992
|
+
} else {
|
|
1993
|
+
this.items = this.el.children;
|
|
1994
|
+
}
|
|
1995
|
+
return utils.getDynamicOptions(
|
|
1996
|
+
this.items,
|
|
1997
|
+
this.settings.extraProps,
|
|
1998
|
+
this.settings.getCaptionFromTitleOrAlt,
|
|
1999
|
+
this.settings.exThumbImage
|
|
2000
|
+
);
|
|
2001
|
+
} else {
|
|
2002
|
+
return this.settings.dynamicEl || [];
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
shouldHideScrollbar() {
|
|
2006
|
+
return this.settings.hideScrollbar && document.body === this.settings.container;
|
|
2007
|
+
}
|
|
2008
|
+
hideScrollbar() {
|
|
2009
|
+
if (!this.shouldHideScrollbar()) {
|
|
2010
|
+
return;
|
|
2011
|
+
}
|
|
2012
|
+
this.bodyPaddingRight = parseFloat($LG("body").style().paddingRight);
|
|
2013
|
+
const bodyRect = document.documentElement.getBoundingClientRect();
|
|
2014
|
+
const scrollbarWidth = window.innerWidth - bodyRect.width;
|
|
2015
|
+
$LG(document.body).css(
|
|
2016
|
+
"padding-right",
|
|
2017
|
+
scrollbarWidth + this.bodyPaddingRight + "px"
|
|
2018
|
+
);
|
|
2019
|
+
$LG(document.body).addClass("lg-overlay-open");
|
|
2020
|
+
}
|
|
2021
|
+
resetScrollBar() {
|
|
2022
|
+
if (!this.shouldHideScrollbar()) {
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
2025
|
+
$LG(document.body).css("padding-right", this.bodyPaddingRight + "px");
|
|
2026
|
+
$LG(document.body).removeClass("lg-overlay-open");
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Open lightGallery.
|
|
2030
|
+
* Open gallery with specific slide by passing index of the slide as parameter.
|
|
2031
|
+
* @category lGPublicMethods
|
|
2032
|
+
* @param {Number} index - index of the slide
|
|
2033
|
+
* @param {HTMLElement} element - Which image lightGallery should zoom from
|
|
2034
|
+
*
|
|
2035
|
+
* @example
|
|
2036
|
+
* const $dynamicGallery = document.getElementById('dynamic-gallery-demo');
|
|
2037
|
+
* const dynamicGallery = lightGallery($dynamicGallery, {
|
|
2038
|
+
* dynamic: true,
|
|
2039
|
+
* dynamicEl: [
|
|
2040
|
+
* {
|
|
2041
|
+
* src: 'img/1.jpg',
|
|
2042
|
+
* thumb: 'img/thumb-1.jpg',
|
|
2043
|
+
* subHtml: '<h4>Image 1 title</h4><p>Image 1 descriptions.</p>',
|
|
2044
|
+
* },
|
|
2045
|
+
* ...
|
|
2046
|
+
* ],
|
|
2047
|
+
* });
|
|
2048
|
+
* $dynamicGallery.addEventListener('click', function () {
|
|
2049
|
+
* // Starts with third item.(Optional).
|
|
2050
|
+
* // This is useful if you want use dynamic mode with
|
|
2051
|
+
* // custom thumbnails (thumbnails outside gallery),
|
|
2052
|
+
* dynamicGallery.openGallery(2);
|
|
2053
|
+
* });
|
|
2054
|
+
*
|
|
2055
|
+
*/
|
|
2056
|
+
openGallery(index = this.settings.index, element) {
|
|
2057
|
+
if (this.lgOpened) return;
|
|
2058
|
+
this.lgOpened = true;
|
|
2059
|
+
this.outer.removeClass("lg-hide-items");
|
|
2060
|
+
this.hideScrollbar();
|
|
2061
|
+
this.$container.addClass("lg-show");
|
|
2062
|
+
const itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(
|
|
2063
|
+
index,
|
|
2064
|
+
index
|
|
2065
|
+
);
|
|
2066
|
+
this.currentItemsInDom = itemsToBeInsertedToDom;
|
|
2067
|
+
let items = "";
|
|
2068
|
+
itemsToBeInsertedToDom.forEach((item) => {
|
|
2069
|
+
items = items + `<div id="${item}" class="lg-item"></div>`;
|
|
2070
|
+
});
|
|
2071
|
+
this.$inner.append(items);
|
|
2072
|
+
this.addHtml(index);
|
|
2073
|
+
let transform = "";
|
|
2074
|
+
this.mediaContainerPosition = this.getMediaContainerPosition();
|
|
2075
|
+
const { top, bottom } = this.mediaContainerPosition;
|
|
2076
|
+
if (!this.settings.allowMediaOverlap) {
|
|
2077
|
+
this.setMediaContainerPosition(top, bottom);
|
|
2078
|
+
}
|
|
2079
|
+
const { __slideVideoInfo } = this.galleryItems[index];
|
|
2080
|
+
if (this.zoomFromOrigin && element) {
|
|
2081
|
+
this.currentImageSize = utils.getSize(
|
|
2082
|
+
element,
|
|
2083
|
+
this.outer,
|
|
2084
|
+
top + bottom,
|
|
2085
|
+
__slideVideoInfo && this.settings.videoMaxSize
|
|
2086
|
+
);
|
|
2087
|
+
transform = this.getOriginTransform(element, this.currentImageSize);
|
|
2088
|
+
}
|
|
2089
|
+
if (!this.zoomFromOrigin || !transform) {
|
|
2090
|
+
this.outer.addClass(this.settings.startClass);
|
|
2091
|
+
this.getSlideItem(index).removeClass("lg-complete");
|
|
2092
|
+
}
|
|
2093
|
+
const timeout = this.settings.zoomFromOrigin ? 100 : this.settings.backdropDuration;
|
|
2094
|
+
setTimeout(() => {
|
|
2095
|
+
this.outer.addClass("lg-components-open");
|
|
2096
|
+
}, timeout);
|
|
2097
|
+
this.index = index;
|
|
2098
|
+
this.LGel.trigger(lGEvents.beforeOpen);
|
|
2099
|
+
this.getSlideItem(index).addClass("lg-current");
|
|
2100
|
+
this.lGalleryOn = false;
|
|
2101
|
+
this.prevScrollTop = $LG(window).scrollTop();
|
|
2102
|
+
if (this.settings.trapFocus && document.body === this.settings.container) {
|
|
2103
|
+
this.prevActiveElement = document.activeElement instanceof HTMLElement ? document.activeElement : void 0;
|
|
2104
|
+
}
|
|
2105
|
+
setTimeout(() => {
|
|
2106
|
+
if (this.zoomFromOrigin && transform) {
|
|
2107
|
+
const currentSlide = this.getSlideItem(index);
|
|
2108
|
+
currentSlide.css("transform", transform);
|
|
2109
|
+
setTimeout(() => {
|
|
2110
|
+
currentSlide.addClass("lg-start-progress lg-start-end-progress").css(
|
|
2111
|
+
"transition-duration",
|
|
2112
|
+
this.settings.startAnimationDuration + "ms"
|
|
2113
|
+
);
|
|
2114
|
+
this.outer.addClass("lg-zoom-from-image");
|
|
2115
|
+
});
|
|
2116
|
+
setTimeout(() => {
|
|
2117
|
+
currentSlide.css("transform", "translate3d(0, 0, 0)");
|
|
2118
|
+
}, 100);
|
|
2119
|
+
}
|
|
2120
|
+
setTimeout(() => {
|
|
2121
|
+
this.$backdrop.addClass("in");
|
|
2122
|
+
this.$container.addClass("lg-show-in");
|
|
2123
|
+
}, 10);
|
|
2124
|
+
setTimeout(() => {
|
|
2125
|
+
if (this.settings.trapFocus && document.body === this.settings.container) {
|
|
2126
|
+
this.trapFocus();
|
|
2127
|
+
}
|
|
2128
|
+
}, this.settings.backdropDuration + 50);
|
|
2129
|
+
if (!this.zoomFromOrigin || !transform) {
|
|
2130
|
+
setTimeout(() => {
|
|
2131
|
+
this.outer.addClass("lg-visible");
|
|
2132
|
+
}, this.settings.backdropDuration);
|
|
2133
|
+
}
|
|
2134
|
+
this.slide(index, false, false, false);
|
|
2135
|
+
this.LGel.trigger(lGEvents.afterOpen);
|
|
2136
|
+
});
|
|
2137
|
+
if (document.body === this.settings.container) {
|
|
2138
|
+
$LG("html").addClass("lg-on");
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
/**
|
|
2142
|
+
* The zoom-from-origin transform for a trigger: it lands the slide on
|
|
2143
|
+
* the trigger's thumbnail, the start of the opening flight and the end
|
|
2144
|
+
* of the closing one. Undefined when the trigger cannot anchor a flight,
|
|
2145
|
+
* and the gallery opens or closes about the stage centre instead.
|
|
2146
|
+
* Plugins may replace it on the instance to fly differently.
|
|
2147
|
+
*/
|
|
2148
|
+
getOriginTransform(element, imageSize) {
|
|
2149
|
+
const { top, bottom } = this.mediaContainerPosition;
|
|
2150
|
+
return utils.getTransform(element, this.outer, top, bottom, imageSize);
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Note - Changing the position of the media on every slide transition creates a flickering effect.
|
|
2154
|
+
* Therefore, The height of the caption is calculated dynamically, only once based on the first slide caption.
|
|
2155
|
+
* if you have dynamic captions for each media,
|
|
2156
|
+
* you can provide an appropriate height for the captions via allowMediaOverlap option
|
|
2157
|
+
*/
|
|
2158
|
+
getMediaContainerPosition() {
|
|
2159
|
+
if (this.settings.allowMediaOverlap) {
|
|
2160
|
+
return {
|
|
2161
|
+
top: 0,
|
|
2162
|
+
bottom: 0
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
const top = this.$toolbar.get().clientHeight || 0;
|
|
2166
|
+
const subHtml = this.outer.find(".lg-components .lg-sub-html").get();
|
|
2167
|
+
const captionHeight = this.settings.defaultCaptionHeight || subHtml && subHtml.clientHeight || 0;
|
|
2168
|
+
const thumbContainer = this.outer.find(".lg-thumb-outer").get();
|
|
2169
|
+
const thumbHeight = thumbContainer ? thumbContainer.clientHeight : 0;
|
|
2170
|
+
const bottom = thumbHeight + captionHeight;
|
|
2171
|
+
return {
|
|
2172
|
+
top,
|
|
2173
|
+
bottom
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
setMediaContainerPosition(top = 0, bottom = 0) {
|
|
2177
|
+
this.$content.css("top", top + "px").css("bottom", bottom + "px");
|
|
2178
|
+
}
|
|
2179
|
+
hideBars() {
|
|
2180
|
+
setTimeout(() => {
|
|
2181
|
+
this.outer.removeClass("lg-hide-items");
|
|
2182
|
+
if (this.settings.hideBarsDelay > 0) {
|
|
2183
|
+
this.outer.on("mousemove.lg click.lg touchstart.lg", () => {
|
|
2184
|
+
this.outer.removeClass("lg-hide-items");
|
|
2185
|
+
clearTimeout(this.hideBarTimeout);
|
|
2186
|
+
this.hideBarTimeout = setTimeout(() => {
|
|
2187
|
+
this.outer.addClass("lg-hide-items");
|
|
2188
|
+
}, this.settings.hideBarsDelay);
|
|
2189
|
+
});
|
|
2190
|
+
this.outer.trigger("mousemove.lg");
|
|
2191
|
+
}
|
|
2192
|
+
}, this.settings.showBarsAfter);
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2195
|
+
* @desc Create image counter
|
|
2196
|
+
* Ex: 1/10
|
|
2197
|
+
*/
|
|
2198
|
+
counter() {
|
|
2199
|
+
if (this.settings.counter) {
|
|
2200
|
+
const counterA11yAttrs = this.settings.ariaAnnouncements ? 'aria-hidden="true"' : 'role="status" aria-live="polite"';
|
|
2201
|
+
const counterHtml = `<div class="lg-counter" ${counterA11yAttrs}>
|
|
2202
|
+
<span id="${this.getIdName(
|
|
2203
|
+
"lg-counter-current"
|
|
2204
|
+
)}" class="lg-counter-current">${this.index + 1} </span> /
|
|
2205
|
+
<span id="${this.getIdName(
|
|
2206
|
+
"lg-counter-all"
|
|
2207
|
+
)}" class="lg-counter-all">${this.galleryItems.length} </span></div>`;
|
|
2208
|
+
this.outer.find(this.settings.appendCounterTo).append(counterHtml);
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* @desc add sub-html into the slide
|
|
2213
|
+
* @param {Number} index - index of the slide
|
|
2214
|
+
*/
|
|
2215
|
+
addHtml(index) {
|
|
2216
|
+
let subHtml;
|
|
2217
|
+
let subHtmlUrl;
|
|
2218
|
+
if (this.galleryItems[index].subHtmlUrl) {
|
|
2219
|
+
subHtmlUrl = this.galleryItems[index].subHtmlUrl;
|
|
2220
|
+
} else {
|
|
2221
|
+
subHtml = this.galleryItems[index].subHtml;
|
|
2222
|
+
}
|
|
2223
|
+
if (!subHtmlUrl) {
|
|
2224
|
+
if (subHtml) {
|
|
2225
|
+
const fL = subHtml.substring(0, 1);
|
|
2226
|
+
if (fL === "." || fL === "#") {
|
|
2227
|
+
try {
|
|
2228
|
+
if (this.settings.subHtmlSelectorRelative && !this.settings.dynamic) {
|
|
2229
|
+
subHtml = $LG(this.items).eq(index).find(subHtml).first().html();
|
|
2230
|
+
} else {
|
|
2231
|
+
subHtml = $LG(subHtml).first().html();
|
|
2232
|
+
}
|
|
2233
|
+
} catch (error) {
|
|
2234
|
+
console.warn(
|
|
2235
|
+
`lightGallery: error processing subHtml selector "${subHtml}". See https://www.lightgalleryjs.com/demos/captions/`
|
|
2236
|
+
);
|
|
2237
|
+
subHtml = "";
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
} else {
|
|
2241
|
+
subHtml = "";
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
if (this.settings.appendSubHtmlTo !== ".lg-item") {
|
|
2245
|
+
if (subHtmlUrl) {
|
|
2246
|
+
utils.fetchCaptionFromUrl(
|
|
2247
|
+
subHtmlUrl,
|
|
2248
|
+
this.outer.find(".lg-sub-html"),
|
|
2249
|
+
"replace"
|
|
2250
|
+
);
|
|
2251
|
+
} else {
|
|
2252
|
+
this.outer.find(".lg-sub-html").html(subHtml);
|
|
2253
|
+
}
|
|
2254
|
+
} else {
|
|
2255
|
+
const currentSlide = $LG(this.getSlideItemId(index));
|
|
2256
|
+
if (subHtmlUrl) {
|
|
2257
|
+
utils.fetchCaptionFromUrl(subHtmlUrl, currentSlide, "append");
|
|
2258
|
+
} else {
|
|
2259
|
+
currentSlide.append(
|
|
2260
|
+
`<div class="lg-sub-html">${subHtml}</div>`
|
|
2261
|
+
);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
if (typeof subHtml !== "undefined" && subHtml !== null) {
|
|
2265
|
+
if (subHtml === "") {
|
|
2266
|
+
this.outer.find(this.settings.appendSubHtmlTo).addClass("lg-empty-html");
|
|
2267
|
+
} else {
|
|
2268
|
+
this.outer.find(this.settings.appendSubHtmlTo).removeClass("lg-empty-html");
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
this.LGel.trigger(
|
|
2272
|
+
lGEvents.afterAppendSubHtml,
|
|
2273
|
+
{
|
|
2274
|
+
index
|
|
2275
|
+
}
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* @desc Preload slides
|
|
2280
|
+
* @param {Number} index - index of the slide
|
|
2281
|
+
* @todo preload not working for the first slide, Also, should work for the first and last slide as well
|
|
2282
|
+
*/
|
|
2283
|
+
preload(index) {
|
|
2284
|
+
for (let i = 1; i <= this.settings.preload; i++) {
|
|
2285
|
+
if (i >= this.galleryItems.length - index) {
|
|
2286
|
+
break;
|
|
2287
|
+
}
|
|
2288
|
+
this.loadContent(index + i, false);
|
|
2289
|
+
}
|
|
2290
|
+
for (let j = 1; j <= this.settings.preload; j++) {
|
|
2291
|
+
if (index - j < 0) {
|
|
2292
|
+
break;
|
|
2293
|
+
}
|
|
2294
|
+
this.loadContent(index - j, false);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
getDummyImgStyles(imageSize) {
|
|
2298
|
+
if (!imageSize) return "";
|
|
2299
|
+
return `width:${imageSize.width}px;
|
|
2300
|
+
margin-left: -${imageSize.width / 2}px;
|
|
2301
|
+
margin-top: -${imageSize.height / 2}px;
|
|
2302
|
+
height:${imageSize.height}px`;
|
|
2303
|
+
}
|
|
2304
|
+
getVideoContStyle(imageSize) {
|
|
2305
|
+
if (!imageSize) return "";
|
|
2306
|
+
return `width:${imageSize.width}px;
|
|
2307
|
+
height:${imageSize.height}px`;
|
|
2308
|
+
}
|
|
2309
|
+
getDummyImageContent($currentSlide, index, alt) {
|
|
2310
|
+
let $currentItem;
|
|
2311
|
+
if (!this.settings.dynamic) {
|
|
2312
|
+
$currentItem = $LG(this.items).eq(index);
|
|
2313
|
+
}
|
|
2314
|
+
if ($currentItem) {
|
|
2315
|
+
let _dummyImgSrc;
|
|
2316
|
+
if (!this.settings.exThumbImage) {
|
|
2317
|
+
_dummyImgSrc = $currentItem.find("img").first().attr("src");
|
|
2318
|
+
} else {
|
|
2319
|
+
_dummyImgSrc = $currentItem.attr(this.settings.exThumbImage);
|
|
2320
|
+
}
|
|
2321
|
+
if (!_dummyImgSrc) return "";
|
|
2322
|
+
const imgStyle = this.getDummyImgStyles(this.currentImageSize);
|
|
2323
|
+
const dummyImgContentImg = document.createElement("img");
|
|
2324
|
+
dummyImgContentImg.alt = alt || "";
|
|
2325
|
+
dummyImgContentImg.src = _dummyImgSrc;
|
|
2326
|
+
dummyImgContentImg.className = `lg-dummy-img`;
|
|
2327
|
+
dummyImgContentImg.style.cssText = imgStyle;
|
|
2328
|
+
$currentSlide.addClass("lg-first-slide");
|
|
2329
|
+
this.outer.addClass("lg-first-slide-loading");
|
|
2330
|
+
return dummyImgContentImg;
|
|
2331
|
+
}
|
|
2332
|
+
return "";
|
|
2333
|
+
}
|
|
2334
|
+
setImgMarkup(src, $currentSlide, index) {
|
|
2335
|
+
const currentGalleryItem = this.galleryItems[index];
|
|
2336
|
+
const { alt, srcset, sizes, sources } = currentGalleryItem;
|
|
2337
|
+
let imgContent = "";
|
|
2338
|
+
const altAttr = alt ? 'alt="' + alt + '"' : "";
|
|
2339
|
+
if (this.isFirstSlideWithZoomAnimation()) {
|
|
2340
|
+
imgContent = this.getDummyImageContent(
|
|
2341
|
+
$currentSlide,
|
|
2342
|
+
index,
|
|
2343
|
+
altAttr
|
|
2344
|
+
);
|
|
2345
|
+
} else {
|
|
2346
|
+
imgContent = utils.getImgMarkup(
|
|
2347
|
+
index,
|
|
2348
|
+
src,
|
|
2349
|
+
altAttr,
|
|
2350
|
+
srcset,
|
|
2351
|
+
sizes,
|
|
2352
|
+
sources
|
|
2353
|
+
);
|
|
2354
|
+
}
|
|
2355
|
+
const picture = document.createElement("picture");
|
|
2356
|
+
picture.className = "lg-img-wrap";
|
|
2357
|
+
$LG(picture).append(imgContent);
|
|
2358
|
+
$currentSlide.prepend(picture);
|
|
2359
|
+
}
|
|
2360
|
+
onSlideObjectLoad($slide, isHTML5VideoWithoutPoster, onLoad, onError) {
|
|
2361
|
+
const mediaObject = $slide.find(".lg-object").first();
|
|
2362
|
+
const media = mediaObject.get();
|
|
2363
|
+
const gated = (handler) => {
|
|
2364
|
+
if (media instanceof HTMLImageElement && typeof media.decode === "function") {
|
|
2365
|
+
void awaitDecode(media).then(handler);
|
|
2366
|
+
} else {
|
|
2367
|
+
handler();
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
2370
|
+
if (utils.isImageLoaded(media) || isHTML5VideoWithoutPoster) {
|
|
2371
|
+
gated(onLoad);
|
|
2372
|
+
} else {
|
|
2373
|
+
mediaObject.on("load.lg error.lg", () => {
|
|
2374
|
+
gated(() => onLoad && onLoad());
|
|
2375
|
+
});
|
|
2376
|
+
mediaObject.on("error.lg", () => {
|
|
2377
|
+
onError && onError();
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
*
|
|
2383
|
+
* @param $el Current slide item
|
|
2384
|
+
* @param index
|
|
2385
|
+
* @param delay Delay is 0 except first time
|
|
2386
|
+
* @param speed Speed is same as delay, except it is 0 if gallery is opened via hash plugin
|
|
2387
|
+
* @param isFirstSlide
|
|
2388
|
+
*/
|
|
2389
|
+
onLgObjectLoad(currentSlide, index, delay, speed, isFirstSlide, isHTML5VideoWithoutPoster) {
|
|
2390
|
+
this.onSlideObjectLoad(
|
|
2391
|
+
currentSlide,
|
|
2392
|
+
isHTML5VideoWithoutPoster,
|
|
2393
|
+
() => {
|
|
2394
|
+
this.triggerSlideItemLoad(
|
|
2395
|
+
currentSlide,
|
|
2396
|
+
index,
|
|
2397
|
+
delay,
|
|
2398
|
+
speed,
|
|
2399
|
+
isFirstSlide
|
|
2400
|
+
);
|
|
2401
|
+
},
|
|
2402
|
+
() => {
|
|
2403
|
+
currentSlide.addClass("lg-complete lg-complete_");
|
|
2404
|
+
currentSlide.html(
|
|
2405
|
+
'<span class="lg-error-msg">' + this.settings.strings["mediaLoadingFailed"] + "</span>"
|
|
2406
|
+
);
|
|
2407
|
+
}
|
|
2408
|
+
);
|
|
2409
|
+
}
|
|
2410
|
+
triggerSlideItemLoad($currentSlide, index, delay, speed, isFirstSlide) {
|
|
2411
|
+
const currentGalleryItem = this.galleryItems[index];
|
|
2412
|
+
const _speed = isFirstSlide && this.getSlideType(currentGalleryItem) === "video" && !currentGalleryItem.poster ? speed : 0;
|
|
2413
|
+
setTimeout(() => {
|
|
2414
|
+
$currentSlide.addClass("lg-complete lg-complete_");
|
|
2415
|
+
this.LGel.trigger(lGEvents.slideItemLoad, {
|
|
2416
|
+
index,
|
|
2417
|
+
delay: delay || 0,
|
|
2418
|
+
isFirstSlide
|
|
2419
|
+
});
|
|
2420
|
+
}, _speed);
|
|
2421
|
+
}
|
|
2422
|
+
isFirstSlideWithZoomAnimation() {
|
|
2423
|
+
return !!(!this.lGalleryOn && this.zoomFromOrigin && this.currentImageSize);
|
|
2424
|
+
}
|
|
2425
|
+
// Add video slideInfo
|
|
2426
|
+
addSlideVideoInfo(items) {
|
|
2427
|
+
items.forEach((element, index) => {
|
|
2428
|
+
element.__slideVideoInfo = utils.isVideo(
|
|
2429
|
+
element.src,
|
|
2430
|
+
!!element.video,
|
|
2431
|
+
index
|
|
2432
|
+
);
|
|
2433
|
+
const videoInfo = element.__slideVideoInfo;
|
|
2434
|
+
if (!videoInfo) {
|
|
2435
|
+
return;
|
|
2436
|
+
}
|
|
2437
|
+
if (this.settings.videoFacade !== false) {
|
|
2438
|
+
element.poster = getFacadePoster(
|
|
2439
|
+
element,
|
|
2440
|
+
videoInfo,
|
|
2441
|
+
this.settings.loadYouTubePoster
|
|
2442
|
+
);
|
|
2443
|
+
} else if (this.settings.loadYouTubePoster && !element.poster && videoInfo.youtube) {
|
|
2444
|
+
element.poster = getYouTubePosterUrl(videoInfo);
|
|
2445
|
+
}
|
|
2446
|
+
});
|
|
2447
|
+
}
|
|
2448
|
+
/**
|
|
2449
|
+
* Load slide content into slide.
|
|
2450
|
+
* This is used to load content into slides that is not visible too
|
|
2451
|
+
* @param {Number} index - index of the slide.
|
|
2452
|
+
* @param {Boolean} rec - if true call loadcontent() function again.
|
|
2453
|
+
*/
|
|
2454
|
+
loadContent(index, rec) {
|
|
2455
|
+
const currentGalleryItem = this.galleryItems[index];
|
|
2456
|
+
const $currentSlide = $LG(this.getSlideItemId(index));
|
|
2457
|
+
const { poster, srcset, sizes, sources } = currentGalleryItem;
|
|
2458
|
+
let { src } = currentGalleryItem;
|
|
2459
|
+
const video = currentGalleryItem.video;
|
|
2460
|
+
const _html5Video = video && typeof video === "string" ? JSON.parse(video) : video;
|
|
2461
|
+
if (currentGalleryItem.responsive) {
|
|
2462
|
+
const srcDyItms = currentGalleryItem.responsive.split(",");
|
|
2463
|
+
src = utils.getResponsiveSrc(srcDyItms) || src;
|
|
2464
|
+
}
|
|
2465
|
+
const videoInfo = currentGalleryItem.__slideVideoInfo;
|
|
2466
|
+
let lgVideoStyle = "";
|
|
2467
|
+
const iframe = !!currentGalleryItem.iframe;
|
|
2468
|
+
const isFirstSlide = !this.lGalleryOn;
|
|
2469
|
+
let delay = 0;
|
|
2470
|
+
if (isFirstSlide) {
|
|
2471
|
+
if (this.zoomFromOrigin && this.currentImageSize) {
|
|
2472
|
+
delay = this.settings.startAnimationDuration + 10;
|
|
2473
|
+
} else {
|
|
2474
|
+
delay = this.settings.backdropDuration + 10;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
if (!$currentSlide.hasClass("lg-loaded")) {
|
|
2478
|
+
if (videoInfo) {
|
|
2479
|
+
const { top, bottom } = this.mediaContainerPosition;
|
|
2480
|
+
const videoSize = utils.getSize(
|
|
2481
|
+
this.items[index],
|
|
2482
|
+
this.outer,
|
|
2483
|
+
top + bottom,
|
|
2484
|
+
videoInfo && this.settings.videoMaxSize
|
|
2485
|
+
);
|
|
2486
|
+
lgVideoStyle = this.getVideoContStyle(videoSize);
|
|
2487
|
+
}
|
|
2488
|
+
if (iframe) {
|
|
2489
|
+
const markup = utils.getIframeMarkup(
|
|
2490
|
+
this.settings.iframeWidth,
|
|
2491
|
+
this.settings.iframeHeight,
|
|
2492
|
+
this.settings.iframeMaxWidth,
|
|
2493
|
+
this.settings.iframeMaxHeight,
|
|
2494
|
+
src,
|
|
2495
|
+
currentGalleryItem.iframeTitle
|
|
2496
|
+
);
|
|
2497
|
+
$currentSlide.prepend(markup);
|
|
2498
|
+
} else if (poster) {
|
|
2499
|
+
let dummyImg = "";
|
|
2500
|
+
const hasStartAnimation = isFirstSlide && this.zoomFromOrigin && this.currentImageSize;
|
|
2501
|
+
if (hasStartAnimation) {
|
|
2502
|
+
dummyImg = this.getDummyImageContent(
|
|
2503
|
+
$currentSlide,
|
|
2504
|
+
index,
|
|
2505
|
+
""
|
|
2506
|
+
);
|
|
2507
|
+
}
|
|
2508
|
+
const markup = utils.getVideoPosterMarkup(
|
|
2509
|
+
poster,
|
|
2510
|
+
dummyImg || "",
|
|
2511
|
+
lgVideoStyle,
|
|
2512
|
+
this.settings.strings["playVideo"],
|
|
2513
|
+
videoInfo
|
|
2514
|
+
);
|
|
2515
|
+
$currentSlide.prepend(markup);
|
|
2516
|
+
} else if (videoInfo) {
|
|
2517
|
+
const markup = `<div class="lg-video-cont " style="${lgVideoStyle}"></div>`;
|
|
2518
|
+
$currentSlide.prepend(markup);
|
|
2519
|
+
} else {
|
|
2520
|
+
this.setImgMarkup(src, $currentSlide, index);
|
|
2521
|
+
}
|
|
2522
|
+
if (poster || videoInfo) {
|
|
2523
|
+
this.LGel.trigger(lGEvents.hasVideo, {
|
|
2524
|
+
index,
|
|
2525
|
+
src,
|
|
2526
|
+
html5Video: _html5Video,
|
|
2527
|
+
hasPoster: !!poster
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
this.LGel.trigger(
|
|
2531
|
+
lGEvents.afterAppendSlide,
|
|
2532
|
+
{ index }
|
|
2533
|
+
);
|
|
2534
|
+
if (this.lGalleryOn && this.settings.appendSubHtmlTo === ".lg-item") {
|
|
2535
|
+
this.addHtml(index);
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
let _speed = 0;
|
|
2539
|
+
if (delay && !$LG(document.body).hasClass("lg-from-hash")) {
|
|
2540
|
+
_speed = delay;
|
|
2541
|
+
}
|
|
2542
|
+
if (this.isFirstSlideWithZoomAnimation()) {
|
|
2543
|
+
const settleFlight = (onLanded) => onTransitionSettle(
|
|
2544
|
+
$currentSlide.get(),
|
|
2545
|
+
"transform",
|
|
2546
|
+
this.settings.startAnimationDuration + 100,
|
|
2547
|
+
onLanded
|
|
2548
|
+
);
|
|
2549
|
+
settleFlight(() => {
|
|
2550
|
+
$currentSlide.removeClass("lg-start-end-progress lg-start-progress").removeAttr("style");
|
|
2551
|
+
});
|
|
2552
|
+
if (!$currentSlide.hasClass("lg-loaded")) {
|
|
2553
|
+
settleFlight(() => {
|
|
2554
|
+
if (this.getSlideType(currentGalleryItem) === "image") {
|
|
2555
|
+
const { alt } = currentGalleryItem;
|
|
2556
|
+
const altAttr = alt ? 'alt="' + alt + '"' : "";
|
|
2557
|
+
$currentSlide.find(".lg-img-wrap").append(
|
|
2558
|
+
utils.getImgMarkup(
|
|
2559
|
+
index,
|
|
2560
|
+
src,
|
|
2561
|
+
altAttr,
|
|
2562
|
+
srcset,
|
|
2563
|
+
sizes,
|
|
2564
|
+
currentGalleryItem.sources
|
|
2565
|
+
)
|
|
2566
|
+
);
|
|
2567
|
+
}
|
|
2568
|
+
if (this.getSlideType(currentGalleryItem) === "image" || this.getSlideType(currentGalleryItem) === "video" && poster) {
|
|
2569
|
+
this.onLgObjectLoad(
|
|
2570
|
+
$currentSlide,
|
|
2571
|
+
index,
|
|
2572
|
+
delay,
|
|
2573
|
+
_speed,
|
|
2574
|
+
true,
|
|
2575
|
+
false
|
|
2576
|
+
);
|
|
2577
|
+
this.onSlideObjectLoad(
|
|
2578
|
+
$currentSlide,
|
|
2579
|
+
!!(videoInfo && videoInfo.html5 && !poster),
|
|
2580
|
+
() => {
|
|
2581
|
+
this.loadContentOnFirstSlideLoad(
|
|
2582
|
+
index,
|
|
2583
|
+
$currentSlide,
|
|
2584
|
+
_speed
|
|
2585
|
+
);
|
|
2586
|
+
},
|
|
2587
|
+
() => {
|
|
2588
|
+
this.loadContentOnFirstSlideLoad(
|
|
2589
|
+
index,
|
|
2590
|
+
$currentSlide,
|
|
2591
|
+
_speed
|
|
2592
|
+
);
|
|
2593
|
+
}
|
|
2594
|
+
);
|
|
2595
|
+
}
|
|
2596
|
+
});
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
$currentSlide.addClass("lg-loaded");
|
|
2600
|
+
if (!this.isFirstSlideWithZoomAnimation() || this.getSlideType(currentGalleryItem) === "video" && !poster) {
|
|
2601
|
+
this.onLgObjectLoad(
|
|
2602
|
+
$currentSlide,
|
|
2603
|
+
index,
|
|
2604
|
+
delay,
|
|
2605
|
+
_speed,
|
|
2606
|
+
isFirstSlide,
|
|
2607
|
+
!!(videoInfo && videoInfo.html5 && !poster)
|
|
2608
|
+
);
|
|
2609
|
+
}
|
|
2610
|
+
if ((!this.zoomFromOrigin || !this.currentImageSize) && $currentSlide.hasClass("lg-complete_") && !this.lGalleryOn) {
|
|
2611
|
+
setTimeout(() => {
|
|
2612
|
+
$currentSlide.addClass("lg-complete");
|
|
2613
|
+
}, this.settings.backdropDuration);
|
|
2614
|
+
}
|
|
2615
|
+
this.lGalleryOn = true;
|
|
2616
|
+
if (rec === true) {
|
|
2617
|
+
if (!$currentSlide.hasClass("lg-complete_")) {
|
|
2618
|
+
$currentSlide.find(".lg-object").first().on("load.lg error.lg", () => {
|
|
2619
|
+
this.preload(index);
|
|
2620
|
+
});
|
|
2621
|
+
} else {
|
|
2622
|
+
this.preload(index);
|
|
2623
|
+
}
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
/**
|
|
2627
|
+
* @desc Remove dummy image content and load next slides
|
|
2628
|
+
* Called only for the first time if zoomFromOrigin animation is enabled
|
|
2629
|
+
* @param index
|
|
2630
|
+
* @param $currentSlide
|
|
2631
|
+
* @param speed
|
|
2632
|
+
*/
|
|
2633
|
+
loadContentOnFirstSlideLoad(index, $currentSlide, speed) {
|
|
2634
|
+
setTimeout(() => {
|
|
2635
|
+
$currentSlide.find(".lg-dummy-img").remove();
|
|
2636
|
+
$currentSlide.removeClass("lg-first-slide");
|
|
2637
|
+
this.outer.removeClass("lg-first-slide-loading");
|
|
2638
|
+
this.isDummyImageRemoved = true;
|
|
2639
|
+
this.preload(index);
|
|
2640
|
+
}, speed + 300);
|
|
2641
|
+
}
|
|
2642
|
+
getItemsToBeInsertedToDom(index, prevIndex, numberOfItems = 0) {
|
|
2643
|
+
const itemsToBeInsertedToDom = [];
|
|
2644
|
+
let possibleNumberOfItems = Math.max(numberOfItems, 3);
|
|
2645
|
+
possibleNumberOfItems = Math.min(
|
|
2646
|
+
possibleNumberOfItems,
|
|
2647
|
+
this.galleryItems.length
|
|
2648
|
+
);
|
|
2649
|
+
const prevIndexItem = `lg-item-${this.lgId}-${prevIndex}`;
|
|
2650
|
+
if (this.galleryItems.length <= 3) {
|
|
2651
|
+
this.galleryItems.forEach((_element, index2) => {
|
|
2652
|
+
itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${index2}`);
|
|
2653
|
+
});
|
|
2654
|
+
return itemsToBeInsertedToDom;
|
|
2655
|
+
}
|
|
2656
|
+
if (index < (this.galleryItems.length - 1) / 2) {
|
|
2657
|
+
for (let idx = index; idx > index - possibleNumberOfItems / 2 && idx >= 0; idx--) {
|
|
2658
|
+
itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${idx}`);
|
|
2659
|
+
}
|
|
2660
|
+
const numberOfExistingItems = itemsToBeInsertedToDom.length;
|
|
2661
|
+
for (let idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
|
|
2662
|
+
itemsToBeInsertedToDom.push(
|
|
2663
|
+
`lg-item-${this.lgId}-${index + idx + 1}`
|
|
2664
|
+
);
|
|
2665
|
+
}
|
|
2666
|
+
} else {
|
|
2667
|
+
for (let idx = index; idx <= this.galleryItems.length - 1 && idx < index + possibleNumberOfItems / 2; idx++) {
|
|
2668
|
+
itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${idx}`);
|
|
2669
|
+
}
|
|
2670
|
+
const numberOfExistingItems = itemsToBeInsertedToDom.length;
|
|
2671
|
+
for (let idx = 0; idx < possibleNumberOfItems - numberOfExistingItems; idx++) {
|
|
2672
|
+
itemsToBeInsertedToDom.push(
|
|
2673
|
+
`lg-item-${this.lgId}-${index - idx - 1}`
|
|
2674
|
+
);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
if (this.settings.loop) {
|
|
2678
|
+
if (index === this.galleryItems.length - 1) {
|
|
2679
|
+
itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${0}`);
|
|
2680
|
+
} else if (index === 0) {
|
|
2681
|
+
itemsToBeInsertedToDom.push(
|
|
2682
|
+
`lg-item-${this.lgId}-${this.galleryItems.length - 1}`
|
|
2683
|
+
);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
if (itemsToBeInsertedToDom.indexOf(prevIndexItem) === -1) {
|
|
2687
|
+
itemsToBeInsertedToDom.push(`lg-item-${this.lgId}-${prevIndex}`);
|
|
2688
|
+
}
|
|
2689
|
+
return itemsToBeInsertedToDom;
|
|
2690
|
+
}
|
|
2691
|
+
organizeSlideItems(index, prevIndex) {
|
|
2692
|
+
var _a, _b;
|
|
2693
|
+
const itemsToBeInsertedToDom = this.getItemsToBeInsertedToDom(
|
|
2694
|
+
index,
|
|
2695
|
+
prevIndex,
|
|
2696
|
+
(_b = (_a = this.settings.virtualization) == null ? void 0 : _a.slides) != null ? _b : this.settings.numberOfSlideItemsInDom
|
|
2697
|
+
);
|
|
2698
|
+
itemsToBeInsertedToDom.forEach((item) => {
|
|
2699
|
+
if (this.currentItemsInDom.indexOf(item) === -1) {
|
|
2700
|
+
this.$inner.append(`<div id="${item}" class="lg-item"></div>`);
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
this.currentItemsInDom.forEach((item) => {
|
|
2704
|
+
if (itemsToBeInsertedToDom.indexOf(item) === -1) {
|
|
2705
|
+
$LG(`#${item}`).remove();
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
return itemsToBeInsertedToDom;
|
|
2709
|
+
}
|
|
2710
|
+
/**
|
|
2711
|
+
* Get previous index of the slide
|
|
2712
|
+
*/
|
|
2713
|
+
getPreviousSlideIndex() {
|
|
2714
|
+
let prevIndex = 0;
|
|
2715
|
+
try {
|
|
2716
|
+
const currentItemId = this.outer.find(".lg-current").first().attr("id");
|
|
2717
|
+
prevIndex = parseInt(currentItemId.split("-")[3]) || 0;
|
|
2718
|
+
} catch (error) {
|
|
2719
|
+
prevIndex = 0;
|
|
2720
|
+
}
|
|
2721
|
+
return prevIndex;
|
|
2722
|
+
}
|
|
2723
|
+
setDownloadValue(index) {
|
|
2724
|
+
if (this.settings.download) {
|
|
2725
|
+
const currentGalleryItem = this.galleryItems[index];
|
|
2726
|
+
const hideDownloadBtn = currentGalleryItem.downloadUrl === false || currentGalleryItem.downloadUrl === "false";
|
|
2727
|
+
if (hideDownloadBtn) {
|
|
2728
|
+
this.outer.addClass("lg-hide-download");
|
|
2729
|
+
} else {
|
|
2730
|
+
const $download = this.getElementById("lg-download");
|
|
2731
|
+
this.outer.removeClass("lg-hide-download");
|
|
2732
|
+
$download.attr(
|
|
2733
|
+
"href",
|
|
2734
|
+
currentGalleryItem.downloadUrl || currentGalleryItem.src
|
|
2735
|
+
);
|
|
2736
|
+
if (currentGalleryItem.download) {
|
|
2737
|
+
$download.attr("download", currentGalleryItem.download);
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
makeSlideAnimation(direction, currentSlideItem, previousSlideItem) {
|
|
2743
|
+
if (this.lGalleryOn) {
|
|
2744
|
+
previousSlideItem.addClass("lg-slide-progress");
|
|
2745
|
+
}
|
|
2746
|
+
setTimeout(
|
|
2747
|
+
() => {
|
|
2748
|
+
this.outer.addClass("lg-no-trans");
|
|
2749
|
+
this.outer.find(".lg-item").removeClass("lg-prev-slide lg-next-slide");
|
|
2750
|
+
if (direction === "prev") {
|
|
2751
|
+
currentSlideItem.addClass("lg-prev-slide");
|
|
2752
|
+
previousSlideItem.addClass("lg-next-slide");
|
|
2753
|
+
} else {
|
|
2754
|
+
currentSlideItem.addClass("lg-next-slide");
|
|
2755
|
+
previousSlideItem.addClass("lg-prev-slide");
|
|
2756
|
+
}
|
|
2757
|
+
setTimeout(() => {
|
|
2758
|
+
this.outer.find(".lg-item").removeClass("lg-current");
|
|
2759
|
+
currentSlideItem.addClass("lg-current");
|
|
2760
|
+
this.outer.removeClass("lg-no-trans");
|
|
2761
|
+
}, 50);
|
|
2762
|
+
},
|
|
2763
|
+
this.lGalleryOn ? this.settings.slideDelay : 0
|
|
2764
|
+
);
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* Goto a specific slide.
|
|
2768
|
+
* @param {Number} index - index of the slide
|
|
2769
|
+
* @param {Boolean} fromTouch - true if slide function called via touch event or mouse drag
|
|
2770
|
+
* @param {Boolean} fromThumb - true if slide function called via thumbnail click
|
|
2771
|
+
* @param {String} direction - Direction of the slide(next/prev)
|
|
2772
|
+
* @category lGPublicMethods
|
|
2773
|
+
* @example
|
|
2774
|
+
* const plugin = lightGallery();
|
|
2775
|
+
* // to go to 3rd slide
|
|
2776
|
+
* plugin.slide(2);
|
|
2777
|
+
*
|
|
2778
|
+
*/
|
|
2779
|
+
slide(index, fromTouch, fromThumb, direction) {
|
|
2780
|
+
const prevIndex = this.getPreviousSlideIndex();
|
|
2781
|
+
this.currentItemsInDom = this.organizeSlideItems(index, prevIndex);
|
|
2782
|
+
if (this.lGalleryOn && prevIndex === index) {
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
const numberOfGalleryItems = this.galleryItems.length;
|
|
2786
|
+
if (!this.lgBusy) {
|
|
2787
|
+
if (this.settings.counter) {
|
|
2788
|
+
this.updateCurrentCounter(index);
|
|
2789
|
+
}
|
|
2790
|
+
this.announceSlide(index);
|
|
2791
|
+
const currentSlideItem = this.getSlideItem(index);
|
|
2792
|
+
const previousSlideItem = this.getSlideItem(prevIndex);
|
|
2793
|
+
const currentGalleryItem = this.galleryItems[index];
|
|
2794
|
+
const videoInfo = currentGalleryItem.__slideVideoInfo;
|
|
2795
|
+
this.outer.attr(
|
|
2796
|
+
"data-lg-slide-type",
|
|
2797
|
+
this.getSlideType(currentGalleryItem)
|
|
2798
|
+
);
|
|
2799
|
+
this.setDownloadValue(index);
|
|
2800
|
+
this.updateCurrentImageSize(index);
|
|
2801
|
+
if (videoInfo) {
|
|
2802
|
+
const { top, bottom } = this.mediaContainerPosition;
|
|
2803
|
+
const videoSize = utils.getSize(
|
|
2804
|
+
this.items[index],
|
|
2805
|
+
this.outer,
|
|
2806
|
+
top + bottom,
|
|
2807
|
+
videoInfo && this.settings.videoMaxSize
|
|
2808
|
+
);
|
|
2809
|
+
this.resizeVideoSlide(index, videoSize);
|
|
2810
|
+
}
|
|
2811
|
+
this.LGel.trigger(lGEvents.beforeSlide, {
|
|
2812
|
+
prevIndex,
|
|
2813
|
+
index,
|
|
2814
|
+
fromTouch: !!fromTouch,
|
|
2815
|
+
fromThumb: !!fromThumb
|
|
2816
|
+
});
|
|
2817
|
+
this.lgBusy = true;
|
|
2818
|
+
clearTimeout(this.hideBarTimeout);
|
|
2819
|
+
this.arrowDisable(index);
|
|
2820
|
+
if (!direction) {
|
|
2821
|
+
if (index < prevIndex) {
|
|
2822
|
+
direction = "prev";
|
|
2823
|
+
} else if (index > prevIndex) {
|
|
2824
|
+
direction = "next";
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
if (!fromTouch) {
|
|
2828
|
+
this.makeSlideAnimation(
|
|
2829
|
+
direction,
|
|
2830
|
+
currentSlideItem,
|
|
2831
|
+
previousSlideItem
|
|
2832
|
+
);
|
|
2833
|
+
} else {
|
|
2834
|
+
this.outer.find(".lg-item").removeClass("lg-prev-slide lg-current lg-next-slide");
|
|
2835
|
+
let touchPrev;
|
|
2836
|
+
let touchNext;
|
|
2837
|
+
if (numberOfGalleryItems > 2) {
|
|
2838
|
+
touchPrev = index - 1;
|
|
2839
|
+
touchNext = index + 1;
|
|
2840
|
+
if (index === 0 && prevIndex === numberOfGalleryItems - 1) {
|
|
2841
|
+
touchNext = 0;
|
|
2842
|
+
touchPrev = numberOfGalleryItems - 1;
|
|
2843
|
+
} else if (index === numberOfGalleryItems - 1 && prevIndex === 0) {
|
|
2844
|
+
touchNext = 0;
|
|
2845
|
+
touchPrev = numberOfGalleryItems - 1;
|
|
2846
|
+
}
|
|
2847
|
+
} else {
|
|
2848
|
+
touchPrev = 0;
|
|
2849
|
+
touchNext = 1;
|
|
2850
|
+
}
|
|
2851
|
+
if (direction === "prev") {
|
|
2852
|
+
this.getSlideItem(touchNext).addClass("lg-next-slide");
|
|
2853
|
+
} else {
|
|
2854
|
+
this.getSlideItem(touchPrev).addClass("lg-prev-slide");
|
|
2855
|
+
}
|
|
2856
|
+
currentSlideItem.addClass("lg-current");
|
|
2857
|
+
}
|
|
2858
|
+
if (!this.lGalleryOn) {
|
|
2859
|
+
this.loadContent(index, true);
|
|
2860
|
+
} else {
|
|
2861
|
+
setTimeout(() => {
|
|
2862
|
+
this.loadContent(index, true);
|
|
2863
|
+
if (this.settings.appendSubHtmlTo !== ".lg-item") {
|
|
2864
|
+
this.addHtml(index);
|
|
2865
|
+
}
|
|
2866
|
+
}, this.settings.speed + 50 + (fromTouch ? 0 : this.settings.slideDelay));
|
|
2867
|
+
}
|
|
2868
|
+
setTimeout(() => {
|
|
2869
|
+
this.lgBusy = false;
|
|
2870
|
+
previousSlideItem.removeClass("lg-slide-progress");
|
|
2871
|
+
this.LGel.trigger(lGEvents.afterSlide, {
|
|
2872
|
+
prevIndex,
|
|
2873
|
+
index,
|
|
2874
|
+
fromTouch,
|
|
2875
|
+
fromThumb
|
|
2876
|
+
});
|
|
2877
|
+
}, (this.lGalleryOn ? this.settings.speed + 100 : 100) + (fromTouch ? 0 : this.settings.slideDelay));
|
|
2878
|
+
}
|
|
2879
|
+
this.index = index;
|
|
2880
|
+
}
|
|
2881
|
+
updateCurrentCounter(index) {
|
|
2882
|
+
this.getElementById("lg-counter-current").html(index + 1 + "");
|
|
2883
|
+
}
|
|
2884
|
+
/**
|
|
2885
|
+
* Plain-text caption of a slide for the aria-live announcer. Resolves
|
|
2886
|
+
* the same sources addHtml uses (inline subHtml markup or a selector)
|
|
2887
|
+
* and strips the markup down to readable text. Remote captions
|
|
2888
|
+
* (subHtmlUrl) are skipped, announcing can't wait on a fetch.
|
|
2889
|
+
*/
|
|
2890
|
+
getSlideCaptionText(index) {
|
|
2891
|
+
const currentGalleryItem = this.galleryItems[index];
|
|
2892
|
+
if (!currentGalleryItem || currentGalleryItem.subHtmlUrl) {
|
|
2893
|
+
return "";
|
|
2894
|
+
}
|
|
2895
|
+
let subHtml = currentGalleryItem.subHtml || "";
|
|
2896
|
+
const firstLetter = subHtml.substring(0, 1);
|
|
2897
|
+
if (firstLetter === "." || firstLetter === "#") {
|
|
2898
|
+
try {
|
|
2899
|
+
if (this.settings.subHtmlSelectorRelative && !this.settings.dynamic) {
|
|
2900
|
+
subHtml = $LG(this.items).eq(index).find(subHtml).first().html();
|
|
2901
|
+
} else {
|
|
2902
|
+
subHtml = $LG(subHtml).first().html();
|
|
2903
|
+
}
|
|
2904
|
+
} catch (error) {
|
|
2905
|
+
subHtml = "";
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
if (!subHtml) {
|
|
2909
|
+
return "";
|
|
2910
|
+
}
|
|
2911
|
+
const container = document.createElement("div");
|
|
2912
|
+
container.innerHTML = subHtml;
|
|
2913
|
+
return container.textContent || "";
|
|
2914
|
+
}
|
|
2915
|
+
/**
|
|
2916
|
+
* Update the polite live region with the shown slide's position and
|
|
2917
|
+
* caption ("Image X of Y, caption"). The single announcement source,
|
|
2918
|
+
* counter and caption bar are not live regions while this is enabled.
|
|
2919
|
+
*/
|
|
2920
|
+
announceSlide(index) {
|
|
2921
|
+
if (!this.settings.ariaAnnouncements) {
|
|
2922
|
+
return;
|
|
2923
|
+
}
|
|
2924
|
+
const announcer = this.getElementById("lg-announcer").get();
|
|
2925
|
+
if (!announcer) {
|
|
2926
|
+
return;
|
|
2927
|
+
}
|
|
2928
|
+
announcer.textContent = formatSlideAnnouncement({
|
|
2929
|
+
template: this.settings.strings["slideAnnouncement"],
|
|
2930
|
+
index: index + 1,
|
|
2931
|
+
total: this.galleryItems.length,
|
|
2932
|
+
caption: this.getSlideCaptionText(index)
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
updateCounterTotal() {
|
|
2936
|
+
this.getElementById("lg-counter-all").html(
|
|
2937
|
+
this.galleryItems.length + ""
|
|
2938
|
+
);
|
|
2939
|
+
}
|
|
2940
|
+
getSlideType(item) {
|
|
2941
|
+
if (item.__slideVideoInfo) {
|
|
2942
|
+
return "video";
|
|
2943
|
+
} else if (item.iframe) {
|
|
2944
|
+
return "iframe";
|
|
2945
|
+
} else {
|
|
2946
|
+
return "image";
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
/** Stop a running release spring; visuals stay at the live frame. */
|
|
2950
|
+
stopSlideSpring() {
|
|
2951
|
+
if (this.cancelSlideSpring) {
|
|
2952
|
+
this.cancelSlideSpring();
|
|
2953
|
+
this.cancelSlideSpring = void 0;
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
touchMove(startCoords, endCoords, e) {
|
|
2957
|
+
const distanceX = endCoords.pageX - startCoords.pageX;
|
|
2958
|
+
const distanceY = endCoords.pageY - startCoords.pageY;
|
|
2959
|
+
this.swipeSamples = pushVelocitySample(this.swipeSamples, {
|
|
2960
|
+
x: endCoords.pageX,
|
|
2961
|
+
y: endCoords.pageY,
|
|
2962
|
+
t: Date.now()
|
|
2963
|
+
});
|
|
2964
|
+
this.swipeDirection = getSwipeAxis(
|
|
2965
|
+
distanceX,
|
|
2966
|
+
distanceY,
|
|
2967
|
+
this.swipeDirection
|
|
2968
|
+
);
|
|
2969
|
+
if (!this.swipeDirection) {
|
|
2970
|
+
return;
|
|
2971
|
+
}
|
|
2972
|
+
const $currentSlide = this.getSlideItem(this.index);
|
|
2973
|
+
if (this.swipeDirection === "horizontal") {
|
|
2974
|
+
e == null ? void 0 : e.preventDefault();
|
|
2975
|
+
this.outer.addClass("lg-dragging");
|
|
2976
|
+
const transforms = getHorizontalDragTransforms(
|
|
2977
|
+
this.getEdgeDragDelta(distanceX),
|
|
2978
|
+
$currentSlide.get().offsetWidth,
|
|
2979
|
+
this.getDirection()
|
|
2980
|
+
);
|
|
2981
|
+
$currentSlide.css("transform", transforms.current);
|
|
2982
|
+
this.outer.find(".lg-prev-slide").first().css("transform", transforms.prev);
|
|
2983
|
+
this.outer.find(".lg-next-slide").first().css("transform", transforms.next);
|
|
2984
|
+
} else if (this.swipeDirection === "vertical") {
|
|
2985
|
+
if (this.settings.swipeToClose) {
|
|
2986
|
+
e == null ? void 0 : e.preventDefault();
|
|
2987
|
+
this.$container.addClass("lg-dragging-vertical");
|
|
2988
|
+
const effects = getVerticalDragEffects(
|
|
2989
|
+
distanceY,
|
|
2990
|
+
window.innerWidth,
|
|
2991
|
+
window.innerHeight
|
|
2992
|
+
);
|
|
2993
|
+
this.$backdrop.css("opacity", effects.backdropOpacity);
|
|
2994
|
+
$currentSlide.css("transform", effects.transform);
|
|
2995
|
+
if (effects.hideUi) {
|
|
2996
|
+
this.outer.addClass("lg-hide-items").removeClass("lg-components-open");
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
* The horizontal delta as rendered: rubber-banded when the drag
|
|
3003
|
+
* points past the first/last slide with nothing there (loop counts).
|
|
3004
|
+
*/
|
|
3005
|
+
getEdgeDragDelta(distanceX) {
|
|
3006
|
+
const count = this.galleryItems.length;
|
|
3007
|
+
return getEdgeFrictionedDelta(
|
|
3008
|
+
distanceX,
|
|
3009
|
+
resolveSwipeTarget(
|
|
3010
|
+
"prev",
|
|
3011
|
+
this.index,
|
|
3012
|
+
count,
|
|
3013
|
+
this.settings.loop
|
|
3014
|
+
) !== null,
|
|
3015
|
+
resolveSwipeTarget(
|
|
3016
|
+
"next",
|
|
3017
|
+
this.index,
|
|
3018
|
+
count,
|
|
3019
|
+
this.settings.loop
|
|
3020
|
+
) !== null,
|
|
3021
|
+
this.getDirection()
|
|
3022
|
+
);
|
|
3023
|
+
}
|
|
3024
|
+
/** Resolved reading direction ('auto' is resolved at init). */
|
|
3025
|
+
getDirection() {
|
|
3026
|
+
return this.settings.direction === "rtl" ? "rtl" : "ltr";
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Spring the dragged slides back to rest, seeded with the release
|
|
3030
|
+
* velocity. Returns false (no spring) for sub-pixel drags.
|
|
3031
|
+
*/
|
|
3032
|
+
springSlidesBack(deltaX, velocityX) {
|
|
3033
|
+
if (Math.abs(deltaX) < 1) {
|
|
3034
|
+
return false;
|
|
3035
|
+
}
|
|
3036
|
+
const $currentSlide = this.getSlideItem(this.index);
|
|
3037
|
+
const $prev = this.outer.find(".lg-prev-slide").first();
|
|
3038
|
+
const $next = this.outer.find(".lg-next-slide").first();
|
|
3039
|
+
const width = $currentSlide.get().offsetWidth;
|
|
3040
|
+
this.stopSlideSpring();
|
|
3041
|
+
this.cancelSlideSpring = runSprings(
|
|
3042
|
+
[{ from: deltaX, velocity: velocityX, target: 0 }],
|
|
3043
|
+
([x]) => {
|
|
3044
|
+
const transforms = getHorizontalDragTransforms(
|
|
3045
|
+
x,
|
|
3046
|
+
width,
|
|
3047
|
+
this.getDirection()
|
|
3048
|
+
);
|
|
3049
|
+
$currentSlide.css("transform", transforms.current);
|
|
3050
|
+
$prev.css("transform", transforms.prev);
|
|
3051
|
+
$next.css("transform", transforms.next);
|
|
3052
|
+
},
|
|
3053
|
+
() => {
|
|
3054
|
+
this.cancelSlideSpring = void 0;
|
|
3055
|
+
this.endDragVisuals();
|
|
3056
|
+
}
|
|
3057
|
+
);
|
|
3058
|
+
return true;
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Carry the release velocity into a gesture navigation: navigate
|
|
3062
|
+
* immediately (events, counter and busy-lock on time; fromTouch
|
|
3063
|
+
* classes flip underneath, inline transforms keep the visuals),
|
|
3064
|
+
* then spring the same drag geometry until the arriving slide lands
|
|
3065
|
+
* at rest. Falls back to a snap-back when navigation declines
|
|
3066
|
+
* (busy, or an edge without loop, the 2.x end animation plays).
|
|
3067
|
+
*/
|
|
3068
|
+
springSlideNavigation(verdict, deltaX, velocityX) {
|
|
3069
|
+
const $current = this.getSlideItem(this.index);
|
|
3070
|
+
const $prev = this.outer.find(".lg-prev-slide").first();
|
|
3071
|
+
const $next = this.outer.find(".lg-next-slide").first();
|
|
3072
|
+
const width = $current.get().offsetWidth;
|
|
3073
|
+
if (!width) {
|
|
3074
|
+
return false;
|
|
3075
|
+
}
|
|
3076
|
+
const prevIndex = this.index;
|
|
3077
|
+
if (verdict === "next") {
|
|
3078
|
+
this.goToNextSlide(true);
|
|
3079
|
+
} else {
|
|
3080
|
+
this.goToPrevSlide(true);
|
|
3081
|
+
}
|
|
3082
|
+
if (this.index === prevIndex) {
|
|
3083
|
+
return this.springSlidesBack(deltaX, velocityX);
|
|
3084
|
+
}
|
|
3085
|
+
const target = (verdict === "next" ? -1 : 1) * (this.getDirection() === "rtl" ? -1 : 1) * (width * 115 / 110);
|
|
3086
|
+
this.stopSlideSpring();
|
|
3087
|
+
this.cancelSlideSpring = runSprings(
|
|
3088
|
+
[{ from: deltaX, velocity: velocityX, target }],
|
|
3089
|
+
([x]) => {
|
|
3090
|
+
const transforms = getHorizontalDragTransforms(
|
|
3091
|
+
x,
|
|
3092
|
+
width,
|
|
3093
|
+
this.getDirection()
|
|
3094
|
+
);
|
|
3095
|
+
$current.css("transform", transforms.current);
|
|
3096
|
+
$prev.css("transform", transforms.prev);
|
|
3097
|
+
$next.css("transform", transforms.next);
|
|
3098
|
+
},
|
|
3099
|
+
() => {
|
|
3100
|
+
this.cancelSlideSpring = void 0;
|
|
3101
|
+
this.endDragVisuals();
|
|
3102
|
+
}
|
|
3103
|
+
);
|
|
3104
|
+
return true;
|
|
3105
|
+
}
|
|
3106
|
+
/**
|
|
3107
|
+
* Hand the slides back to CSS after a gesture. The inline transforms
|
|
3108
|
+
* go first, while lg-dragging still pins transition-duration to 0s,
|
|
3109
|
+
* so the snap from the released position to the slide's resting
|
|
3110
|
+
* place lands in a single frame. Dropping the class first animates
|
|
3111
|
+
* that snap instead, and the outgoing slide is seen travelling back
|
|
3112
|
+
* toward the centre while its fade is still running.
|
|
3113
|
+
*/
|
|
3114
|
+
endDragVisuals() {
|
|
3115
|
+
this.outer.find(".lg-item").removeAttr("style");
|
|
3116
|
+
if (this.settings.mode !== "lg-slide") {
|
|
3117
|
+
this.outer.removeClass("lg-slide");
|
|
3118
|
+
}
|
|
3119
|
+
void this.outer.get().offsetHeight;
|
|
3120
|
+
this.outer.removeClass("lg-dragging");
|
|
3121
|
+
}
|
|
3122
|
+
/**
|
|
3123
|
+
* Spring a non-closing vertical drag back to rest, slide transform
|
|
3124
|
+
* and backdrop opacity together, seeded with the release velocity.
|
|
3125
|
+
*/
|
|
3126
|
+
springVerticalRestore(deltaY, velocityY) {
|
|
3127
|
+
if (Math.abs(deltaY) < 1) {
|
|
3128
|
+
return false;
|
|
3129
|
+
}
|
|
3130
|
+
const $currentSlide = this.getSlideItem(this.index);
|
|
3131
|
+
this.stopSlideSpring();
|
|
3132
|
+
this.$container.addClass("lg-dragging-vertical");
|
|
3133
|
+
this.cancelSlideSpring = runSprings(
|
|
3134
|
+
[{ from: deltaY, velocity: velocityY, target: 0 }],
|
|
3135
|
+
([y]) => {
|
|
3136
|
+
const effects = getVerticalDragEffects(
|
|
3137
|
+
y,
|
|
3138
|
+
window.innerWidth,
|
|
3139
|
+
window.innerHeight
|
|
3140
|
+
);
|
|
3141
|
+
this.$backdrop.css("opacity", effects.backdropOpacity);
|
|
3142
|
+
$currentSlide.css("transform", effects.transform);
|
|
3143
|
+
},
|
|
3144
|
+
() => {
|
|
3145
|
+
this.cancelSlideSpring = void 0;
|
|
3146
|
+
this.$container.removeClass("lg-dragging-vertical");
|
|
3147
|
+
this.endDragVisuals();
|
|
3148
|
+
this.$backdrop.css("opacity", 1);
|
|
3149
|
+
}
|
|
3150
|
+
);
|
|
3151
|
+
return true;
|
|
3152
|
+
}
|
|
3153
|
+
touchEnd(endCoords, startCoords, event) {
|
|
3154
|
+
const releaseVelocity = getWindowedVelocity(
|
|
3155
|
+
this.swipeSamples,
|
|
3156
|
+
Date.now()
|
|
3157
|
+
);
|
|
3158
|
+
if (this.settings.mode !== "lg-slide") {
|
|
3159
|
+
this.outer.addClass("lg-slide");
|
|
3160
|
+
}
|
|
3161
|
+
setTimeout(() => {
|
|
3162
|
+
this.$container.removeClass("lg-dragging-vertical");
|
|
3163
|
+
this.outer.removeClass("lg-hide-items").addClass("lg-components-open");
|
|
3164
|
+
let triggerClick = true;
|
|
3165
|
+
let springing = false;
|
|
3166
|
+
if (this.swipeDirection === "horizontal") {
|
|
3167
|
+
const verdict = getSwipeReleaseVerdict({
|
|
3168
|
+
deltaX: endCoords.pageX - startCoords.pageX,
|
|
3169
|
+
velocityX: releaseVelocity.x,
|
|
3170
|
+
threshold: this.settings.swipeThreshold,
|
|
3171
|
+
flickVelocity: this.settings.flickVelocity,
|
|
3172
|
+
viewportWidth: this.outer.get().offsetWidth,
|
|
3173
|
+
direction: this.getDirection()
|
|
3174
|
+
});
|
|
3175
|
+
const renderedDeltaX = this.getEdgeDragDelta(
|
|
3176
|
+
endCoords.pageX - startCoords.pageX
|
|
3177
|
+
);
|
|
3178
|
+
if (verdict === "next" || verdict === "prev") {
|
|
3179
|
+
triggerClick = false;
|
|
3180
|
+
springing = this.springSlideNavigation(
|
|
3181
|
+
verdict,
|
|
3182
|
+
renderedDeltaX,
|
|
3183
|
+
releaseVelocity.x
|
|
3184
|
+
);
|
|
3185
|
+
} else {
|
|
3186
|
+
springing = this.springSlidesBack(
|
|
3187
|
+
renderedDeltaX,
|
|
3188
|
+
releaseVelocity.x
|
|
3189
|
+
);
|
|
3190
|
+
}
|
|
3191
|
+
} else if (this.swipeDirection === "vertical") {
|
|
3192
|
+
if (shouldCloseOnVerticalDrag(
|
|
3193
|
+
endCoords.pageY - startCoords.pageY,
|
|
3194
|
+
releaseVelocity.y,
|
|
3195
|
+
window.innerHeight,
|
|
3196
|
+
{
|
|
3197
|
+
closable: this.settings.closable,
|
|
3198
|
+
swipeToClose: this.settings.swipeToClose
|
|
3199
|
+
}
|
|
3200
|
+
)) {
|
|
3201
|
+
this.closeGallery();
|
|
3202
|
+
return;
|
|
3203
|
+
}
|
|
3204
|
+
if (this.settings.swipeToClose) {
|
|
3205
|
+
springing = this.springVerticalRestore(
|
|
3206
|
+
endCoords.pageY - startCoords.pageY,
|
|
3207
|
+
releaseVelocity.y
|
|
3208
|
+
);
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
if (!springing) {
|
|
3212
|
+
this.endDragVisuals();
|
|
3213
|
+
this.$backdrop.css("opacity", 1);
|
|
3214
|
+
}
|
|
3215
|
+
if (triggerClick && Math.abs(endCoords.pageX - startCoords.pageX) < 5) {
|
|
3216
|
+
const target = $LG(event.target);
|
|
3217
|
+
if (this.isPosterElement(target)) {
|
|
3218
|
+
this.LGel.trigger(lGEvents.posterClick);
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3221
|
+
this.swipeDirection = void 0;
|
|
3222
|
+
});
|
|
3223
|
+
setTimeout(() => {
|
|
3224
|
+
if (!this.outer.hasClass("lg-dragging") && this.settings.mode !== "lg-slide") {
|
|
3225
|
+
this.outer.removeClass("lg-slide");
|
|
3226
|
+
}
|
|
3227
|
+
}, this.settings.speed + 100);
|
|
3228
|
+
}
|
|
3229
|
+
enableSwipe() {
|
|
3230
|
+
let startCoords = {};
|
|
3231
|
+
let endCoords = {};
|
|
3232
|
+
let isMoved = false;
|
|
3233
|
+
let isSwiping = false;
|
|
3234
|
+
if (this.settings.enableSwipe) {
|
|
3235
|
+
this.$inner.on("touchstart.lg", (e) => {
|
|
3236
|
+
this.dragOrSwipeEnabled = true;
|
|
3237
|
+
const $item = this.getSlideItem(this.index);
|
|
3238
|
+
if (($LG(e.target).hasClass("lg-item") || $item.get().contains(e.target)) && !this.outer.hasClass("lg-zoomed") && !this.lgBusy && e.touches.length === 1) {
|
|
3239
|
+
isSwiping = true;
|
|
3240
|
+
this.touchAction = "swipe";
|
|
3241
|
+
isMoved = false;
|
|
3242
|
+
endCoords = {};
|
|
3243
|
+
this.stopSlideSpring();
|
|
3244
|
+
this.manageSwipeClass();
|
|
3245
|
+
this.swipeSamples = [
|
|
3246
|
+
{
|
|
3247
|
+
x: e.touches[0].pageX,
|
|
3248
|
+
y: e.touches[0].pageY,
|
|
3249
|
+
t: Date.now()
|
|
3250
|
+
}
|
|
3251
|
+
];
|
|
3252
|
+
startCoords = {
|
|
3253
|
+
pageX: e.touches[0].pageX,
|
|
3254
|
+
pageY: e.touches[0].pageY
|
|
3255
|
+
};
|
|
3256
|
+
}
|
|
3257
|
+
});
|
|
3258
|
+
this.$inner.on("touchmove.lg", (e) => {
|
|
3259
|
+
if (isSwiping && this.touchAction === "swipe" && e.touches.length === 1) {
|
|
3260
|
+
endCoords = {
|
|
3261
|
+
pageX: e.touches[0].pageX,
|
|
3262
|
+
pageY: e.touches[0].pageY
|
|
3263
|
+
};
|
|
3264
|
+
this.touchMove(startCoords, endCoords, e);
|
|
3265
|
+
isMoved = true;
|
|
3266
|
+
}
|
|
3267
|
+
});
|
|
3268
|
+
this.$inner.on("touchend.lg", (event) => {
|
|
3269
|
+
if (this.touchAction === "swipe") {
|
|
3270
|
+
if (isMoved) {
|
|
3271
|
+
isMoved = false;
|
|
3272
|
+
this.touchEnd(endCoords, startCoords, event);
|
|
3273
|
+
} else if (isSwiping) {
|
|
3274
|
+
const target = $LG(event.target);
|
|
3275
|
+
if (this.isPosterElement(target)) {
|
|
3276
|
+
this.LGel.trigger(lGEvents.posterClick);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
this.touchAction = void 0;
|
|
3280
|
+
isSwiping = false;
|
|
3281
|
+
}
|
|
3282
|
+
});
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
enableDrag() {
|
|
3286
|
+
let startCoords = {};
|
|
3287
|
+
let endCoords = {};
|
|
3288
|
+
let isDraging = false;
|
|
3289
|
+
let isMoved = false;
|
|
3290
|
+
if (this.settings.enableDrag) {
|
|
3291
|
+
this.outer.on("mousedown.lg", (e) => {
|
|
3292
|
+
this.dragOrSwipeEnabled = true;
|
|
3293
|
+
const $item = this.getSlideItem(this.index);
|
|
3294
|
+
if ($LG(e.target).hasClass("lg-item") || $item.get().contains(e.target)) {
|
|
3295
|
+
if (!this.outer.hasClass("lg-zoomed") && !this.lgBusy) {
|
|
3296
|
+
e.preventDefault();
|
|
3297
|
+
this.stopSlideSpring();
|
|
3298
|
+
this.manageSwipeClass();
|
|
3299
|
+
this.swipeSamples = [
|
|
3300
|
+
{ x: e.pageX, y: e.pageY, t: Date.now() }
|
|
3301
|
+
];
|
|
3302
|
+
startCoords = {
|
|
3303
|
+
pageX: e.pageX,
|
|
3304
|
+
pageY: e.pageY
|
|
3305
|
+
};
|
|
3306
|
+
isDraging = true;
|
|
3307
|
+
this.outer.get().scrollLeft += 1;
|
|
3308
|
+
this.outer.get().scrollLeft -= 1;
|
|
3309
|
+
this.outer.removeClass("lg-grab").addClass("lg-grabbing");
|
|
3310
|
+
this.LGel.trigger(lGEvents.dragStart);
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
});
|
|
3314
|
+
$LG(window).on(`mousemove.lg.global${this.lgId}`, (e) => {
|
|
3315
|
+
if (isDraging && this.lgOpened) {
|
|
3316
|
+
isMoved = true;
|
|
3317
|
+
endCoords = {
|
|
3318
|
+
pageX: e.pageX,
|
|
3319
|
+
pageY: e.pageY
|
|
3320
|
+
};
|
|
3321
|
+
this.touchMove(startCoords, endCoords);
|
|
3322
|
+
this.LGel.trigger(lGEvents.dragMove);
|
|
3323
|
+
}
|
|
3324
|
+
});
|
|
3325
|
+
$LG(window).on(`mouseup.lg.global${this.lgId}`, (event) => {
|
|
3326
|
+
if (!this.lgOpened) {
|
|
3327
|
+
return;
|
|
3328
|
+
}
|
|
3329
|
+
const target = $LG(event.target);
|
|
3330
|
+
if (isMoved) {
|
|
3331
|
+
isMoved = false;
|
|
3332
|
+
this.touchEnd(endCoords, startCoords, event);
|
|
3333
|
+
this.LGel.trigger(lGEvents.dragEnd);
|
|
3334
|
+
} else if (this.isPosterElement(target)) {
|
|
3335
|
+
this.LGel.trigger(lGEvents.posterClick);
|
|
3336
|
+
}
|
|
3337
|
+
if (isDraging) {
|
|
3338
|
+
isDraging = false;
|
|
3339
|
+
this.outer.removeClass("lg-grabbing").addClass("lg-grab");
|
|
3340
|
+
}
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
triggerPosterClick() {
|
|
3345
|
+
this.$inner.on("click.lg", (event) => {
|
|
3346
|
+
if (!this.dragOrSwipeEnabled && this.isPosterElement($LG(event.target))) {
|
|
3347
|
+
this.LGel.trigger(lGEvents.posterClick);
|
|
3348
|
+
}
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
manageSwipeClass() {
|
|
3352
|
+
let _touchNext = this.index + 1;
|
|
3353
|
+
let _touchPrev = this.index - 1;
|
|
3354
|
+
if (this.settings.loop && this.galleryItems.length > 2) {
|
|
3355
|
+
if (this.index === 0) {
|
|
3356
|
+
_touchPrev = this.galleryItems.length - 1;
|
|
3357
|
+
} else if (this.index === this.galleryItems.length - 1) {
|
|
3358
|
+
_touchNext = 0;
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
this.outer.find(".lg-item").removeClass("lg-next-slide lg-prev-slide");
|
|
3362
|
+
if (_touchPrev > -1) {
|
|
3363
|
+
this.getSlideItem(_touchPrev).addClass("lg-prev-slide");
|
|
3364
|
+
}
|
|
3365
|
+
this.getSlideItem(_touchNext).addClass("lg-next-slide");
|
|
3366
|
+
}
|
|
3367
|
+
/**
|
|
3368
|
+
* Go to next slide
|
|
3369
|
+
* @param {Boolean} fromTouch - true if slide function called via touch event
|
|
3370
|
+
* @category lGPublicMethods
|
|
3371
|
+
* @example
|
|
3372
|
+
* const plugin = lightGallery();
|
|
3373
|
+
* plugin.goToNextSlide();
|
|
3374
|
+
* @see <a href="/demos/methods/">Demo</a>
|
|
3375
|
+
*/
|
|
3376
|
+
goToNextSlide(fromTouch) {
|
|
3377
|
+
let _loop = this.settings.loop;
|
|
3378
|
+
if (fromTouch && this.galleryItems.length < 3) {
|
|
3379
|
+
_loop = false;
|
|
3380
|
+
}
|
|
3381
|
+
if (!this.lgBusy) {
|
|
3382
|
+
if (this.index + 1 < this.galleryItems.length) {
|
|
3383
|
+
this.index++;
|
|
3384
|
+
this.LGel.trigger(lGEvents.beforeNextSlide, {
|
|
3385
|
+
index: this.index
|
|
3386
|
+
});
|
|
3387
|
+
this.slide(this.index, !!fromTouch, false, "next");
|
|
3388
|
+
} else {
|
|
3389
|
+
if (_loop) {
|
|
3390
|
+
this.index = 0;
|
|
3391
|
+
this.LGel.trigger(lGEvents.beforeNextSlide, {
|
|
3392
|
+
index: this.index
|
|
3393
|
+
});
|
|
3394
|
+
this.slide(this.index, !!fromTouch, false, "next");
|
|
3395
|
+
} else if (this.settings.slideEndAnimation && !fromTouch) {
|
|
3396
|
+
this.outer.addClass("lg-right-end");
|
|
3397
|
+
setTimeout(() => {
|
|
3398
|
+
this.outer.removeClass("lg-right-end");
|
|
3399
|
+
}, 400);
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
/**
|
|
3405
|
+
* Go to previous slides
|
|
3406
|
+
* @param {Boolean} fromTouch - true if slide function called via touch event
|
|
3407
|
+
* @category lGPublicMethods
|
|
3408
|
+
* @example
|
|
3409
|
+
* const plugin = lightGallery({});
|
|
3410
|
+
* plugin.goToPrevSlide();
|
|
3411
|
+
* @see <a href="/demos/methods/">Demo</a>
|
|
3412
|
+
*
|
|
3413
|
+
*/
|
|
3414
|
+
goToPrevSlide(fromTouch) {
|
|
3415
|
+
let _loop = this.settings.loop;
|
|
3416
|
+
if (fromTouch && this.galleryItems.length < 3) {
|
|
3417
|
+
_loop = false;
|
|
3418
|
+
}
|
|
3419
|
+
if (!this.lgBusy) {
|
|
3420
|
+
if (this.index > 0) {
|
|
3421
|
+
this.index--;
|
|
3422
|
+
this.LGel.trigger(lGEvents.beforePrevSlide, {
|
|
3423
|
+
index: this.index,
|
|
3424
|
+
fromTouch
|
|
3425
|
+
});
|
|
3426
|
+
this.slide(this.index, !!fromTouch, false, "prev");
|
|
3427
|
+
} else {
|
|
3428
|
+
if (_loop) {
|
|
3429
|
+
this.index = this.galleryItems.length - 1;
|
|
3430
|
+
this.LGel.trigger(lGEvents.beforePrevSlide, {
|
|
3431
|
+
index: this.index,
|
|
3432
|
+
fromTouch
|
|
3433
|
+
});
|
|
3434
|
+
this.slide(this.index, !!fromTouch, false, "prev");
|
|
3435
|
+
} else if (this.settings.slideEndAnimation && !fromTouch) {
|
|
3436
|
+
this.outer.addClass("lg-left-end");
|
|
3437
|
+
setTimeout(() => {
|
|
3438
|
+
this.outer.removeClass("lg-left-end");
|
|
3439
|
+
}, 400);
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
keyPress() {
|
|
3445
|
+
$LG(window).on(`keydown.lg.global${this.lgId}`, (e) => {
|
|
3446
|
+
if (this.lgOpened && this.settings.escKey === true && e.keyCode === 27) {
|
|
3447
|
+
e.preventDefault();
|
|
3448
|
+
if (this.settings.allowMediaOverlap && this.outer.hasClass("lg-can-toggle") && this.outer.hasClass("lg-components-open")) {
|
|
3449
|
+
this.outer.removeClass("lg-components-open");
|
|
3450
|
+
} else {
|
|
3451
|
+
this.closeGallery();
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
if (this.lgOpened && this.galleryItems.length > 1) {
|
|
3455
|
+
const rtl = this.getDirection() === "rtl";
|
|
3456
|
+
if (e.keyCode === 37) {
|
|
3457
|
+
e.preventDefault();
|
|
3458
|
+
if (rtl) {
|
|
3459
|
+
this.goToNextSlide();
|
|
3460
|
+
} else {
|
|
3461
|
+
this.goToPrevSlide();
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
if (e.keyCode === 39) {
|
|
3465
|
+
e.preventDefault();
|
|
3466
|
+
if (rtl) {
|
|
3467
|
+
this.goToPrevSlide();
|
|
3468
|
+
} else {
|
|
3469
|
+
this.goToNextSlide();
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
});
|
|
3474
|
+
}
|
|
3475
|
+
arrow() {
|
|
3476
|
+
this.getElementById("lg-prev").on("click.lg", () => {
|
|
3477
|
+
this.goToPrevSlide();
|
|
3478
|
+
});
|
|
3479
|
+
this.getElementById("lg-next").on("click.lg", () => {
|
|
3480
|
+
this.goToNextSlide();
|
|
3481
|
+
});
|
|
3482
|
+
}
|
|
3483
|
+
arrowDisable(index) {
|
|
3484
|
+
if (!this.settings.loop && this.settings.hideControlOnEnd) {
|
|
3485
|
+
const $prev = this.getElementById("lg-prev");
|
|
3486
|
+
const $next = this.getElementById("lg-next");
|
|
3487
|
+
if (index + 1 === this.galleryItems.length) {
|
|
3488
|
+
$next.attr("disabled", "disabled").addClass("disabled");
|
|
3489
|
+
} else {
|
|
3490
|
+
$next.removeAttr("disabled").removeClass("disabled");
|
|
3491
|
+
}
|
|
3492
|
+
if (index === 0) {
|
|
3493
|
+
$prev.attr("disabled", "disabled").addClass("disabled");
|
|
3494
|
+
} else {
|
|
3495
|
+
$prev.removeAttr("disabled").removeClass("disabled");
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
setTranslate($el, xValue, yValue, scaleX = 1, scaleY = 1) {
|
|
3500
|
+
$el.css(
|
|
3501
|
+
"transform",
|
|
3502
|
+
"translate3d(" + xValue + "px, " + yValue + "px, 0px) scale3d(" + scaleX + ", " + scaleY + ", 1)"
|
|
3503
|
+
);
|
|
3504
|
+
}
|
|
3505
|
+
mousewheel() {
|
|
3506
|
+
let lastCall = 0;
|
|
3507
|
+
this.outer.on("wheel.lg", (e) => {
|
|
3508
|
+
if (!e.deltaY || this.galleryItems.length < 2) {
|
|
3509
|
+
return;
|
|
3510
|
+
}
|
|
3511
|
+
e.preventDefault();
|
|
3512
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
3513
|
+
if (now - lastCall < 1e3) {
|
|
3514
|
+
return;
|
|
3515
|
+
}
|
|
3516
|
+
lastCall = now;
|
|
3517
|
+
if (e.deltaY > 0) {
|
|
3518
|
+
this.goToNextSlide();
|
|
3519
|
+
} else if (e.deltaY < 0) {
|
|
3520
|
+
this.goToPrevSlide();
|
|
3521
|
+
}
|
|
3522
|
+
});
|
|
3523
|
+
}
|
|
3524
|
+
isSlideElement(target) {
|
|
3525
|
+
return target.hasClass("lg-outer") || target.hasClass("lg-item") || target.hasClass("lg-img-wrap") || target.hasClass("lg-img-rotate");
|
|
3526
|
+
}
|
|
3527
|
+
isPosterElement(target) {
|
|
3528
|
+
const playButton = this.getSlideItem(this.index).find(".lg-video-play-button").get();
|
|
3529
|
+
return target.hasClass("lg-video-poster") || target.hasClass("lg-video-play-button") || playButton && playButton.contains(target.get());
|
|
3530
|
+
}
|
|
3531
|
+
/**
|
|
3532
|
+
* Maximize minimize inline gallery.
|
|
3533
|
+
* @category lGPublicMethods
|
|
3534
|
+
*/
|
|
3535
|
+
toggleMaximize() {
|
|
3536
|
+
this.getElementById("lg-maximize").on("click.lg", () => {
|
|
3537
|
+
this.$container.toggleClass("lg-inline");
|
|
3538
|
+
this.refreshOnResize();
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
invalidateItems() {
|
|
3542
|
+
for (let index = 0; index < this.items.length; index++) {
|
|
3543
|
+
const element = this.items[index];
|
|
3544
|
+
const $element = $LG(element);
|
|
3545
|
+
$element.off(`click.lgcustom-item-${$element.attr("data-lg-id")}`);
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
trapFocus() {
|
|
3549
|
+
this.$container.get().focus({
|
|
3550
|
+
preventScroll: true
|
|
3551
|
+
});
|
|
3552
|
+
$LG(window).on(`keydown.lg.global${this.lgId}`, (e) => {
|
|
3553
|
+
if (!this.lgOpened) {
|
|
3554
|
+
return;
|
|
3555
|
+
}
|
|
3556
|
+
const isTabPressed = e.key === "Tab" || e.keyCode === 9;
|
|
3557
|
+
if (!isTabPressed) {
|
|
3558
|
+
return;
|
|
3559
|
+
}
|
|
3560
|
+
const focusableEls = utils.getFocusableElements(
|
|
3561
|
+
this.$container.get()
|
|
3562
|
+
);
|
|
3563
|
+
const firstFocusableEl = focusableEls[0];
|
|
3564
|
+
const lastFocusableEl = focusableEls[focusableEls.length - 1];
|
|
3565
|
+
if (e.shiftKey) {
|
|
3566
|
+
if (document.activeElement === firstFocusableEl) {
|
|
3567
|
+
lastFocusableEl.focus();
|
|
3568
|
+
e.preventDefault();
|
|
3569
|
+
}
|
|
3570
|
+
} else {
|
|
3571
|
+
if (document.activeElement === lastFocusableEl) {
|
|
3572
|
+
firstFocusableEl.focus();
|
|
3573
|
+
e.preventDefault();
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
});
|
|
3577
|
+
}
|
|
3578
|
+
manageCloseGallery() {
|
|
3579
|
+
if (!this.settings.closable) return;
|
|
3580
|
+
let mousedown = false;
|
|
3581
|
+
this.getElementById("lg-close").on("click.lg", () => {
|
|
3582
|
+
this.closeGallery();
|
|
3583
|
+
});
|
|
3584
|
+
if (this.settings.closeOnTap) {
|
|
3585
|
+
this.outer.on("mousedown.lg", (e) => {
|
|
3586
|
+
const target = $LG(e.target);
|
|
3587
|
+
if (this.isSlideElement(target)) {
|
|
3588
|
+
mousedown = true;
|
|
3589
|
+
} else {
|
|
3590
|
+
mousedown = false;
|
|
3591
|
+
}
|
|
3592
|
+
});
|
|
3593
|
+
this.outer.on("mousemove.lg", () => {
|
|
3594
|
+
mousedown = false;
|
|
3595
|
+
});
|
|
3596
|
+
this.outer.on("mouseup.lg", (e) => {
|
|
3597
|
+
const target = $LG(e.target);
|
|
3598
|
+
if (this.isSlideElement(target) && mousedown) {
|
|
3599
|
+
if (!this.outer.hasClass("lg-dragging")) {
|
|
3600
|
+
this.closeGallery();
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
});
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
/**
|
|
3607
|
+
* Close lightGallery if it is opened.
|
|
3608
|
+
*
|
|
3609
|
+
* @description If closable is false in the settings, you need to pass true via closeGallery method to force close gallery
|
|
3610
|
+
* @return returns the estimated time to close gallery completely including the close animation duration
|
|
3611
|
+
* @category lGPublicMethods
|
|
3612
|
+
* @example
|
|
3613
|
+
* const plugin = lightGallery();
|
|
3614
|
+
* plugin.closeGallery();
|
|
3615
|
+
*
|
|
3616
|
+
*/
|
|
3617
|
+
closeGallery(force) {
|
|
3618
|
+
if (!this.lgOpened || !this.settings.closable && !force) {
|
|
3619
|
+
return 0;
|
|
3620
|
+
}
|
|
3621
|
+
this.LGel.trigger(lGEvents.beforeClose);
|
|
3622
|
+
if (this.settings.resetScrollPosition && !this.settings.hideScrollbar) {
|
|
3623
|
+
$LG(window).scrollTop(this.prevScrollTop);
|
|
3624
|
+
}
|
|
3625
|
+
const currentItem = this.items[this.index];
|
|
3626
|
+
let transform;
|
|
3627
|
+
if (this.zoomFromOrigin && currentItem) {
|
|
3628
|
+
const { top, bottom } = this.mediaContainerPosition;
|
|
3629
|
+
const { __slideVideoInfo, poster } = this.galleryItems[this.index];
|
|
3630
|
+
const imageSize = utils.getSize(
|
|
3631
|
+
currentItem,
|
|
3632
|
+
this.outer,
|
|
3633
|
+
top + bottom,
|
|
3634
|
+
__slideVideoInfo && poster && this.settings.videoMaxSize
|
|
3635
|
+
);
|
|
3636
|
+
transform = this.getOriginTransform(currentItem, imageSize);
|
|
3637
|
+
}
|
|
3638
|
+
if (!transform) {
|
|
3639
|
+
transform = getCenterCloseTransform();
|
|
3640
|
+
this.outer.addClass("lg-close-to-center");
|
|
3641
|
+
}
|
|
3642
|
+
if (transform) {
|
|
3643
|
+
this.outer.addClass("lg-closing lg-zoom-from-image");
|
|
3644
|
+
this.getSlideItem(this.index).addClass("lg-start-end-progress").css(
|
|
3645
|
+
"transition-duration",
|
|
3646
|
+
this.settings.startAnimationDuration + "ms"
|
|
3647
|
+
).css("transform", transform);
|
|
3648
|
+
} else {
|
|
3649
|
+
this.outer.addClass("lg-hide-items");
|
|
3650
|
+
this.outer.removeClass("lg-zoom-from-image");
|
|
3651
|
+
}
|
|
3652
|
+
this.destroyModules();
|
|
3653
|
+
this.lGalleryOn = false;
|
|
3654
|
+
this.isDummyImageRemoved = false;
|
|
3655
|
+
this.zoomFromOrigin = this.settings.zoomFromOrigin;
|
|
3656
|
+
clearTimeout(this.hideBarTimeout);
|
|
3657
|
+
this.hideBarTimeout = false;
|
|
3658
|
+
$LG("html").removeClass("lg-on");
|
|
3659
|
+
this.outer.removeClass("lg-visible lg-components-open");
|
|
3660
|
+
this.$backdrop.removeClass("in").css("opacity", 0);
|
|
3661
|
+
const removeTimeout = transform ? Math.max(
|
|
3662
|
+
this.settings.startAnimationDuration,
|
|
3663
|
+
this.settings.backdropDuration
|
|
3664
|
+
) : this.settings.backdropDuration;
|
|
3665
|
+
this.$container.removeClass("lg-show-in");
|
|
3666
|
+
setTimeout(() => {
|
|
3667
|
+
if (transform) {
|
|
3668
|
+
this.outer.removeClass("lg-zoom-from-image");
|
|
3669
|
+
}
|
|
3670
|
+
this.$container.removeClass("lg-show");
|
|
3671
|
+
this.resetScrollBar();
|
|
3672
|
+
this.$backdrop.removeAttr("style").css(
|
|
3673
|
+
"transition-duration",
|
|
3674
|
+
this.settings.backdropDuration + "ms"
|
|
3675
|
+
);
|
|
3676
|
+
this.outer.removeClass(
|
|
3677
|
+
`lg-closing lg-close-to-center ${this.settings.startClass}`
|
|
3678
|
+
);
|
|
3679
|
+
this.getSlideItem(this.index).removeClass("lg-start-end-progress");
|
|
3680
|
+
this.$inner.empty();
|
|
3681
|
+
const announcer = this.getElementById("lg-announcer").get();
|
|
3682
|
+
if (announcer) {
|
|
3683
|
+
announcer.textContent = "";
|
|
3684
|
+
}
|
|
3685
|
+
if (this.lgOpened) {
|
|
3686
|
+
this.LGel.trigger(lGEvents.afterClose, {
|
|
3687
|
+
instance: this
|
|
3688
|
+
});
|
|
3689
|
+
}
|
|
3690
|
+
if (this.$container.get()) {
|
|
3691
|
+
this.$container.get().blur();
|
|
3692
|
+
}
|
|
3693
|
+
if (this.prevActiveElement && this.prevActiveElement.isConnected) {
|
|
3694
|
+
this.prevActiveElement.focus({ preventScroll: true });
|
|
3695
|
+
}
|
|
3696
|
+
this.prevActiveElement = void 0;
|
|
3697
|
+
this.lgOpened = false;
|
|
3698
|
+
}, removeTimeout + 100);
|
|
3699
|
+
return removeTimeout + 100;
|
|
3700
|
+
}
|
|
3701
|
+
initModules() {
|
|
3702
|
+
this.plugins.forEach((module2) => {
|
|
3703
|
+
try {
|
|
3704
|
+
module2.init();
|
|
3705
|
+
} catch (err) {
|
|
3706
|
+
console.warn(
|
|
3707
|
+
`lightGallery:- make sure lightGallery module is properly initiated. See https://www.lightgalleryjs.com/docs/methods/`
|
|
3708
|
+
);
|
|
3709
|
+
}
|
|
3710
|
+
});
|
|
3711
|
+
}
|
|
3712
|
+
destroyModules(destroy) {
|
|
3713
|
+
this.plugins.forEach((module2) => {
|
|
3714
|
+
try {
|
|
3715
|
+
if (destroy) {
|
|
3716
|
+
module2.destroy();
|
|
3717
|
+
} else {
|
|
3718
|
+
module2.closeGallery && module2.closeGallery();
|
|
3719
|
+
}
|
|
3720
|
+
} catch (err) {
|
|
3721
|
+
console.warn(
|
|
3722
|
+
`lightGallery:- make sure lightGallery module is properly destroyed. See https://www.lightgalleryjs.com/docs/methods/`
|
|
3723
|
+
);
|
|
3724
|
+
}
|
|
3725
|
+
});
|
|
3726
|
+
}
|
|
3727
|
+
/**
|
|
3728
|
+
* Refresh lightGallery with new set of children.
|
|
3729
|
+
*
|
|
3730
|
+
* @description This is useful to update the gallery when the child elements are changed without calling destroy method.
|
|
3731
|
+
*
|
|
3732
|
+
* If you are using dynamic mode, you can pass the modified array of dynamicEl as the first parameter to refresh the dynamic gallery
|
|
3733
|
+
* @see <a href="/demos/dynamic-mode/">Demo</a>
|
|
3734
|
+
* @category lGPublicMethods
|
|
3735
|
+
* @example
|
|
3736
|
+
* const plugin = lightGallery();
|
|
3737
|
+
* // Delete or add children, then call
|
|
3738
|
+
* plugin.refresh();
|
|
3739
|
+
*
|
|
3740
|
+
*/
|
|
3741
|
+
refresh(galleryItems) {
|
|
3742
|
+
if (!this.settings.dynamic) {
|
|
3743
|
+
this.invalidateItems();
|
|
3744
|
+
}
|
|
3745
|
+
if (galleryItems) {
|
|
3746
|
+
this.galleryItems = galleryItems;
|
|
3747
|
+
} else {
|
|
3748
|
+
this.galleryItems = this.getItems();
|
|
3749
|
+
}
|
|
3750
|
+
this.updateControls();
|
|
3751
|
+
this.openGalleryOnItemClick();
|
|
3752
|
+
this.LGel.trigger(lGEvents.updateSlides);
|
|
3753
|
+
}
|
|
3754
|
+
updateControls() {
|
|
3755
|
+
this.addSlideVideoInfo(this.galleryItems);
|
|
3756
|
+
this.updateCounterTotal();
|
|
3757
|
+
this.manageSingleSlideClassName();
|
|
3758
|
+
}
|
|
3759
|
+
destroyGallery() {
|
|
3760
|
+
var _a;
|
|
3761
|
+
this.destroyModules(true);
|
|
3762
|
+
if (!this.settings.dynamic) {
|
|
3763
|
+
this.invalidateItems();
|
|
3764
|
+
}
|
|
3765
|
+
$LG(window).off(`.lg.global${this.lgId}`);
|
|
3766
|
+
this.LGel.off(".lg");
|
|
3767
|
+
(_a = this.toolbarOverflow) == null ? void 0 : _a.destroy();
|
|
3768
|
+
this.toolbarOverflow = void 0;
|
|
3769
|
+
this.$container.remove();
|
|
3770
|
+
}
|
|
3771
|
+
/**
|
|
3772
|
+
* Destroy lightGallery.
|
|
3773
|
+
* Destroy lightGallery and its plugin instances completely
|
|
3774
|
+
*
|
|
3775
|
+
* @description This method also calls CloseGallery function internally. Returns the time takes to completely close and destroy the instance.
|
|
3776
|
+
* In case if you want to re-initialize lightGallery right after destroying it, initialize it only once the destroy process is completed.
|
|
3777
|
+
* You can use refresh method most of the times.
|
|
3778
|
+
* @category lGPublicMethods
|
|
3779
|
+
* @example
|
|
3780
|
+
* const plugin = lightGallery();
|
|
3781
|
+
* plugin.destroy();
|
|
3782
|
+
*
|
|
3783
|
+
*/
|
|
3784
|
+
destroy() {
|
|
3785
|
+
const closeTimeout = this.closeGallery(true);
|
|
3786
|
+
if (closeTimeout) {
|
|
3787
|
+
setTimeout(this.destroyGallery.bind(this), closeTimeout);
|
|
3788
|
+
} else {
|
|
3789
|
+
this.destroyGallery();
|
|
3790
|
+
}
|
|
3791
|
+
return closeTimeout;
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
function lightGallery(el, options) {
|
|
3795
|
+
return new LightGallery(el, options);
|
|
3796
|
+
}
|
|
3797
|
+
lightGallery.setLicenseKey = setLicenseKey;
|
|
3798
|
+
return lightGallery;
|
|
3799
|
+
});
|
|
3800
|
+
//# sourceMappingURL=lightgallery.umd.js.map
|