From 66773d92bd9a50cdd01f63f5221e90eaeb2d6179 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 10 Jul 2024 15:41:44 +0900 Subject: [PATCH] Validate when using slider --- index.html | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index e27a038..f5e9d7e 100644 --- a/index.html +++ b/index.html @@ -285,12 +285,16 @@ } else if (value >= subtitles_array.length) { value = subtitles_array.length - 1; } - current_subtitle = value; - time_info.set_time_offset( - subtitles_array[current_subtitle].time_start * 1000.0 - ); - display_subtitle(); - set_up_play_anim(); + + // Only when value is valid. + if (value >= 0 && value < subtitles_array.length) { + current_subtitle = value; + time_info.set_time_offset( + subtitles_array[current_subtitle].time_start * 1000.0 + ); + display_subtitle(); + set_up_play_anim(); + } }); document.getElementById("left_button").addEventListener(