Fix reoder drag zoom misalignment and zoom

Summary: Looks like zoom alignment in general broke, and we also need to account for zoom in commit reodring

Reviewed By: quark-zju

Differential Revision: D53833156

fbshipit-source-id: 26363094ef84e105b4b85bddf31b4c3c54a32579
This commit is contained in:
Evan Krause 2024-02-15 16:25:14 -08:00 committed by Facebook GitHub Bot
parent c1e6b62579
commit f58488e2f9
2 changed files with 5 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import {is} from 'immutable';
import {useRef, useState} from 'react';
import {Icon} from 'shared/Icon';
import {unwrap} from 'shared/utils';
import {getZoomLevel} from 'shared/zoom';
import './StackEditSubTree.css';
@ -61,13 +62,15 @@ export function StackEditSubTree(props: ActivateSplitProps): React.ReactElement
setReorderState(state);
};
const zoom = getZoomLevel();
return (x, y, isDragging) => {
// Visual update.
const draggingDiv = draggingDivRef.current;
if (draggingDiv != null) {
if (isDragging) {
Object.assign(draggingDiv.style, {
transform: `translate(${x}px, calc(-50% + ${y}px))`,
transform: `translate(${x / zoom}px, calc(-50% + ${y / zoom}px))`,
opacity: '1',
});
} else {

View File

@ -17,6 +17,7 @@ export function getZoomLevel(): number {
if (isNaN(number)) {
return 1;
}
return number;
} catch {}
return 1;
}