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

Animation Macros #9

Open
mmmries opened this issue Apr 5, 2015 · 3 comments
Open

Animation Macros #9

mmmries opened this issue Apr 5, 2015 · 3 comments

Comments

@mmmries
Copy link
Owner

mmmries commented Apr 5, 2015

I've been playing with CSS animations in SVG, they are really cool, but very cumbersome to get the basic stuff working. If I just want to make something blink on and off I have to do this:

{:style, %{type: "text/css"}, "
    @-webkit-keyframes big-blink {
      from {opacity: 1.0}
      to   {opacity: 0.0}
    }
    polygon.big-fade {
      -webkit-animation: big-blink 2s linear 0s infinite alternate;
    }
  "},

It would be nice to do this same thing with just a single attribute or by wrapping an element.

{:circle, %{cx: 50, cy: 50, r:25, fill: "orange", blink: true}, nil}

OR

{:blink, [
  {:circle, %{cx: 50, cy: 50, r: 25, fill: "orange"}, nil}
]}

@film42 do you have any preference between wrapping vs attribute?

@mmmries
Copy link
Owner Author

mmmries commented Apr 5, 2015

or perhaps we should be able to provide some attributes to the animation like this?

{:blink, %{repeat: 3} [
  {:hexagon, %{cx: 50, cy: 50, r: 40, fill: "lightgreen"}}
]}

@mmmries
Copy link
Owner Author

mmmries commented Apr 5, 2015

http://goo.gl/SH7z9I

@mmmries
Copy link
Owner Author

mmmries commented Apr 5, 2015

I'm starting to have second thoughts about this feature. Performing CSS animations on elements inside and SVG currently causes a lot of repaints on the browser. I profiled the link above and it was spending about 25% of the rendering threads time just computing and painting the rotation. If you create the same SVG and put the animation on the SVG element (instead of the the g element inside the SVG) it runs at 60fps without using almost any CPU at all.

http://goo.gl/5TFkgk

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