-
-
Notifications
You must be signed in to change notification settings - Fork 86
Fix viewport size calculation on Firefox first load #1271
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
base: main
Are you sure you want to change the base?
Changes from all commits
351e4e1
fd155b4
cf3ca17
b3c356c
851d4a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,11 +117,37 @@ | |
| return str.replace(/[\u00A0-\u9999<>\&]/gim, (i) => `&#${i.charCodeAt(0)};`); | ||
| } | ||
|
|
||
| function viewPortToCount(){ | ||
| const zoom = Math.floor((( window.outerWidth - 10 ) / window.innerWidth) * 100); | ||
| return Math.floor((window.innerHeight/(3*zoom) + 1)*(window.innerWidth/(2.5*zoom) + 1)); | ||
| function viewPortToCount() { | ||
| // Use stable viewport size instead of outerWidth (Firefox devtools issue) | ||
| const width = | ||
| document.documentElement.clientWidth || window.innerWidth; | ||
|
|
||
| const height = | ||
| document.documentElement.clientHeight || window.innerHeight; | ||
|
|
||
| // Zoom ratio btw layout width and viewport width | ||
| let zoomRatio = 1; | ||
|
|
||
| if (window.innerWidth) { | ||
| zoomRatio = width / window.innerWidth || 1; | ||
| } | ||
|
|
||
| // Estimated card size (in viewport units) | ||
| const CARD_HEIGHT_FACTOR = 3; | ||
| const CARD_WIDTH_FACTOR = 2.5; | ||
|
|
||
| const rows = Math.floor( | ||
| height / (CARD_HEIGHT_FACTOR * zoomRatio) + 1 | ||
| ); | ||
|
|
||
| const cols = Math.floor( | ||
| width / (CARD_WIDTH_FACTOR * zoomRatio) + 1 | ||
| ); | ||
|
Comment on lines
-120
to
+145
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Has this code been tested? The concern raised during the previous has not been addressed, and therefore it looks like the functionality should be utterly broken unless the return value of |
||
|
|
||
| return rows * cols; | ||
| } | ||
|
|
||
|
|
||
| function getInnerHtml(node, query) { | ||
| const queryNode = node.querySelector(query); | ||
| return queryNode != null ? queryNode.innerHTML : ""; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this won't work. Before this change
zoomused to be percentage, but the formulas forrowsandcolshave been actually preserved in spite of the fact thatzoomRatiois now being used instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out, I see what you mean.
The goal was to switch to a ratio while keeping the existing behavior stable but I agree this may not fully preserve the original scaling.
I’ll revisit the calculation and see how we can better align it with the new zoomRatio semantics.