-
-
Notifications
You must be signed in to change notification settings - Fork 426
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
WIP: Add Background Tool, Pointer Tool, Minio Support #21
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"onquit" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This isn't an HTML5 canvas, it's an old svg hack, (the code is _that_ old!) | ||
const fakeCanvas = document.getElementById("canvas"); | ||
const uid = Tools.generateUID("b"); // b for background | ||
|
||
function onstart() { | ||
const fileInput = document.createElement("input"); | ||
fileInput.type = "file"; | ||
fileInput.accept = "image/*"; | ||
|
||
fileInput.addEventListener("change", () => { | ||
const file = fileInput.files[0]; | ||
|
||
Tools.drawAndSend({ | ||
id: uid, | ||
data: file, | ||
fileType: file.type | ||
}, "Background"); | ||
Tools.change(Tools.prevToolName); | ||
}); | ||
|
||
fileInput.click(); | ||
} | ||
|
||
function draw(msg, self) { | ||
const file = self ? msg.data : new Blob([msg.data], { type: msg.fileType }); | ||
const fileURL = URL.createObjectURL(file); | ||
|
||
fakeCanvas.style.background = `url("${fileURL}") 170px 0px no-repeat`; | ||
} | ||
|
||
Tools.add({ | ||
"name": "Background", | ||
"icon": "🖼️", | ||
"shortcut": "b", | ||
"draw": draw, | ||
"onstart": onstart | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about that tool. It could quickly get out of hands with many users... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it's not something for public boards. Maybe it could be enabled when creating a board? Or even in the server? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.pointer { | ||
position: absolute; | ||
font-size: 2.5rem; | ||
visibility: hidden; | ||
transform: translate(-50%, -50%); | ||
cursor: none; | ||
border-radius: 40%; | ||
} | ||
|
||
.pointer.visible { | ||
visibility: visible; | ||
} | ||
|
||
.pointer.highlight { | ||
background-color: cornflowerblue; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
const uid = Tools.generateUID("f"); // f for finger | ||
let lastTime = performance.now(); | ||
|
||
const pointer = document.createElement("div"); | ||
pointer.classList.add("pointer"); | ||
pointer.innerHTML = "👆"; | ||
|
||
Tools.board.appendChild(pointer); | ||
|
||
function movePointer(x, y) { | ||
pointer.style.left = `${x * Tools.scale}px`; | ||
pointer.style.top = `${y * Tools.scale}px`; | ||
|
||
// TODO: Could find a better solution for JIP | ||
if (!pointer.classList.contains("visible")) { | ||
showPointer(true, false); | ||
} | ||
} | ||
|
||
function move(x, y) { | ||
movePointer(x, y); | ||
|
||
if (performance.now() - lastTime > 70) { | ||
Tools.send({ | ||
id: uid, | ||
type: "update", | ||
action: "move", | ||
x, | ||
y | ||
}, "Pointer"); | ||
lastTime = performance.now(); | ||
} | ||
} | ||
|
||
function draw(msg) { | ||
switch (msg.action) { | ||
case "move": | ||
movePointer(msg.x, msg.y); | ||
break; | ||
case "show": | ||
showPointer(true, false); | ||
break; | ||
case "hide": | ||
showPointer(false, false); | ||
break; | ||
case "highlight": | ||
highlightPointer(true, false); | ||
break; | ||
case "noHighlight": | ||
highlightPointer(false, false); | ||
break; | ||
} | ||
} | ||
|
||
function highlightPointer(highlight, self) { | ||
pointer.classList.toggle("highlight", highlight); | ||
|
||
if (self) { | ||
Tools.send({ | ||
id: uid, | ||
type: "update", | ||
action: highlight ? "highlight" : "noHighlight" | ||
}, "Pointer"); | ||
} | ||
} | ||
|
||
function showPointer(show, self) { | ||
pointer.classList.toggle("visible", show); | ||
|
||
if (self) { | ||
Tools.send({ | ||
id: uid, | ||
type: "update", | ||
action: show ? "show" : "hide" | ||
}, "Pointer"); | ||
} | ||
} | ||
|
||
Tools.add({ | ||
"name": "Pointer", | ||
"icon": "👆", | ||
"shortcut": "f", | ||
"listeners": { | ||
"press": () => highlightPointer(true, true), | ||
"move": move, | ||
"release": () => highlightPointer(false, true) | ||
}, | ||
"draw": draw, | ||
"onstart": () => showPointer(true, true), | ||
"onquit": () => showPointer(false, true), | ||
"mouseCursor": "none", | ||
"stylesheet": "tools/pointer/pointer.css" | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This tool seems very useful ! This is the one I think we need the most. But it should have one pointer per user. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want the changes to the README
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, it's in my TODO list to just remove these.