Commit be5cdd65 authored by Mario Botsch's avatar Mario Botsch
Browse files

fine tune laser pointer

parent 46f7beb0
"use strict";
let RevealJingle = (function () {
const config = Reveal.getConfig().jingles || {};
let jingleLayout = null;
let jingles = [];
function createJingle(filename, style) {
const defaultStyle = "display:block; position:absolute; left:0; right:0; top:0; bottom:0; margin:auto; object-fit:contain; pointer-events:none;"
let vid = document.createElement("video");
vid.style = style ? defaultStyle+style : defaultStyle;
vid.src = filename;
vid.onplay = () => { jingleLayout.style.display = "flex"; vid.style.display = "block"; }
vid.onended = () => { jingleLayout.style.display = vid.style.display = "none"; }
jingleLayout.appendChild(vid);
return vid;
}
function setupJingles() {
// setup container
const reveal = document.querySelector(".reveal");
jingleLayout = document.createElement("div");
jingleLayout.style = "display:flex; flex-flow: column nowrap; justify-content:center; position:fixed; left:0; right:0; top:0; bottom:0; margin:0; z-index:100; background:none;";
reveal.appendChild(jingleLayout);
// setup video element per jingle
for (let i=0; i<config.length; i++) {
jingles.push( createJingle(config[i].vid, config[i].css) );
}
}
function playJingle(i) {
jingles[i].play();
}
function setupKeyBindings() {
const N = Math.min(9, jingles.length);
for (let i = 0; i < N; i++) {
Reveal.addKeyBinding(
{
keyCode: 49 + i,
key: String.fromCharCode(49 + i),
description: "Play jingle " + i,
},
() => {
playJingle(i);
}
);
}
}
return {
init: function () {
console.log("init jingle plugin");
if (config.length) {
setupJingles();
setupKeyBindings();
}
},
};
})();
Reveal.registerPlugin("jingle", RevealJingle);
......@@ -1148,6 +1148,9 @@ let RevealWhiteboard = (function () {
* pointer and mouse callbacks
******************************************************************/
// need this to remember button state for pointerup event
let buttonsPressed=null;
function pointerdown(evt) {
// only when whiteboard is active
if (!whiteboardActive) return;
......@@ -1158,6 +1161,9 @@ let RevealWhiteboard = (function () {
// only pen and mouse events
if (evt.pointerType != "pen" && evt.pointerType != "mouse") return;
// remember button state
buttonsPressed = evt.buttons;
// mouse button 2: toggle laser
if (evt.buttons == 2) {
toggleLaser();
......@@ -1229,7 +1235,9 @@ let RevealWhiteboard = (function () {
if (evt.pointerType != "pen" && evt.pointerType != "mouse") return;
// mouse button 2: toggle laser (nothing to do here)
if (evt.buttons == 2) {console.log("HALLO"); return;}
if (buttonsPressed == 2) {
return killEvent(evt);
}
// finish pen stroke
if (tool == ToolType.PEN) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment