Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search with zoom #683

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading