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

Pseudo Element Animation Support #391

Closed
11 opened this issue Apr 8, 2021 · 2 comments
Closed

Pseudo Element Animation Support #391

11 opened this issue Apr 8, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@11
Copy link

11 commented Apr 8, 2021

Feature Request

Describe the Feature

Adding a pseudo element attribute to the options object - similar to the actual native api

Ex: https://css-tricks.com/pseudo-elements-in-the-web-animations-api/

Describe the Solution You'd Like

When instantiating a new web animations object, there should be an option to define a pseudo element you'd like to target

const { ref, playState } = useWebAnimations({
    keyframes: {
      transform: "translateX(500px)", 
      background: ["red", "blue", "green"], 
    },
    timing: {
      delay: 500, 
      duration: 1000, 
      iterations: 2, 
      direction: "alternate", 
      easing: "ease-in-out", 
    },
    pseudoElement: '::after', // NOTE: this flag here would be added
    // ... More useful options ...
  });

Describe Alternatives You've Considered

I don't think there is another way to handle this? The only alternative is to animate another element and change the markup to work well with the added element

Additional Information

Example of why this is useful:

An example where this comes up is when trying to create toast messages after clicking on an element

For example - this toast message after clicking on a copy to clipboard button is often just a pseudo element:

image

So being able to keep the styling for this toast message inside the pseudo element CSS, while being able to express animation logic with useWebAnimations.

@wellyshen wellyshen added the enhancement New feature or request label Apr 8, 2021
@wellyshen
Copy link
Owner

wellyshen commented Apr 8, 2021

@11 If you pass the pseudoElement into the timing options, it can work (not test it yet). Because the timing reflects to the options parameter of the Element.animate(). Maybe we should rename it as animateOptions for better understanding.

@wellyshen
Copy link
Owner

wellyshen commented Apr 10, 2021

@11 I Now we can use the pseudoElement via the animationOptions in v0.7.0.

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

No branches or pull requests

2 participants