1
0
Fork 0
mirror of https://github.com/lrsjng/h5ai synced 2025-12-28 11:42:43 +01:00

Allow for setting control schemes s based on the preview type

This commit is contained in:
agentd00nut 2019-04-11 11:25:56 -04:00
parent 6f61a12772
commit 08dc58da6b
2 changed files with 62 additions and 4 deletions

View file

@ -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,

View file

@ -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
@ -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([]);
@ -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();