feat: disables scroll / zoom animations on drag and drop layer

This commit is contained in:
Mark Mankarious
2023-10-30 22:51:58 +00:00
parent efde7780a0
commit 1d9324eb84
2 changed files with 14 additions and 6 deletions

View File

@@ -7,9 +7,15 @@ interface Props {
children?: React.ReactNode;
order?: number;
sx?: SxProps;
disableAnimation?: boolean;
}
export const SceneLayer = ({ children, order = 0, sx }: Props) => {
export const SceneLayer = ({
children,
order = 0,
sx,
disableAnimation
}: Props) => {
const elementRef = useRef<HTMLDivElement>(null);
const scroll = useUiStateStore((state) => {
@@ -23,12 +29,12 @@ export const SceneLayer = ({ children, order = 0, sx }: Props) => {
if (!elementRef.current) return;
gsap.to(elementRef.current, {
duration: 0.25,
duration: disableAnimation ? 0 : 0.25,
translateX: scroll.position.x,
translateY: scroll.position.y,
scale: zoom
});
}, [zoom, scroll]);
}, [zoom, scroll, disableAnimation]);
return (
<Box

View File

@@ -190,10 +190,12 @@ export const UiOverlay = () => {
sx={{
position: 'absolute',
width: 350,
transform: 'translateY(-100%)'
}}
style={{
maxWidth: `calc(${rendererSize.width} - ${appPadding.x * 2}px)`,
left: appPadding.x,
top: rendererSize.height - appPadding.y * 2 - spacing(1),
transform: 'translateY(-100%)'
top: rendererSize.height - appPadding.y * 2 - spacing(1)
}}
>
<DebugUtils />
@@ -202,7 +204,7 @@ export const UiOverlay = () => {
</Box>
{mode.type === 'PLACE_ICON' && mode.id && (
<SceneLayer>
<SceneLayer disableAnimation>
<DragAndDrop iconId={mode.id} tile={mouse.position.tile} />
</SceneLayer>
)}