Add manifest.json, icons and install button, flatten client/src
This commit is contained in:
parent
a219e689c1
commit
474afda9c2
105 changed files with 338 additions and 283 deletions
45
client/js/utils/size.js
Normal file
45
client/js/utils/size.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
let width, height;
|
||||
const listeners = [];
|
||||
|
||||
function update() {
|
||||
width = window.innerWidth;
|
||||
height = window.innerHeight;
|
||||
|
||||
for (let i = 0; i < listeners.length; i++) {
|
||||
listeners[i](width, height);
|
||||
}
|
||||
}
|
||||
|
||||
let resizeRAF;
|
||||
|
||||
function resize() {
|
||||
if (resizeRAF) {
|
||||
window.cancelAnimationFrame(resizeRAF);
|
||||
}
|
||||
resizeRAF = window.requestAnimationFrame(update);
|
||||
}
|
||||
|
||||
update();
|
||||
window.addEventListener('resize', resize);
|
||||
|
||||
export function windowWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
export function windowHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
export function addResizeListener(f, init) {
|
||||
listeners.push(f);
|
||||
if (init) {
|
||||
f(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
export function removeResizeListener(f) {
|
||||
const i = listeners.indexOf(f);
|
||||
if (i > -1) {
|
||||
listeners.splice(i, 1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue