From b7a73d17964f7f4ae56a313ff64afa94e24efe68 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Mon, 24 Jun 2024 20:12:03 -0400 Subject: Fix alt+scroll offset from elements above sticky header (#1131) --- ext/js/display/display.js | 6 +++--- ext/search.html | 50 ++++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/ext/js/display/display.js b/ext/js/display/display.js index ebd11e0a..b5dd4ba6 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -97,7 +97,7 @@ export class Display extends EventDispatcher { /** @type {boolean} */ this._historyHasChanged = false; /** @type {?Element} */ - this._navigationHeader = document.querySelector('#navigation-header'); + this._aboveStickyHeader = document.querySelector('#above-sticky-header'); /** @type {import('display').PageType} */ this._contentType = 'clear'; /** @type {string} */ @@ -1516,8 +1516,8 @@ export class Display extends EventDispatcher { } let target = (index === 0 && definitionIndex <= 0) || node === null ? 0 : this._getElementTop(node); - if (this._navigationHeader !== null) { - target -= this._navigationHeader.getBoundingClientRect().height; + if (this._aboveStickyHeader !== null && target !== 0) { + target += this._aboveStickyHeader.getBoundingClientRect().height; } this._windowScroll.stop(); diff --git a/ext/search.html b/ext/search.html index e15f9bb9..4324dad5 100644 --- a/ext/search.html +++ b/ext/search.html @@ -23,31 +23,33 @@
-
-
-
-
-

Yomitan Search

-
+
+
+
+
+
+

Yomitan Search

+
-
-
-
- -
- - - -- cgit v1.2.3