This commit is contained in:
SelfishPig 2026-01-11 17:51:25 +01:00 committed by GitHub
commit f396b16386
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -28,7 +28,7 @@ window.baguetteBox = (function () {
onChange: null,
readDirRtl: false,
},
overlay, slider, btnPrev, btnNext, btnHelp, btnAnim, btnRotL, btnRotR, btnSel, btnFull, btnZoom, btnVmode, btnReadDir, btnClose,
overlay, slider, btnPrev, btnNext, btnHelp, btnAnim, btnRotL, btnRotR, btnSel, btnFull, btnZoom, btnVmode, btnReadDir, btnSpeed, btnClose,
currentGallery = [],
currentIndex = 0,
isOverlayVisible = false,
@ -46,6 +46,7 @@ window.baguetteBox = (function () {
documentLastFocus = null,
isFullscreen = false,
vmute = false,
vspeed = sread('vspeed') || 1.0,
vloop = sread('vmode') == 'L',
vnext = sread('vmode') == 'C',
loopA = null,
@ -317,6 +318,7 @@ window.baguetteBox = (function () {
'<button id="bbox-full" type="button" tt="full-screen">⛶</button>' +
'<button id="bbzoom" type="button" tt="zoom/stretch">z</button>' +
'<button id="bbox-vmode" type="button" tt="a"></button>' +
'<button id="bbox-vspeed" type="button" tt="playback speed">1x</button>' +
'<button id="bbox-close" type="button" aria-label="Close">X</button>' +
'</div></div>'
);
@ -336,6 +338,7 @@ window.baguetteBox = (function () {
btnFull = ebi('bbox-full');
btnZoom = ebi('bbzoom');
btnVmode = ebi('bbox-vmode');
btnSpeed = ebi('bbox-vspeed');
btnClose = ebi('bbox-close');
bcfg_bind(options, 'bbzoom', 'bbzoom', false, setzoom);
@ -522,6 +525,29 @@ window.baguetteBox = (function () {
tt.show.call(this);
}
function setVspeed() {
var v = vid();
ebi('bbox-vspeed').style.display = v ? '' : 'none';
if (!v)
return;
v.playbackRate = vspeed;
btnSpeed.textContent = vspeed + "x";
swrite('vspeed', vspeed);
}
function cycleVspeed() {
var newSpeed = vspeed + 0.25;
if (newSpeed > 2.0) {
newSpeed = 0.25;
}
vspeed = newSpeed;
setVspeed();
if (tt.en)
tt.show.call(this);
}
function findfile() {
var thumb = currentGallery[currentIndex].imageElement,
name = vsplit(thumb.href)[1].split('?')[0],
@ -627,6 +653,7 @@ window.baguetteBox = (function () {
bind(overlay, 'wheel', overlayWheelHandler);
bind(btnPrev, 'click', showLeftImage);
bind(btnNext, 'click', showRightImage);
bind(btnSpeed, 'click', cycleVspeed);
bind(btnClose, 'click', hideOverlay);
bind(btnVmode, 'click', tglVmode);
bind(btnHelp, 'click', halp);
@ -651,6 +678,7 @@ window.baguetteBox = (function () {
unbind(overlay, 'wheel', overlayWheelHandler);
unbind(btnPrev, 'click', showLeftImage);
unbind(btnNext, 'click', showRightImage);
unbind(btnSpeed, 'click', cycleVspeed);
unbind(btnClose, 'click', hideOverlay);
unbind(btnVmode, 'click', tglVmode);
unbind(btnHelp, 'click', halp);
@ -1281,6 +1309,7 @@ window.baguetteBox = (function () {
selbg();
mp_ctl();
setVmode();
setVspeed();
var el = vidimg();
if (el.getAttribute('rot'))