added gameboard
This commit is contained in:
parent
93d278340e
commit
fa36efa455
68 changed files with 7800 additions and 1 deletions
20
gameboard-service/src/lib/actions/resize.ts
Normal file
20
gameboard-service/src/lib/actions/resize.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
type Options = {
|
||||
f: (width: number, height: number) => void;
|
||||
};
|
||||
|
||||
export function resize(node: HTMLElement, options: Options) {
|
||||
const resizeObserver = new ResizeObserver((entries) => {
|
||||
for (const entry of entries) {
|
||||
const w = entry.contentBoxSize[0].inlineSize;
|
||||
const h = entry.contentBoxSize[0].blockSize;
|
||||
options.f(w, h);
|
||||
}
|
||||
});
|
||||
resizeObserver.observe(node);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
resizeObserver.unobserve(node);
|
||||
}
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue