Skip to content

Commit

Permalink
fix: Do not add multiple zooms when duration changes. #1601
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Aug 10, 2023
1 parent 6105c39 commit eef25a6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions ui/src/parts/range_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,20 +635,23 @@ export const
}, [activeTag, onAnnotate])

React.useEffect(() => {
if (needsZoom(duration)) {
const zoomAnnotation: DrawnAnnotation = {
id: xid(),
canvasStart: 0,
canvasY: ZOOM_STROKE_WIDTH - 1,
canvasEnd: 100,
canvasHeight: WAVEFORM_HEIGHT - (2 * (ZOOM_STROKE_WIDTH - 1)),
start: -1,
end: -1,
tag: '',
isZoom: true
setAnnotations(annotations => {
if (needsZoom(duration) && !annotations[0].isZoom) {
const zoomAnnotation: DrawnAnnotation = {
id: xid(),
canvasStart: 0,
canvasY: ZOOM_STROKE_WIDTH - 1,
canvasEnd: 100,
canvasHeight: WAVEFORM_HEIGHT - (2 * (ZOOM_STROKE_WIDTH - 1)),
start: -1,
end: -1,
tag: '',
isZoom: true
}
return [zoomAnnotation, ...annotations]
}
setAnnotations(annotations => [zoomAnnotation, ...annotations])
}
return annotations
})
}, [duration])

return (
Expand Down

0 comments on commit eef25a6

Please sign in to comment.