fix(call): keep the mobile call embed aligned to the room during drawer slides

This commit is contained in:
Erwan Leboucher committed 2026-07-19 17:36:20 +02:00
1 parent 2f0196b618
commit 23b9dfca74
1 file changed
+22 -4
+22 -4
View File
@@ -175,8 +175,26 @@ export const useCallEmbedPlacementSync = (containerViewRef: RefObject<HTMLDivEle
);
useEffect(() => {
syncCallEmbedPlacement();
window.addEventListener('scroll', syncCallEmbedPlacement, true);
return () => window.removeEventListener('scroll', syncCallEmbedPlacement, true);
}, [syncCallEmbedPlacement]);
let raf = 0;
let last = '';
const tick = () => {
const embedEl = callEmbedRef.current;
const container = containerViewRef.current;
if (embedEl && container) {
const rect = container.getBoundingClientRect();
const key = `${rect.top}|${rect.left}|${rect.width}|${rect.height}`;
if (key !== last) {
last = key;
embedEl.style.position = 'fixed';
embedEl.style.top = `${rect.top}px`;
embedEl.style.left = `${rect.left}px`;
embedEl.style.width = `${rect.width}px`;
embedEl.style.height = `${rect.height}px`;
}
}
raf = requestAnimationFrame(tick);
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [callEmbedRef, containerViewRef]);
};