mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
zoomToElement feature
This commit is contained in:
parent
2d8dc7e0d1
commit
75850a7709
@ -69,6 +69,26 @@ export const LiveEditor: React.FC = React.memo(() => {
|
||||
wrapperRef.current?.resetTransform();
|
||||
}, [settings.transform]);
|
||||
|
||||
React.useEffect(() => {
|
||||
const wrapperRect =
|
||||
wrapperRef.current?.instance.wrapperComponent?.getBoundingClientRect();
|
||||
|
||||
const node = document.querySelector(
|
||||
`span[data-key*='${settings.searchNode}' i]`
|
||||
);
|
||||
|
||||
if (wrapperRect && node) {
|
||||
const newScale = 0.8;
|
||||
const x = Number(node.getAttribute("data-x"));
|
||||
const y = Number(node.getAttribute("data-y"));
|
||||
|
||||
const newPositionX = (wrapperRect.left - x) * newScale;
|
||||
const newPositionY = (wrapperRect.top - y) * newScale;
|
||||
|
||||
wrapperRef.current?.setTransform(newPositionX, newPositionY, newScale);
|
||||
}
|
||||
}, [settings.searchNode]);
|
||||
|
||||
if (pageLoaded)
|
||||
return (
|
||||
<StyledLiveEditor>
|
||||
|
Loading…
x
Reference in New Issue
Block a user