mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 00:54:27 +03:00
resize observer: only return new dimensions if they've actually changed
This commit is contained in:
parent
de8d06b119
commit
9e63194b82
@ -17,7 +17,15 @@ export function useResizeObserver(...refs: RefType[]) {
|
|||||||
() =>
|
() =>
|
||||||
new ResizeObserver((entries) => {
|
new ResizeObserver((entries) => {
|
||||||
window.requestAnimationFrame(() => {
|
window.requestAnimationFrame(() => {
|
||||||
setDimensions(entries.map((entry) => entry.contentRect));
|
setDimensions((prevDimensions) => {
|
||||||
|
const newDimensions = entries.map((entry) => entry.contentRect);
|
||||||
|
if (
|
||||||
|
JSON.stringify(prevDimensions) !== JSON.stringify(newDimensions)
|
||||||
|
) {
|
||||||
|
return newDimensions;
|
||||||
|
}
|
||||||
|
return prevDimensions;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
[],
|
[],
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user