Fix several potential memory leaks (#5586)
This commit is contained in:
parent
3405d62523
commit
37617b4b8e
@ -144,6 +144,8 @@ export function animateOpening(isArchived?: boolean) {
|
|||||||
}
|
}
|
||||||
toggleAvatar?.classList.remove('animating');
|
toggleAvatar?.classList.remove('animating');
|
||||||
peer.classList.remove('animating');
|
peer.classList.remove('animating');
|
||||||
|
|
||||||
|
callbacks.delete(cb);
|
||||||
});
|
});
|
||||||
}, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
}, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
||||||
|
|
||||||
@ -283,6 +285,8 @@ export function animateClosing(isArchived?: boolean) {
|
|||||||
peer.classList.remove('animating');
|
peer.classList.remove('animating');
|
||||||
toggleAvatar!.classList.remove('animating');
|
toggleAvatar!.classList.remove('animating');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
callbacks.delete(cb);
|
||||||
}, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
}, ANIMATION_DURATION + ANIMATION_END_DELAY);
|
||||||
|
|
||||||
callbacks.add(cb);
|
callbacks.add(cb);
|
||||||
|
|||||||
@ -163,6 +163,7 @@ export function useIntersectionObserver({
|
|||||||
function destroy() {
|
function destroy() {
|
||||||
callbacks.clear();
|
callbacks.clear();
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
|
entriesAccumulator.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
controllerRef.current = {
|
controllerRef.current = {
|
||||||
|
|||||||
@ -722,6 +722,8 @@ function useEffectBase(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (effectConfig) effectConfig.schedule = undefined; // Help GC
|
||||||
|
|
||||||
byCursor[cursor] = {
|
byCursor[cursor] = {
|
||||||
...effectConfig,
|
...effectConfig,
|
||||||
dependencies,
|
dependencies,
|
||||||
|
|||||||
@ -57,8 +57,17 @@ export default function animateHorizontalScroll(container: HTMLElement, left: nu
|
|||||||
|
|
||||||
const startAt = Date.now();
|
const startAt = Date.now();
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
container.style.scrollSnapType = '';
|
||||||
|
delete container.dataset.scrollId;
|
||||||
|
stopById.delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
animate(() => {
|
animate(() => {
|
||||||
if (isStopped) return false;
|
if (isStopped) {
|
||||||
|
cleanup();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const t = Math.min((Date.now() - startAt) / duration, 1);
|
const t = Math.min((Date.now() - startAt) / duration, 1);
|
||||||
|
|
||||||
@ -66,9 +75,7 @@ export default function animateHorizontalScroll(container: HTMLElement, left: nu
|
|||||||
container.scrollLeft = Math.round(target - currentPath);
|
container.scrollLeft = Math.round(target - currentPath);
|
||||||
|
|
||||||
if (t >= 1) {
|
if (t >= 1) {
|
||||||
container.style.scrollSnapType = '';
|
cleanup();
|
||||||
delete container.dataset.scrollId;
|
|
||||||
stopById.delete(id);
|
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user