mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-29 08:19:13 -04:00
wip
This commit is contained in:
parent
64a85200b9
commit
47ad04c49b
26 changed files with 313 additions and 247 deletions
26
src/toast.ts
26
src/toast.ts
|
@ -1,17 +1,17 @@
|
|||
let onScreen = 0;
|
||||
|
||||
export function toast(html) {
|
||||
const div = document.createElement("div");
|
||||
div.classList = "toast";
|
||||
div.innerHTML = html;
|
||||
const lasts = 1500 + onScreen * 200;
|
||||
div.style.animationDuration = lasts + "ms";
|
||||
div.style.top = 40 + onScreen * 50 + "px";
|
||||
|
||||
let div= document.createElement("div");
|
||||
div.classList = 'hidden toast';
|
||||
document.body.appendChild(div);
|
||||
onScreen++;
|
||||
setTimeout(() => {
|
||||
div.remove();
|
||||
onScreen--;
|
||||
}, lasts);
|
||||
let timeout: NodeJS.Timeout|undefined;
|
||||
export function toast(html) {
|
||||
div.classList = "toast visible";
|
||||
div.innerHTML = html;
|
||||
if(timeout) {
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
timeout=setTimeout(() => {
|
||||
timeout=undefined
|
||||
div.classList = 'hidden toast';
|
||||
}, 1500);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue