smistad / annotationweb

A web-based annnotation system for easy annotation of image sequences such as ultrasound and camera recordings
MIT License
32 stars 18 forks source link

Fixed bug with scrolling/key press to move between frames #54

Open ingridtv opened 2 years ago

ingridtv commented 2 years ago

I noticed that when hovering over the canvas and scrolling, the current frame number incremented/decremented beyond the range of frames (for me, below 0 and above the total number of frames). The same bug happened with key left/right presses. The canvas keeps displaying the first/last frame in the sequence, but the browser console gives an error message:

segmentation.js:357 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or OffscreenCanvas or SVGImageElement or VideoFrame)'.
    at redrawSequence (segmentation.js:357)
    at goToFrame (annotationweb.js:71)

I added if statements to the calls to goToFrame() in annotationweb.js that seems to fix the problem.

(cherry picked from commit 5e25cf99447b178788308d4115e8bcf63458ea7a)