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

Question: Who requires SVG support? #74

Closed
julianshapiro opened this issue May 19, 2014 · 29 comments
Closed

Question: Who requires SVG support? #74

julianshapiro opened this issue May 19, 2014 · 29 comments

Comments

@julianshapiro
Copy link
Owner

I'm considering adding support for SVG element animation. By default, neither jQuery, nor Transit, nor Velocity support this. Why? Because most CSS properties don't take effect on SVG elements; you have to tween their HTML attributes (e.g. width='100%') directly.

CSS properties that already work by default for SVG elements:
opacity, 2D transforms (all browsers except Safari desktop and mobile)

What I'd be adding support for:
transform (full browser support), x, y, width, height, cx, cy, r, rx, ry, x1, y1, x2, y2 -- basically, anything that's numerically tweenable.

How it would work: Before an element is animated, there would be a check for node instanceof SVGElement. When Velocity detects this flag, it'll apply all properties directly to the SVG element's attributes instead of its style tag.

So here's the question, who would use this? Better yet, is anyone dying for this to be implemented?

I only consider this a valid consideration for Velocity if it helps people avoid having to load additional SVG animation libraries; if you still need whatever your current SVG solution is even once Velocity has integrated this support, then it's not worth supporting at all.

@julianshapiro julianshapiro changed the title Question for Velocity Users: Who needs SVG support? Question for Velocity Users: Who requires SVG support? May 19, 2014
@legomushroom
Copy link

  • I'd like to see full SVG support in a way of extension. No need to overblow codebase for it. Intend to work with SVG? - link additional file and you are in the game :)
  • CSS transforms for SVG elements do not work nor in FF no in IE(3d at least).
  • The idea of prototype check seems good for me.
  • 👍 for the step callback.
  • I have a gist where I'm collecting CSS properties for SVG https://gist.github.com/legomushroom/7397561

@exside
Copy link

exside commented May 19, 2014

would love svg support (no need for snap then =D), but also see the point of bloating the codebase...

@julianshapiro
Copy link
Owner Author

@exside, @legomushroom

There should be very minimal bloat if I implement this.

CSS transforms for SVG elements do not work nor in FF no in IE (3d at least).

Right, thanks for the reminder. Updated original post.

I have a gist where I'm collecting CSS properties for SVG https://gist.github.com/legomushroom/7397561

Awesome, Oleg! Bookmarked.

@julianshapiro julianshapiro changed the title Question for Velocity Users: Who requires SVG support? Question for Velocity users: Who requires SVG support? May 30, 2014
@frekw
Copy link

frekw commented Jun 4, 2014

Hi!

I'm definitely interested in support for SVG animations. I'm currently using SVG.js as well as Snapsvg.js in two different projects, but the only use I have for both of them is animating x/y/transform properties.

It would be really nice to get rid of the huge overhead they impose for the animations use case, especially since e.g jQuery can be used to modify the SVG DOM just fine, jQuery + Velocity would be a great combination for more basic SVG animations.

@speculr
Copy link

speculr commented Jun 7, 2014

yes please

@dashed
Copy link

dashed commented Jun 8, 2014

+1.

@msurguy
Copy link

msurguy commented Jun 18, 2014

I was actually looking for SVG animations with velocity :)
Check this out to see how I would use it : http://codepen.io/msurguy/pen/rAved

But of course potential would be very big if I could do anything with SVGs like I could do with any DOM elements.

@julianshapiro julianshapiro changed the title Question for Velocity users: Who requires SVG support? Question: Who requires SVG support? Jun 20, 2014
@bhongy
Copy link

bhongy commented Jun 20, 2014

I just changed all animations in my current project from Snap.svg to Velocity over the last weekend. Your API is way intuitive to work with, and I want all animation handlings to be queued and executed in one place (via Velocity).

I can do most animations that my project is required with only Velocity.js except doing something like transforming a path (like animating a shape from triangle to a square).

Currently, I use Snap to load my SVG spirtes then inject different fragments of the code into divs, then use Velocity.js to animate transform or opacity properties of the SVG elements.

So, supporting for SVG animation will be great. I hope to remove Snap from my project dependency - it is not the smallest library, and I just use it to load SVG sprites and animating shapes. I was thinking about implementing it myself but not confident that I'm good enough to deal with cross-browser quirks.

Hope it would not add much more weight to Velocity, else I think @legomushroom made a good point that having it as a plugin might be a good option.

@julianshapiro
Copy link
Owner Author

Hey Thanik!

I just changed all animations in my current project from Snap.svg to Velocity over the last weekend. Your API is way intuitive to work with, and I want all animation handlings to be queued and executed in one place (via Velocity).

Awesome. Thank you for the kind words :)

Hope it would not add much more weight to Velocity, else I think @legomushroom made a good point that having it as a plugin might be a good option.

I'll have it integrated directly into Velocity itself. It should barely add any weight. This will land in the next 14 days. Stay tuned! :)

@bhongy
Copy link

bhongy commented Jun 20, 2014

Hey Julian, awesome news! I really admire your great work on Velocity. Love the techniques you implement to cache DOM states and avoid querying it for computed values.

@julianshapiro
Copy link
Owner Author

How often do you use CSS transforms on SVG's as opposed to sticking with x, y, and the other native SVG attributes?

@ydaniv
Copy link
Contributor

ydaniv commented Jun 21, 2014

@julianshapiro I reckon transform usage is more common than xs and ys in SVG, especially for animations.

@julianshapiro
Copy link
Owner Author

Yeah, I'd agree. Problem is that it's not possible to support it on Android stock browser and all of IE unless there's an add-on to Velocity to provide CSS transform matrix math support.

I sort of feel like leaving it out altogether since people will complain that their SVG transforms aren't working in IE/AOSP.

@ydaniv
Copy link
Contributor

ydaniv commented Jun 21, 2014

I think that the inline transform attribute IS supported in all browsers, even though CSS transforms aren't.
See: http://msdn.microsoft.com/en-us/library/ie/bg124140(v=vs.85).aspx

@exside
Copy link

exside commented Jun 21, 2014

CSS transforms whenever possible =)

@julianshapiro
Copy link
Owner Author

I think that the inline transform attribute IS supported in all browsers, even though CSS transforms aren't.

You have to pass it a raw matrix/matrix3d value, though. Otherwise, only the scale transform works. No idea why.

@ydaniv
Copy link
Contributor

ydaniv commented Jun 21, 2014

IMHO, if it's trivial to add SVG support for modern browsers then adding that with the disclaimer that for additional support users need to add another plugin is totally legit.

@bhongy
Copy link

bhongy commented Jun 21, 2014

I primarily use opacity/transform to animate - just to keep the work in the composite layer to avoid repainting and layout recalculation (if I understand the discussion correctly). I have not tested in IE---will do it tonight.

What is your thoughts about changing all transforms to matrix and matrix3d based on the browser support? But keeping the API the same. (Like how GSAP do it).

If so, please let me know if there is anything that I can help.

@julianshapiro
Copy link
Owner Author

I don't think the same layout recalc issues would apply to SVG's since they have no concept of document flow. But I could be wrong; haven't checked into it yet.

Either way, there's one last thing I need: #120.

@thasmo
Copy link

thasmo commented Jun 22, 2014

+1

@bhongy
Copy link

bhongy commented Jun 22, 2014

d'oh! I never thought about that. It makes very much sense. It seems like anything in SVG gets repainted (using show paint rectangles in Chrome) during animation even with the translateZ hack.

@bhongy
Copy link

bhongy commented Jun 23, 2014

@julianshapiro, would stroke, stroke-width, fill, etc be a part of this SVG support additions? It might be just similar to backgroundColor, color, etc.

@julianshapiro
Copy link
Owner Author

Yup, I already built in support for those. :-)

Sent from my phone.

On Jun 23, 2014, at 12:29 PM, Thanik Bhongbhibhat [email protected] wrote:

@julianshapiro, would stroke, stroke-width, fill, etc be a part of this SVG support additions? It might be just similar to backgroundColor, color.


Reply to this email directly or view it on GitHub.

@bhongy
Copy link

bhongy commented Jun 23, 2014

Sweet!! 👍

@julianshapiro julianshapiro added this to the 1.0.0 milestone Jun 27, 2014
@nexflo
Copy link

nexflo commented Jun 27, 2014

yup awesome! +1

@julianshapiro
Copy link
Owner Author

This took a tremendous amount of time, but only 80 additional lines of code. Woohoo!

See http://velocityjs.org/#svg for implementation details. Please test and report any issues in a new thread.

Enjoy!

@dashed
Copy link

dashed commented Jun 28, 2014

@julianshapiro Awesome work! Really appreciate adding SVG support. Will be playing with the new features soon.

@tomByrer
Copy link
Contributor

This took a tremendous amount of time, but only 80 additional lines of code.

Alot of my coding is like that; glad I'm not the only one ;)

only 2D (not 3D) CSS transform properties work with SVGs.

Is that because of flaky SVG support in browsers you decided not to add it, or...?

Thanks for your hard work!

@jonahbron
Copy link

I'm going to need to animate SVG elements, so I'll definitely be investigating this implementation. +1

Rycochet pushed a commit that referenced this issue Aug 3, 2020
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