aboutsummaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2019-11-28 12:38:25 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2019-11-28 12:38:25 +0200
commite37ffb6cf5796fc45787046830d84b9d316c0186 (patch)
tree91bc6f0171c47a90a3a531b2906cf126b189515d /ext/mixed/js/display.js
parent5a1046bc906a74ca39906a52acc62fc702a658f2 (diff)
fix scroll issues in Display.entryScrollIntoView
- Save scroll context before scrolling to top - Explicit null check for scroll param to handle scrolling to y=0 correctly
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 2396805a..27100fd2 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -61,7 +61,6 @@ class Display {
if (!this.context) { return; }
const link = e.target;
- this.windowScroll.toY(0);
const context = {
source: {
type: 'terms',
@@ -77,6 +76,8 @@ class Display {
url: this.context.url
};
+ this.windowScroll.toY(0);
+
const definitions = await apiKanjiFind(link.textContent, this.getOptionsContext());
this.setContentKanji(definitions, context);
} catch (error) {
@@ -110,10 +111,6 @@ class Display {
const scannedElement = e.target;
const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
- if (!disableScroll) {
- this.windowScroll.toY(0);
- }
-
const context = {
source: disableHistory ? this.context.source : {
type: 'terms',
@@ -132,6 +129,10 @@ class Display {
this.setContentTerms(definitions, context);
+ if (!disableScroll) {
+ this.windowScroll.toY(0);
+ }
+
if (selectText) {
textSource.select();
}
@@ -481,7 +482,7 @@ class Display {
this.windowScroll.stop();
let target;
- if (scroll) {
+ if (scroll !== null) {
target = scroll;
} else {
target = index === 0 || entry === null ? 0 : Display.getElementTop(entry);