animate-css / animate.css

🍿 A cross-browser library of CSS animations. As easy to use as an easy thing.
https://animate.style/
Other
80.1k stars 16.24k forks source link

`--animate-delay` has no effect (and I think that I’ve figured out why) #1793

Open handcoding opened 2 weeks ago

handcoding commented 2 weeks ago

Describe The Bug

The docs mention that users can add --animate-delay to their CSS to delay when a given animation starts. But this CSS variable seems to have no effect.

Safari - Animate css  A cross-browser library of CSS animations  - 2024-06 at 11-12-58

Steps To Reproduce

  1. Run this minimized test case, which includes --animate-delay: 5s; on an element: https://codepen.io/handcoding/pen/dyEZxoJ

Expected Behavior

The expected behavior is that this element would animate after a delay of 5 seconds.

Desktop

Additional Context

I believe that I’ve figured out why this is happening.

In animate.css's base .animate__animated class, the library programmatically connects the animation-duration CSS property to its variable through animation-duration: var(--animate-duration); (which is good!).

.... but then the library’s .animate__animated class doesn’t also connect the animation-delay CSS property to its corresponding --animate-delay variable.

So the upshot is that if you set, say, --animate-delay: 5s; on an element, there ends up being no delay at all.

@charset "UTF-8";/*!
 * animate.css - https://animate.style/
 * Version - 4.1.1
 * Licensed under the MIT license - http://opensource.org/licenses/MIT
 *
 * Copyright (c) 2020 Animate.css
 */
:root {
  --animate-duration: 1s;
  --animate-delay: 1s;
  --animate-repeat: 1;
}
.animate__animated {
  -webkit-animation-duration: 1s;
  animation-duration: 1s;
  -webkit-animation-duration: var(--animate-duration);
  animation-duration: var(--animate-duration);
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}

[…]

PS I believe that the --animate-repeat CSS variable is also affected by this since that doesn’t appear to be programmatically connected to its corresponding CSS property within .animate__animated either.