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
This commit is contained in:
parent
5a1046bc90
commit
e37ffb6cf5
@ -61,7 +61,6 @@ class Display {
|
|||||||
if (!this.context) { return; }
|
if (!this.context) { return; }
|
||||||
|
|
||||||
const link = e.target;
|
const link = e.target;
|
||||||
this.windowScroll.toY(0);
|
|
||||||
const context = {
|
const context = {
|
||||||
source: {
|
source: {
|
||||||
type: 'terms',
|
type: 'terms',
|
||||||
@ -77,6 +76,8 @@ class Display {
|
|||||||
url: this.context.url
|
url: this.context.url
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.windowScroll.toY(0);
|
||||||
|
|
||||||
const definitions = await apiKanjiFind(link.textContent, this.getOptionsContext());
|
const definitions = await apiKanjiFind(link.textContent, this.getOptionsContext());
|
||||||
this.setContentKanji(definitions, context);
|
this.setContentKanji(definitions, context);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -110,10 +111,6 @@ class Display {
|
|||||||
const scannedElement = e.target;
|
const scannedElement = e.target;
|
||||||
const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
|
const sentence = docSentenceExtract(textSource, this.options.anki.sentenceExt);
|
||||||
|
|
||||||
if (!disableScroll) {
|
|
||||||
this.windowScroll.toY(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
source: disableHistory ? this.context.source : {
|
source: disableHistory ? this.context.source : {
|
||||||
type: 'terms',
|
type: 'terms',
|
||||||
@ -132,6 +129,10 @@ class Display {
|
|||||||
|
|
||||||
this.setContentTerms(definitions, context);
|
this.setContentTerms(definitions, context);
|
||||||
|
|
||||||
|
if (!disableScroll) {
|
||||||
|
this.windowScroll.toY(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (selectText) {
|
if (selectText) {
|
||||||
textSource.select();
|
textSource.select();
|
||||||
}
|
}
|
||||||
@ -481,7 +482,7 @@ class Display {
|
|||||||
this.windowScroll.stop();
|
this.windowScroll.stop();
|
||||||
let target;
|
let target;
|
||||||
|
|
||||||
if (scroll) {
|
if (scroll !== null) {
|
||||||
target = scroll;
|
target = scroll;
|
||||||
} else {
|
} else {
|
||||||
target = index === 0 || entry === null ? 0 : Display.getElementTop(entry);
|
target = index === 0 || entry === null ? 0 : Display.getElementTop(entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user