Skip to content

Next Image does not work properly when used in a horizontally scrolling container #32774

@agusterodin

Description

@agusterodin

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

16.13.0

What browser are you using?

Chrome (Desktop and Android)

What operating system are you using?

macOS Monterey and Android 12

How are you deploying your application?

Vercel (broken when developing locally with yarn dev as well)

Describe the Bug

There are two issues present:

I am using Next Image inside of a horizontally scrolling container and the lazyBoundary prop isn't working + on Android Chrome images will permanently disappear once scrolled away from.

Firstly, here is a video screenshot of the network tab in Chrome on desktop. Notice that images do not load until the image is literally in the viewport despite lazyBoundary being set to an arbitrarily high value (in this case 9000px). From what I understand from the docs, the syntax is similar to that of the CSS margin property. This means that I should be able to specify both a vertical and horizontal value via shorthand (ex: 500px 1000px), correct?

Screen.Recording.2021-12-23.at.2.13.01.PM.mov

Secondly (and way more critically) on Chrome for Android I experience the same lazyBoundary issue but also experience images completely disappearing after scrolling away from them and back to them.

Next.Image.Horizontal.Scroll.Bug.mov

This issue is present when deploying to Vercel as well as developing locally.

Expected Behavior

The lazyBoundary property to be respected in a horizontal container and for images not to disappear on mobile

To Reproduce

https://github.com/agusterodin/next-image-horizontal-scroll-bug-reproduction

Present when running the project via yarn dev AND when deployed to Vercel.

Metadata

Metadata

Assignees

Labels

Image (next/image)Related to Next.js Image Optimization.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions