motion icon indicating copy to clipboard operation
motion copied to clipboard

[BUG] Custom variant is stuck with stale values if the variant changes faster than the transition duration

Open jamesopti opened this issue 3 years ago • 2 comments
trafficstars

2. Describe the bug

Changing variants rapidly (faster than the duration of the transition) can leave a variant stuck with incorrect (stale) values.

NOTE: I believe this only happens when using the transitionEnd option for the custom variant.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

This CSB is a fork of the image gallery one with a toggle to turn it on/off.

When off, it displays the images in a list. When on, it switches to a gallery

https://codesandbox.io/s/framer-motion-image-gallery-forked-0wy3pi?file=/src/Example.tsx

4. Steps to reproduce

Steps to reproduce the behavior:

  1. Load the CSB - See all images are stacked with the "off" variant
  2. Click on the button to toggle the slideshow on
  3. Click the next arrow 5 times quickly to skip to the end
  4. Toggle the button back to off
  5. Observe 2-3 of the 5 variants have the wrong position and transform css properties.

Gallery OFF Screen Shot 2022-08-16 at 5 57 48 PM

Gallery ON Screen Shot 2022-08-16 at 6 01 24 PM

5. Expected behavior

Each image wrapper should have the CSS transform properties for the "off" variant, notably "position: relative"

6. Video or screenshots

In this loom, at the end, you can see that 2 of the 5 motion components are stuck in position:fixed despite having the variant "off"

https://www.loom.com/share/543d5e95169649599d14578f781b848d

7. Environment details

Mac OS Monterey 12.1, Chrome Version 104.0.5112.79 (Official Build) (arm64)

jamesopti avatar Aug 17 '22 01:08 jamesopti

This appears to still be an issue!

ali-idrizi avatar Feb 27 '24 12:02 ali-idrizi