Skip to content

Commit

Permalink
Update cvat-ui/src/components/annotation-page/canvas/views/context-im…
Browse files Browse the repository at this point in the history
…age/model/hooks/useCanvasControl.tsx

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
shinkar94 and coderabbitai[bot] authored Dec 27, 2024
1 parent 245e8fb commit 0eea71c
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ export const useCanvasControl = (canvasRef: RefObject<HTMLCanvasElement>, fullsc
y: (e.clientY - dragOffset.y) / zoomLevel,
};
positionRef.current = newPosition;
if (animationFrameRef.current === null) {
animationFrameRef.current = requestAnimationFrame(() => {
if (canvasRef.current) {
canvasRef.current.style.transform = `
scale(${zoomLevel}) translate(${positionRef.current.x}px, ${positionRef.current.y}px)`;
}
animationFrameRef.current = null;
});
if (animationFrameRef.current !== null) {
cancelAnimationFrame(animationFrameRef.current);
}
animationFrameRef.current = requestAnimationFrame(() => {
if (canvasRef.current) {
canvasRef.current.style.transform = `
scale(${zoomLevel}) translate(${positionRef.current.x}px, ${positionRef.current.y}px)`;
}
animationFrameRef.current = null;
});
} else if (e.buttons === 2) {
const deltaX = e.movementX;
const deltaY = e.movementY;
Expand Down

0 comments on commit 0eea71c

Please sign in to comment.