fix(timeline): stabilize overlay lifecycle
This commit is contained in:
@@ -155,6 +155,8 @@ export function useViewportPopover({
|
||||
}, [align, anchor, estimatedHeight, offset, side, viewportPadding, width, zIndex]);
|
||||
|
||||
useEffect(() => {
|
||||
const closeOnViewportChange = anchor.kind === "point";
|
||||
|
||||
function cancelScheduledFrame() {
|
||||
if (frameRef.current === null) return;
|
||||
cancelAnimationFrame(frameRef.current);
|
||||
@@ -181,9 +183,19 @@ export function useViewportPopover({
|
||||
updateOrClose();
|
||||
|
||||
const handleScroll = () => {
|
||||
if (closeOnViewportChange) {
|
||||
cancelScheduledFrame();
|
||||
onClose();
|
||||
return;
|
||||
}
|
||||
scheduleUpdate("scroll");
|
||||
};
|
||||
const handleResize = () => {
|
||||
if (closeOnViewportChange) {
|
||||
cancelScheduledFrame();
|
||||
onClose();
|
||||
return;
|
||||
}
|
||||
scheduleUpdate("resize");
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user