From c3ea733c68a8366df26ee48d89ee78d8495ec8fb Mon Sep 17 00:00:00 2001 From: ingridtv Date: Wed, 15 Dec 2021 11:57:27 +0100 Subject: [PATCH] Fixed bug with scrolling/key press to move to frames 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. I added an if-statement in annotationweb.js that seems to fix the problem. (cherry picked from commit 5e25cf99447b178788308d4115e8bcf63458ea7a) --- .../static/annotationweb/annotationweb.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/annotationweb/static/annotationweb/annotationweb.js b/annotationweb/static/annotationweb/annotationweb.js index b89456d..637700a 100644 --- a/annotationweb/static/annotationweb/annotationweb.js +++ b/annotationweb/static/annotationweb/annotationweb.js @@ -342,14 +342,18 @@ function loadSequence(image_sequence_id, start_frame, nrOfFrames, show_entire_se if(g_shiftKeyPressed) { goToNextKeyFrame(); } else { - goToFrame(g_currentFrameNr + 1); + if (g_currentFrameNr < end) { + goToFrame(g_currentFrameNr + 1); + } } } else { // scroll down if(g_shiftKeyPressed) { goToPreviousKeyFrame(); } else { - goToFrame(g_currentFrameNr - 1); + if (g_currentFrameNr > start) { + goToFrame(g_currentFrameNr - 1); + } } } event.preventDefault(); @@ -362,13 +366,17 @@ function loadSequence(image_sequence_id, start_frame, nrOfFrames, show_entire_se if(g_shiftKeyPressed) { goToPreviousKeyFrame(); } else { - goToFrame(g_currentFrameNr - 1); + if (g_currentFrameNr > start) { + goToFrame(g_currentFrameNr - 1); + } } } else if(event.which === 39) { // Right if(g_shiftKeyPressed) { goToNextKeyFrame(); } else { - goToFrame(g_currentFrameNr + 1); + if (g_currentFrameNr < end) { + goToFrame(g_currentFrameNr + 1); + } } } });