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