feat(gallery): can close gallery when clicking on browser back button
This commit is contained in:
parent
c6a2cb0240
commit
479fdb9dbe
1 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@ import { LightGallery } from 'lightgallery/lightgallery';
|
||||||
import lgThumbnail from 'lightgallery/plugins/thumbnail';
|
import lgThumbnail from 'lightgallery/plugins/thumbnail';
|
||||||
import lgZoom from 'lightgallery/plugins/zoom';
|
import lgZoom from 'lightgallery/plugins/zoom';
|
||||||
import lgRotate from 'lightgallery/plugins/rotate';
|
import lgRotate from 'lightgallery/plugins/rotate';
|
||||||
|
import lgHash from 'lightgallery/plugins/hash';
|
||||||
import 'lightgallery/css/lightgallery-bundle.css';
|
import 'lightgallery/css/lightgallery-bundle.css';
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
|
@ -11,7 +12,7 @@ export default class extends Controller {
|
||||||
|
|
||||||
connect(): void {
|
connect(): void {
|
||||||
const options = {
|
const options = {
|
||||||
plugins: [lgZoom, lgThumbnail, lgRotate],
|
plugins: [lgZoom, lgThumbnail, lgRotate, lgHash],
|
||||||
flipVertical: false,
|
flipVertical: false,
|
||||||
flipHorizontal: false,
|
flipHorizontal: false,
|
||||||
animateThumb: false,
|
animateThumb: false,
|
||||||
|
@ -21,6 +22,14 @@ export default class extends Controller {
|
||||||
selector: '.gallery-link'
|
selector: '.gallery-link'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const gallery = document.querySelector('.gallery');
|
||||||
|
|
||||||
|
if (gallery != null) {
|
||||||
|
gallery.addEventListener('lgBeforeOpen', () => {
|
||||||
|
window.history.pushState({}, 'Gallery opened');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.lightGallery = lightGallery(this.element as HTMLElement, options);
|
this.lightGallery = lightGallery(this.element as HTMLElement, options);
|
||||||
|
|
||||||
const downloadIcon = document.querySelector('.lg-download');
|
const downloadIcon = document.querySelector('.lg-download');
|
||||||
|
|
Loading…
Reference in a new issue