Repository navigation
Full-page screenshot: scroll in CSS pixels and slot each shot to one viewport (phone fix) - #63
Merged
Conversation
…viewport On phones (devicePixelRatio > 1) the native scrollTo works in view pixels, so each capture step advanced only a fraction of a viewport and the shots after the first landed misaligned and oversized in the stitched image. Scroll via JavaScript in an isolated world with instant behavior and wait for scrollY to settle; record the real offset per shot as before. In the stitcher, draw every shot into a slot of exactly one viewport height at the shot scale, so an odd-sized shot cannot enlarge its segment. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On phones (devicePixelRatio > 1) the full-page screenshot behind the Structure tab wireframe was misaligned from the second viewport on: the first screenful was fine, later ones appeared shifted and much larger than they should be. Desktop (DPR 1) was unaffected.
Cause
scrollTo(x, y), which works in view/physical pixels. On a phone each "one viewport" step advanced onlyvh/DPRCSS pixels, so shots after the first were taken at the wrong offsets.Fix
html_service.dart: new_scrollPageToscrolls via JavaScript in an isolated world —window.scrollTo({top: y, behavior: "instant"})(CSS pixels, immune to page-levelscroll-behavior: smooth) — and pollswindow.scrollYuntil the scroll settles. The capture loop and the restore use it; the real scroll offset is still recorded per shot. Dimensions are read in the same isolated world.screenshot_stitch.dart:stitchScreenshotstakesviewportHeightand draws every shot into a slot of exactly one viewport (viewportHeight × scale) at its recorded offset — segments are uniform by construction, odd-sized shots get squeezed instead of enlarging their segment.Verification
flutter analyzeclean;flutter test1685 pass.