diff --git a/src/components/project.vue b/src/components/project.vue index a245f1e..a6a7c2d 100644 --- a/src/components/project.vue +++ b/src/components/project.vue @@ -97,7 +97,7 @@ export default { async init() { this.initProject(); this.initLightbox(); - + await Promise.all([ this.initFeed(), this.initMap() @@ -107,7 +107,7 @@ export default { if(this.hash.items.length == 3) await this.findPost(this.hash.items[1], this.hash.items[2]); }, quit() { - this.lightbox?.end(); + this.lightbox.end(); this.$refs.feedSimpleBar.scrollElement.removeEventListener('scroll', this.onFeedScroll); this.setFeedUpdateTimer(-1); this.map.remove(); @@ -121,20 +121,22 @@ export default { this.baseMaps = {}; }, initLightbox() { - this.lightbox = new Lightbox({ - alwaysShowNavOnTouchDevices: true, - albumLabel: 'Media %1 / %2', - fadeDuration: 300, - imageFadeDuration: 400, - positionFromTop: 0, - resizeDuration: 400, - hasVideo: true, - onMediaChange: (oMedia) => { - this.hash.items = [this.currProject.codename, 'media', oMedia.id]; - if(oMedia.set == 'post-medias') this.goToPost('media', oMedia.id); - }, - onClosing: () => {this.hash.items = [this.hash.items[0]];} - }); + if(!this.lightbox) { + this.lightbox = new Lightbox({ + alwaysShowNavOnTouchDevices: true, + albumLabel: 'Media %1 / %2', + fadeDuration: 300, + imageFadeDuration: 400, + positionFromTop: 0, + resizeDuration: 400, + hasVideo: true, + onMediaChange: (oMedia) => { + this.hash.items = [this.currProject.codename, 'media', oMedia.id]; + if(oMedia.set == 'post-medias') this.goToPost('media', oMedia.id); + }, + onClosing: () => {this.hash.items = [this.hash.items[0]];} + }); + } }, async initFeed() { //Simplebar event diff --git a/src/components/projectPost.vue b/src/components/projectPost.vue index f02f645..9168c0b 100644 --- a/src/components/projectPost.vue +++ b/src/components/projectPost.vue @@ -56,7 +56,7 @@ return this.mouseOverDrill?'drill-message':'marker'; }, anchorLink() { - return '#'+[this.hash.page, this.hash.items[0], this.options.type, this.options.id].join(this.consts.hash_sep); + return '#'+[this.hash.page, this.project.currProject.codename, this.options.type, this.options.id].join(this.consts.hash_sep); }, modeHisto() { return (this.project.currProject.mode == this.consts.modes.histo); @@ -104,7 +104,7 @@ this.popupRequested = true; if(this.isMobile()) this.project.toggleFeedPanel(false, 'panToInstant'); - this.hash.items = [this.hash.items[0], this.options.type, this.options.id]; + this.hash.items = [this.project.currProject.codename, this.options.type, this.options.id]; return this.map.panToBetweenPanels(this.relatedMarkerLatLng, this.focusZoomLevel, iAnimDuration).then(() => { this.openMarkerPopup(false); diff --git a/src/scripts/lightbox.js b/src/scripts/lightbox.js index 5e9fec2..def2c20 100644 --- a/src/scripts/lightbox.js +++ b/src/scripts/lightbox.js @@ -41,12 +41,12 @@ export default class Lightbox { init() { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { - this.enable(); this.build(); + this.enable(); }, { once: true }); } else { - this.enable(); this.build(); + this.enable(); } } @@ -66,41 +66,42 @@ export default class Lightbox { } build() { - if (document.getElementById('lightbox')) return; - - const wrapper = document.createElement('div'); - wrapper.innerHTML = ` -
-