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 transform instead of height and y to improve performance #12

Open
anhdd-kuro opened this issue Jan 27, 2024 · 0 comments
Open

Use transform instead of height and y to improve performance #12

anhdd-kuro opened this issue Jan 27, 2024 · 0 comments

Comments

@anhdd-kuro
Copy link

anhdd-kuro commented Jan 27, 2024

For those that are using height and y for animation, for ex bars-scale.svg, it can cause the browser to repaint, which is not good for performance.
The same animation effect can be achieved using the transform property instead.

<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
  <style>
    .spinner_jCIR {
      animation: spinner_B8Vq .9s linear infinite;
      animation-delay: -.9s;
      transform-origin: center;
      animation-timing-function: cubic-bezier(0.36, .61, .3, .98);
    }

    .spinner_upm8 {
      animation-delay: -.8s
    }

    .spinner_2eL5 {
      animation-delay: -.7s
    }

    .spinner_Rp9l {
      animation-delay: -.6s
    }

    .spinner_dy3W {
      animation-delay: -.5s
    }

    @keyframes spinner_B8Vq {

      0%,
      66.66% {
        transform: scaleY(1);
      }

      33.33% {
        transform: scaleY(1.8);
      }
    }
  </style>
  <rect class="spinner_jCIR" x="1" y="6" width="2.8" height="12" />
  <rect class="spinner_jCIR spinner_upm8" x="5.8" y="6" width="2.8" height="12" />
  <rect class="spinner_jCIR spinner_2eL5" x="10.6" y="6" width="2.8" height="12" />
  <rect class="spinner_jCIR spinner_Rp9l" x="15.4" y="6" width="2.8" height="12" />
  <rect class="spinner_jCIR spinner_dy3W" x="20.2" y="6" width="2.8" height="12" />
</svg>
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

1 participant