Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ export function WidgetBuilderV2({
}
}, []);

const [mainContentPosition, setMainContentPosition] = useState<{
left: number;
top: number;
} | null>(null);
useEffect(() => {
const mainContentElement = document.querySelector('main');

const observer = new ResizeObserver(entries => {
for (const entry of entries) {
if (entry.target === mainContentElement) {
const rect = entry.target.getBoundingClientRect();
setMainContentPosition({top: rect.top, left: rect.left});
Comment thread
JonasBa marked this conversation as resolved.
}
}
});
if (mainContentElement) {
observer.observe(mainContentElement);
}

return () => {
observer.disconnect();
};
}, []);

const dimensions = useDimensions({elementRef: navigationElementRef});

const handleDragEnd = ({over}: any) => {
Expand Down Expand Up @@ -168,12 +192,12 @@ export function WidgetBuilderV2({
? isMediumScreen
? {
left: 0,
top: `${dimensions.height ?? 0}px`,
top: `${mainContentPosition?.top ?? 0}px`,
willChange: 'top',
}
: {
left: `${dimensions.width ?? 0}px`,
top: 0,
top: `${mainContentPosition?.top ?? 0}px`,
willChange: 'left',
}
: undefined
Expand Down
Loading