mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 00:52:16 -06:00
bbox: unload pics/vids from DOM; closes #71
videos unloaded correctly when switching between files, but not when closing the lightbox while playing a video and then clicking another now, only media within the preload window (+/- 2 from current file) is kept loaded into DOM, everything else gets ejected, both on navigation and when closing the lightbox
This commit is contained in:
parent
c1180d6f9c
commit
a17c267d87
|
@ -615,7 +615,43 @@ window.baguetteBox = (function () {
|
||||||
|
|
||||||
documentLastFocus && documentLastFocus.focus();
|
documentLastFocus && documentLastFocus.focus();
|
||||||
isOverlayVisible = false;
|
isOverlayVisible = false;
|
||||||
}, 500);
|
unvid();
|
||||||
|
unfig();
|
||||||
|
}, 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
function unvid(keep) {
|
||||||
|
var vids = QSA('#bbox-overlay video');
|
||||||
|
for (var a = vids.length - 1; a >= 0; a--) {
|
||||||
|
var v = vids[a];
|
||||||
|
if (v == keep)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
v.src = '';
|
||||||
|
v.load();
|
||||||
|
|
||||||
|
var p = v.parentNode;
|
||||||
|
p.removeChild(v);
|
||||||
|
p.parentNode.removeChild(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function unfig(keep) {
|
||||||
|
var figs = QSA('#bbox-overlay figure'),
|
||||||
|
npre = options.preload || 0,
|
||||||
|
k = [];
|
||||||
|
|
||||||
|
if (keep === undefined)
|
||||||
|
keep = -9;
|
||||||
|
|
||||||
|
for (var a = keep - npre; a <= keep + npre; a++)
|
||||||
|
k.push('bbox-figure-' + a);
|
||||||
|
|
||||||
|
for (var a = figs.length - 1; a >= 0; a--) {
|
||||||
|
var f = figs[a];
|
||||||
|
if (!has(k, f.getAttribute('id')))
|
||||||
|
f.parentNode.removeChild(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadImage(index, callback) {
|
function loadImage(index, callback) {
|
||||||
|
@ -708,6 +744,7 @@ window.baguetteBox = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function show(index, gallery) {
|
function show(index, gallery) {
|
||||||
|
gallery = gallery || currentGallery;
|
||||||
if (!isOverlayVisible && index >= 0 && index < gallery.length) {
|
if (!isOverlayVisible && index >= 0 && index < gallery.length) {
|
||||||
prepareOverlay(gallery, options);
|
prepareOverlay(gallery, options);
|
||||||
showOverlay(index);
|
showOverlay(index);
|
||||||
|
@ -720,12 +757,10 @@ window.baguetteBox = (function () {
|
||||||
if (index >= imagesElements.length)
|
if (index >= imagesElements.length)
|
||||||
return bounceAnimation('right');
|
return bounceAnimation('right');
|
||||||
|
|
||||||
var v = vid();
|
try {
|
||||||
if (v) {
|
vid().pause();
|
||||||
v.src = '';
|
|
||||||
v.load();
|
|
||||||
v.parentNode.removeChild(v);
|
|
||||||
}
|
}
|
||||||
|
catch (ex) { }
|
||||||
|
|
||||||
currentIndex = index;
|
currentIndex = index;
|
||||||
loadImage(currentIndex, function () {
|
loadImage(currentIndex, function () {
|
||||||
|
@ -734,6 +769,15 @@ window.baguetteBox = (function () {
|
||||||
});
|
});
|
||||||
updateOffset();
|
updateOffset();
|
||||||
|
|
||||||
|
if (options.animation == 'none')
|
||||||
|
unvid(vid());
|
||||||
|
else
|
||||||
|
setTimeout(function () {
|
||||||
|
unvid(vid());
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
unfig(index);
|
||||||
|
|
||||||
if (options.onChange)
|
if (options.onChange)
|
||||||
options.onChange(currentIndex, imagesElements.length);
|
options.onChange(currentIndex, imagesElements.length);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue