Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion copyparty/web/baguettebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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,
Expand All @@ -42,6 +42,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,
Expand Down Expand Up @@ -313,6 +314,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>'
);
Expand All @@ -332,6 +334,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);
Expand Down Expand Up @@ -518,6 +521,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],
Expand Down Expand Up @@ -623,6 +649,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);
Expand All @@ -647,6 +674,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);
Expand Down Expand Up @@ -1265,6 +1293,7 @@ window.baguetteBox = (function () {
selbg();
mp_ctl();
setVmode();
setVspeed();

var el = vidimg();
if (el.getAttribute('rot'))
Expand Down