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

Big shift: use mask + css gradient instead of SVG Animation #220

Closed
wants to merge 4 commits into from

Conversation

danilowoz
Copy link
Owner

@danilowoz danilowoz commented Oct 5, 2020

Summary

The current approach uses a mix of masking, SVG-LinearGradient and SVG-Animation, but it always seems slower (more in #125) than other alternatives like CSS gradient + CSS animations. Also, SVG doesn't provide the best API possible to handle even with the small changes, like the interval between animation. But on another hand, CSS animation is an amazing solution for animations and how to handle it.

The biggest advantages I can see here about this new approach:

  • Low CPU usage in my testes;
  • Better API;
  • Bring new possibilities, like different kind of animations;
  • Smallest bundle;

Otherwise, assuming that the new approach needs to render somehow a style tag - in order to set the animation - it needs to use the dangerouslySetInnerHTML prop or even a third-party to set in the head scope (which would be the worst case).

Other disadvantages:

  • Responsiveness: the Rect element is not able to stretch to SVG's sizes, then it doesn't cover all css gradient
<div style={{ width: 400, height: 400, border: '1px solid #eee' }}>
   <Code style={{ width: '100%', height: '100%' }} />
</div>

Screenshot 2020-10-05 at 11 50 55

  • Background color: as the Rect has background color white, it covers the background of the page:
Before After
Screenshot 2020-10-05 at 11 54 03 Screenshot 2020-10-05 at 11 55 09

Any Breaking Changes

TODO

The following props were deprecated:

  • Interval:
  • backgroundColorOpacity
  • foregroundColorOpacity
  • baseUrl
  • Responsiveness

How to test

npm i react-content-loader@beta

@danilowoz
Copy link
Owner Author

@steffen-harbich-cognitum it might be of interest to you

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

Successfully merging this pull request may close these issues.

1 participant