davidjerleke / embla-carousel

A lightweight carousel library with fluid motion and great swipe precision.
https://www.embla-carousel.com
MIT License
6.16k stars 187 forks source link

Help diagnosing gatsby-plugin-image issue using withArtDirection #240

Closed ardiewen closed 2 years ago

ardiewen commented 2 years ago

Bug is related to

Embla Carousel version

Describe the bug

CodeSandbox

https://codesandbox.io/s/broken-butterfly-ltxgv

I first noticed this when testing React18 but also reproduced in React17. Here's a minimal repro on a react17 branch: https://github.com/ardiewen/gatsby-image-react18-repro/tree/react17

Steps to reproduce

  1. Start the minimal repro in develop mode
  2. Go to '/artdirected'
  3. Scroll the images to see the behaviour

Expected behavior

Additional context

davidjerleke commented 2 years ago

Hi @ardiewen,

I only had 2 minutes to do some debugging but I found this: It seems like the artDirection image is being re-rendered whenever you drag the carousel and release the pointer, but Embla is not being re-rendered. You can reproduce this like so:

  1. Open up dev tools.
  2. Toggle open the first slide element in order to reveal its contents.
  3. Toggle open the <picture> element in order to show its contents.
  4. Drag and release the carousel.
  5. Watch the picture element being removed and added again.
picture

Another thing: The console is throwing a couple of errors so these maybe worth investigating a bit:

Skärmavbild 2021-11-16 kl  15 02 10

At this point I have no idea why this is happening though.

Best, David

ardiewen commented 2 years ago

Hey @davidjerleke thanks for your prompt response! I managed to isolate the issue.

I first thought it had to do with the transform animation, but it looks like any re-render of the parent container will cause an art directed image to also rerender, even if it's been loaded.

This is not the case with the regular GatsbyImage. Rerendering parent containers will not cause a child GatsbyImage to rerender once its been loaded.

I'll create an issue on the gatsby repo.

davidjerleke commented 2 years ago

Hi @ardiewen,

Glad to hear that. Let’s hope that they will fix the issue soon. Good luck with everything 👍🏻.

Best, David