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

Use translate3d() by default for automatic interpolation of translations in order to utilize hardware acceleration. #851

Closed
ghost opened this issue Nov 7, 2019 · 2 comments
Labels
kind: request New feature or request that should be actioned

Comments

@ghost
Copy link

ghost commented Nov 7, 2019

🚀 Feature Proposal

When creating a spring that interpolates transition properties of type translateX(), translateY(), and/or translateZ(), react-spring should automatically convert these properties to translate3d(tx, ty, tz) as this forces the browser to utilize hardware acceleration, which produces a noticeable impact on animation performance.

Motivation

CPU animation can be quite choppy at times. Hardware acceleration animation can provide a noticeable improvement, so why not make it the default behavior?

Example

// The spring:

const spring = useSpring({
    from: { transform: "translateX(0px)" },
    transform: "translateX(500px)" 
});
// Current behavior:

<div style="transform: translateX(<!--animated values goes here-->)"></div>
// Desired behavior. Notice how translateX() was automatically converted to translate3d().

<div style="transform: translate3d(<!--animated values goes here-->)" /></div>
@ghost ghost added the kind: request New feature or request that should be actioned label Nov 7, 2019
@aleclarson
Copy link
Contributor

With v9, you can pass transform props directly to the style prop of any animated element.

More info here: #782

@ghost
Copy link
Author

ghost commented Nov 7, 2019

Sweet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: request New feature or request that should be actioned
Projects
None yet
Development

No branches or pull requests

1 participant