Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for setting control schemes based on the preview type #701

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/_h5ai/public/js/lib/ext/preview/preview-vid.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const {dom} = require('../../util');
const allsettings = require('../../core/settings');
const preview = require('./preview');

preview.setControlType("vid")

const settings = Object.assign({
enabled: false,
autoplay: true,
Expand Down
64 changes: 60 additions & 4 deletions src/_h5ai/public/js/lib/ext/preview/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,25 @@ const dropEvent = ev => {
ev.preventDefault();
};

const onKeydown = ev => {
// const onKeydown = ev => {
// const key = ev.keyCode;

// if (key === 27) { // esc
// dropEvent(ev);
// exit(); // eslint-disable-line no-use-before-define
// } else if (key === 8 || key === 37) { // backspace, left
// dropEvent(ev);
// prev();
// } else if (key === 13 || key === 32 || key === 39) { // enter, space, right
// dropEvent(ev);
// next();
// } else if (key === 70) { // f
// dropEvent(ev);
// toggleFullscreen();
// }
// };

const defaultControls = ev => {
const key = ev.keyCode;

if (key === 27) { // esc
Expand All @@ -147,7 +165,42 @@ const onKeydown = ev => {
dropEvent(ev);
toggleFullscreen();
}
};
}

const videoControls = ev => {
const key = ev.keyCode;

if (key === 27) { // esc
dropEvent(ev);
exit(); // eslint-disable-line no-use-before-define
} else if (key === 8 || key === 188) { // backspace === 8; , ===188
dropEvent(ev);
prev();
} else if (key === 13 || key === 190) { // enter === 13; . ===190
dropEvent(ev);
next();
} else if (key === 70) { // f
dropEvent(ev);
toggleFullscreen();
}
}

const onKeydown = ev => {

switch(Preview.controlsType){
case "vid":
videoControls(ev)
break;
default:
defaultControls(ev)
}
}

const setControlType = (t) =>{
Preview.controlsType = t
}



const enter = () => {
setLabels([]);
Expand Down Expand Up @@ -284,12 +337,15 @@ const init = () => {
.on('load', updateGui);
};

module.exports = {

var Preview = module.exports = {
setLabels,
register,
get item() {
return session && session.item;
}
},
controlsType:"default",
setControlType
};

init();