Skip to content

Commit

Permalink
Fixed dragging method for skeletons (#8976)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored Jan 21, 2025
1 parent 5d69c7e commit 4c5e522
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cvat-canvas/src/typescript/canvasView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,12 +1129,12 @@ export class CanvasViewImpl implements CanvasView, Listener {
...(state.shapeType === 'mask' ? { snapToGrid: 1 } : {}),
});

let startPoint = null;

let startCenter = null;
draggableInstance.on('dragstart', (): void => {
onDragStart();
this.draggableShape = shape;
startPoint = { x: shape.x(), y: shape.y() };
const { cx, cy } = shape.bbox();
startCenter = { x: cx, y: cy };
start = Date.now();
}).on('dragmove', (e: CustomEvent): void => {
onDragMove();
Expand Down Expand Up @@ -1170,10 +1170,10 @@ export class CanvasViewImpl implements CanvasView, Listener {

onDragEnd();
this.draggableShape = null;
const endPoint = { x: shape.x(), y: shape.y() };
const { cx, cy } = shape.bbox();

const dx2 = (startPoint.x - endPoint.x) ** 2;
const dy2 = (startPoint.y - endPoint.y) ** 2;
const dx2 = (startCenter.x - cx) ** 2;
const dy2 = (startCenter.y - cy) ** 2;
if (Math.sqrt(dx2 + dy2) > 0) {
if (state.shapeType === 'mask') {
const { points } = state;
Expand Down

0 comments on commit 4c5e522

Please sign in to comment.