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

animationDelay not applying #10134

Closed
dcramer opened this issue Jul 10, 2017 · 4 comments
Closed

animationDelay not applying #10134

dcramer opened this issue Jul 10, 2017 · 4 comments

Comments

@dcramer
Copy link

dcramer commented Jul 10, 2017

Using React v15.6.1 the animationDelay style does not appear to be applying.

Here's the specific I was working with trying to debug the problem:

import React, {Component} from 'react';

import './PageLoadingIndicator.css';

export default class PageLoadingIndicator extends Component {
  render() {
    let points = 1;
    let duration = 2; // seconds
    let durationPerBit = duration / points;
    let bitWidth = 100 / points;
    let height = 4;
    return (
      <div
        style={{
          display: 'block',
          height: height,
          position: 'fixed',
          width: '100%',
          left: 0,
          right: 0,
          top: 0
        }}>
        {[...Array(points)].map((_, i) => {
          console.log(durationPerBit * (i + 1));
          return (
            <span
              key={i}
              style={{
                display: 'inline-block',
                borderRadius: 0,
                background: '#fff',
                height: height,
                opacity: 0,
                position: 'absolute',
                left: `${bitWidth * i}%`,
                width: `${bitWidth}%`,
                animationDelay: `${durationPerBit * (i + 1)}s`,
                animation: `${duration}s ease infinite pageLoadingAnim`
              }}
            />
          );
        })}
      </div>
    );
  }
}

Upon inspection, the rendered HTML looks like:

<div style="display: block; height: 4px; position: fixed; width: 100%; left: 0px; right: 0px; top: 0px;">
    <span style="display: inline-block; border-radius: 0px; background: rgb(255, 255, 255); height: 4px; opacity: 0; position: absolute; left: 0%; width: 100%; animation: pageLoadingAnim 2s ease infinite;"></span>
</div>
dcramer added a commit to getsentry/zeus that referenced this issue Jul 10, 2017
@aweary
Copy link
Contributor

aweary commented Jul 10, 2017

@dcramer animation is a shorthand property that includes animation-delay, so I believe it's expected behavior that it would overwrite the previous animation-delay style. Could you include the delay in the animation property?

Do you know if this worked in previous React versions?

@dcramer
Copy link
Author

dcramer commented Jul 10, 2017

@aweary not sure if it ever worked and pardon my ignorance for not realizing that. It was working in the style sheet due to order if operations and I was just translating it over.

@aweary
Copy link
Contributor

aweary commented Jul 10, 2017

@dcramer no worries! We've had some previous discussions about warning for overlapping styles like this. See #6348, which links to a lot of the discussions. For now, you can get around this by either including the delay in the animation shorthand property, or explicitly using each expanded property, like animation-name, etc.

@dcramer
Copy link
Author

dcramer commented Jul 10, 2017

👍

@dcramer dcramer closed this as completed Jul 10, 2017
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

2 participants