Merge pull request 'fix lightbox (again) #245, fixes regression introduced in #247' (#250) from h3ndrik/pyfedi:lightbox_again into main

Reviewed-on: https://codeberg.org/rimu/pyfedi/pulls/250
This commit is contained in:
rimu 2024-07-05 08:09:26 +00:00
commit 2de36cf512
3 changed files with 12 additions and 38 deletions

View file

@ -86,6 +86,9 @@ function setupLightboxGallery() {
function setupLightboxTeaser() { function setupLightboxTeaser() {
function popStateListener(event) {
baguetteBox.hide();
}
baguetteBox.run('.post_teaser', { baguetteBox.run('.post_teaser', {
fullScreen: false, fullScreen: false,
noScrollbars: true, noScrollbars: true,
@ -93,18 +96,7 @@ function setupLightboxTeaser() {
preload: 3, preload: 3,
ignoreClass: 'preview_image', ignoreClass: 'preview_image',
afterShow: function() { afterShow: function() {
var backButtonPrevented = false; window.history.pushState('#lightbox', document.title, document.location+'#lightbox');
history.pushState(null, document.title, location.href);
function popStateListener(event) {
if (backButtonPrevented === false){
history.pushState(null, document.title, location.href);
baguetteBox.hide();
backButtonPrevented = true;
} else {
window.removeEventListener('popstate', popStateListener);
history.back();
}
}
window.addEventListener('popstate', popStateListener); window.addEventListener('popstate', popStateListener);
function baguetteBoxClickImg(event) { function baguetteBoxClickImg(event) {
@ -122,6 +114,12 @@ function setupLightboxTeaser() {
el.addEventListener('click', baguetteBoxClickImg); el.addEventListener('click', baguetteBoxClickImg);
} }
}, },
afterHide: function() {
if (window.history.state === '#lightbox') {
window.history.back();
window.removeEventListener('popstate', popStateListener);
}
},
}); });
} }

View file

@ -1428,19 +1428,7 @@ h1 .warning_badge {
} }
#baguetteBox-overlay { #baguetteBox-overlay {
overflow: scroll !important; overflow: scroll;
}
#baguetteBox-overlay .full-image {
height: auto !important;
}
#baguetteBox-overlay .full-image figure {
display: inline-block !important;
}
#baguetteBox-slider {
height: auto !important;
} }
/*# sourceMappingURL=structure.css.map */ /*# sourceMappingURL=structure.css.map */

View file

@ -1106,17 +1106,5 @@ h1 .warning_badge {
} }
#baguetteBox-overlay { #baguetteBox-overlay {
overflow: scroll !important; overflow: scroll;
.full-image {
height: auto !important;
//min-height: 100%;
figure {
display: inline-block !important;
}
}
}
#baguetteBox-slider {
height: auto !important;
//min-height: 100%;
} }