Skip to content

Commit

Permalink
check scroll animation setting in useApplyCanvasOffsetToStyle (#4699)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrmendy authored Jan 9, 2024
1 parent 591eba2 commit 99c0972
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions editor/src/components/canvas/controls/canvas-offset-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function useApplyCanvasOffsetToStyle(setScaleToo: boolean): React.RefObje
const elementRef = React.useRef<HTMLDivElement>(null)
const canvasOffsetRef = useRefEditorState((store) => store.editor.canvas.roundedCanvasOffset)
const scaleRef = useRefEditorState((store) => store.editor.canvas.scale)
const isScrollAnimationActiveRef = useRefEditorState(
(store) => store.editor.canvas.scrollAnimation,
)

const mode = useEditorState(
Substores.restOfEditor,
Expand All @@ -45,13 +48,15 @@ export function useApplyCanvasOffsetToStyle(setScaleToo: boolean): React.RefObje
setScaleToo && scaleRef.current >= 1 ? `${scaleRef.current * 100}%` : '1',
)

elementRef.current.style.setProperty(
'transition',
isFollowMode(mode) ? `transform ${liveblocksThrottle}ms linear` : 'none',
)
if (!isScrollAnimationActiveRef.current) {
elementRef.current.style.setProperty(
'transition',
isFollowMode(mode) ? `transform ${liveblocksThrottle}ms linear` : 'none',
)
}
}
},
[elementRef, setScaleToo, scaleRef, mode],
[setScaleToo, scaleRef, isScrollAnimationActiveRef, mode],
)

useSelectorWithCallback(
Expand Down

0 comments on commit 99c0972

Please sign in to comment.