mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-02-02 16:21:32 -08:00
close lightbox on back, zoom and close on click
This commit is contained in:
parent
47dd776ca6
commit
d2598a83ef
1 changed files with 31 additions and 0 deletions
|
@ -88,9 +88,40 @@ function setupLightboxGallery() {
|
|||
function setupLightboxTeaser() {
|
||||
baguetteBox.run('.post_teaser', {
|
||||
fullScreen: false,
|
||||
noScrollbars: true,
|
||||
async: true,
|
||||
preload: 3,
|
||||
ignoreClass: 'preview_image',
|
||||
afterShow: function() {
|
||||
var backButtonPrevented = false;
|
||||
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);
|
||||
|
||||
function baguetteBoxClickImg(event) {
|
||||
if (this.style.width != "100%" && this.offsetWidth < window.innerWidth) {
|
||||
this.style.width = "100%";
|
||||
this.style.maxHeight = "none";
|
||||
} else {
|
||||
this.style.width = "";
|
||||
this.style.maxHeight = "";
|
||||
this.removeEventListener('click', baguetteBoxClickImg);
|
||||
baguetteBox.hide();
|
||||
}
|
||||
};
|
||||
for (const el of document.querySelectorAll('div#baguetteBox-overlay img')) {
|
||||
el.addEventListener('click', baguetteBoxClickImg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue