This commit is contained in:
Rainer Simon 2020-05-13 08:36:57 +02:00
parent bc005087e0
commit f89eac2b87
1 changed files with 5 additions and 4 deletions

View File

@ -2,9 +2,10 @@ import React from 'preact/compat';
import { useState, useRef, useEffect } from 'preact/hooks';
import setPosition from './setPosition';
const autoApply = props => {
const applied = props.annotation.clone({ body: [{ ...props.autoApply }]});
return applied.toAnnotation();
/** We need to compare bounds by value, not by object ref **/
const bounds = elem => {
const { top, left, width, height } = elem.getBoundingClientRect();
return `${top}, ${left}, ${width}, ${height}`;
}
/**
@ -40,7 +41,7 @@ const Editor = props => {
if (element.current)
setPosition(props.wrapperEl, element.current, props.selectedElement);
}, [ props.selectedElement.getBoundingClientRect() ]);
}, [ props.selectedElement, bounds(props.selectedElement) ]);
// Attach resize listener on mount
useEffect(() => {