From 4e7d08ff2c184a361622a6efaf00e21af51428a9 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 28 Nov 2019 13:22:47 +0200 Subject: [PATCH] set current entry even when disableScroll is true --- ext/mixed/js/display.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 27100fd2..ed3d9adc 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -360,6 +360,8 @@ class Display { const {index, scroll, disableScroll} = context; if (!disableScroll) { this.entryScrollIntoView(index || 0, scroll); + } else { + this.entrySetCurrent(index || 0); } if (options.audio.enabled && options.audio.autoPlay) { @@ -465,7 +467,7 @@ class Display { } } - entryScrollIntoView(index, scroll, smooth) { + entrySetCurrent(index) { index = Math.min(index, this.definitions.length - 1); index = Math.max(index, 0); @@ -479,9 +481,16 @@ class Display { entry.classList.add('entry-current'); } - this.windowScroll.stop(); - let target; + this.index = index; + return entry; + } + + entryScrollIntoView(index, scroll, smooth) { + this.windowScroll.stop(); + + const entry = this.entrySetCurrent(index); + let target; if (scroll !== null) { target = scroll; } else { @@ -493,8 +502,6 @@ class Display { } else { this.windowScroll.toY(target); } - - this.index = index; } sourceTermView() {