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

Image initial position calculation incorrect when browser cache is disabled on Chrome #439

Open
rsbrowne opened this issue Dec 12, 2023 · 2 comments

Comments

@rsbrowne
Copy link

Describe the bug
When the browser's cache is disabled the calculation for the image starting position (when not full width) seems to be incorrect. It seems that the calculation might be happening before the image is done loading and as a result 0 is being used for the image width and height (This is just my theory on what's going wrong but I also suspect this may be related to issue #112).

To Reproduce
Steps to reproduce the behavior:

  1. Visit the responsive image docs
  2. Open dev tools -> Network -> tick "Disable cache"
  3. Reload the page
  4. The image should now be in the wrong position i.e. top left corner of the image should now be in the center of the screen
  5. If it looks fine try resizing the page slightly

Expected behavior
The image should be positioned correctly regardless of how long it takes the image asset to load

Screenshots
responsive-image-bug

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
@stevebrowndotco
Copy link

I solved this with a workaround

    const handleImageOnLoad = (image: HTMLImageElement) => {
        transformRef.current?.resetTransform()
    }

@lucas-nd
Copy link

The approach of calling a resetTransform when the image is loaded is not working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants