mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
web: improve item flash animation when revealing item in list
this also fixes a potential memory leak due to event listener not unsubscribing
This commit is contained in:
@@ -206,7 +206,7 @@ textarea,
|
||||
}
|
||||
|
||||
.flash {
|
||||
animation: flash 0.5s;
|
||||
animation: flash 1s;
|
||||
}
|
||||
|
||||
@keyframes flash {
|
||||
|
||||
@@ -112,7 +112,7 @@ function ListContainer(props: ListContainerProps) {
|
||||
let flashStartTimeout: NodeJS.Timeout;
|
||||
let flashEndTimeout: NodeJS.Timeout;
|
||||
|
||||
AppEventManager.subscribe(
|
||||
const event = AppEventManager.subscribe(
|
||||
AppEvents.revealItemInList,
|
||||
async (id?: string) => {
|
||||
if (!id || !listRef.current) return;
|
||||
@@ -133,16 +133,17 @@ function ListContainer(props: ListContainerProps) {
|
||||
noteItem.classList.add("flash");
|
||||
flashEndTimeout = setTimeout(() => {
|
||||
noteItem.classList.remove("flash");
|
||||
}, 1000);
|
||||
}, 2000);
|
||||
}, 500);
|
||||
}
|
||||
);
|
||||
|
||||
return () => {
|
||||
event.unsubscribe();
|
||||
clearTimeout(flashStartTimeout);
|
||||
clearTimeout(flashEndTimeout);
|
||||
};
|
||||
}, []);
|
||||
}, [items]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user