Position editor on resize
This commit is contained in:
parent
2727b38c94
commit
bc005087e0
|
@ -42,6 +42,16 @@ const Editor = props => {
|
||||||
setPosition(props.wrapperEl, element.current, props.selectedElement);
|
setPosition(props.wrapperEl, element.current, props.selectedElement);
|
||||||
}, [ props.selectedElement.getBoundingClientRect() ]);
|
}, [ props.selectedElement.getBoundingClientRect() ]);
|
||||||
|
|
||||||
|
// Attach resize listener on mount
|
||||||
|
useEffect(() => {
|
||||||
|
const resizeObserver = new ResizeObserver(() => {
|
||||||
|
setPosition(props.wrapperEl, element.current, props.selectedElement);
|
||||||
|
});
|
||||||
|
|
||||||
|
resizeObserver.observe(props.wrapperEl);
|
||||||
|
return () => resizeObserver.disconnect();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const onAppendBody = body => setCurrentAnnotation(
|
const onAppendBody = body => setCurrentAnnotation(
|
||||||
currentAnnotation.clone({
|
currentAnnotation.clone({
|
||||||
body: [ ...currentAnnotation.bodies, body ]
|
body: [ ...currentAnnotation.bodies, body ]
|
||||||
|
|
Loading…
Reference in New Issue