Skip to content

Commit

Permalink
Remove unnecessary chart updates on drags
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-statsig authored Dec 14, 2024
1 parent cf08c6a commit a54c58a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function mouseMove(chart: Chart, event: MouseEvent) {
if (state.dragStart) {
state.dragging = true
state.dragEnd = event
chart.update('none')
chart.draw();

Check failure on line 48 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Delete `;`

Check failure on line 48 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Extra semicolon

Check failure on line 48 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Delete `;`

Check failure on line 48 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Extra semicolon
}
}

Expand All @@ -58,7 +58,7 @@ function keyDown(chart: Chart, event: KeyboardEvent) {
removeHandler(chart, 'keydown')
state.dragging = false
state.dragStart = state.dragEnd = undefined
chart.update('none')
chart.draw();

Check failure on line 61 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Delete `;`

Check failure on line 61 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Extra semicolon

Check failure on line 61 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Delete `;`

Check failure on line 61 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Extra semicolon
}

function getPointPosition(event: MouseEvent, chart: Chart) {
Expand Down Expand Up @@ -203,12 +203,12 @@ export function mouseUp(chart: Chart, event: MouseEvent) {
const distanceY = directionEnabled(mode, 'y', chart) ? rect.height : 0
const distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY)

// Remove drag start and end before chart update to stop drawing selected area
// Remove drag start and end before chart render to stop drawing selected area
state.dragStart = state.dragEnd = undefined

if (distance <= threshold) {
state.dragging = false
chart.update('none')
chart.draw();

Check failure on line 211 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Delete `;`

Check failure on line 211 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Extra semicolon

Check failure on line 211 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Delete `;`

Check failure on line 211 in src/handlers.ts

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Extra semicolon
return
}

Expand Down

0 comments on commit a54c58a

Please sign in to comment.