Skip to content

Commit

Permalink
Fix search with zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Jan 6, 2025
1 parent b047f10 commit ec211e0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions www/js/lib/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* util.js : Utility functions
*
* Copyright 2013-2023 Mossroy, Jaifroid and contributors
Expand Down Expand Up @@ -487,7 +487,13 @@ function Hilitor (node, tag) {
if (appstate.isReplayWorkerAvailable) {
iframeWindow = document.getElementById('articleContent').contentDocument.getElementById('replay_iframe').contentWindow;
}
var scrollOffset = hilitedNodes[start].offsetTop - window.innerHeight / 4;
var root = iframeWindow.document.documentElement;
var zoomFactor = 'zoom' in root.style && params.relativeFontSize && !window.MSBlobBuilder
? params.relativeFontSize / 100 : 1;
// Convert both the element position and viewport height to zoomed coordinates
var elementPosition = hilitedNodes[start].offsetTop * zoomFactor;
var viewportOffset = window.innerHeight / 4;
var scrollOffset = elementPosition - viewportOffset;
if ('scrollBehavior' in document.documentElement.style) {
iframeWindow.scrollTo({
top: scrollOffset,
Expand Down

0 comments on commit ec211e0

Please sign in to comment.