scroll-smooth and lazy images #410
Closed
carstenjaksch
started this conversation in
Ideas
Replies: 1 comment 9 replies
-
Can we see this behavior somewhere online? I've never noticed this.
Afaik this should prevent a layout shift by calculating the aspect ratio, even when using responsive images. Where did you learn this? |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a common issue not only related to Peak, but I would like to discuss a solution that could be included with Peak.
By default, Peak sets
scroll-smooth
on the HTML element. But this does not work well with a lot of lazy-loaded images on the site. For example: I have a project with a long home page, a lot of lazy-loaded images (all using the picture partial of Peak) and links to an ID at the bottom of the page.If the user visits the page for the first time and clicks such a link without scrolling, the browser smoothly scrolls to ... a random location. On desktop, it is not always a big issue – the target is just a bit offset. But on smaller screen sizes, the issue is getting worse: The user is stranded somewhere in the middle of the page and the target location is not in sight – very confusing.
This happens because during the scroll all of the images are loaded and the page jumps, so does the original link target.
But the images have width and height attributes set, you say. Yes, but these do not work with responsive images.
Here is an article about that kind of issue and probably a solution: https://itnext.io/how-to-stop-content-jumping-when-images-load-7c915e47f576
Beta Was this translation helpful? Give feedback.
All reactions