December 11, 201411 yr I need to animate a zRotation using animate(), unfortunately animate() doesn't suppose multiple key-frames. I want to know what I'm doing wrong; with the following code since it's not working ? Can you animate between two key-frames with animate() ? $('.abox').animate({"transform":"rotateZ(90deg)"});
December 11, 201411 yr Is there a reason you want to animate using jQuery's VERY inefficient animate method as opposed to using CSS? If you had to use jQuery, which in most cases I don't recommend you will have to put in all the vendor prefixes. Edited December 11, 201411 yr by rbrtsmith
December 11, 201411 yr You can't use $.animate() for rotations, etc. You're better off using an animation library such as Velocity. JQuery's animation, as Robert has said, is poor for performance. Velocity works with jQuery, has the same API and in some cases will out perform CSS animation.
December 11, 201411 yr Wynn Im guessing that velocity makes use of requestAnimationFrame ? I've read a post some time ago by Paul Irish where he was saying it can often outperform css animations. I need to read more into it.
December 11, 201411 yr Author You can't use $.animate() for rotations, etc. You're better off using an animation library such as Velocity. JQuery's animation, as Robert has said, is poor for performance. Velocity works with jQuery, has the same API and in some cases will out perform CSS animation. How about jQuery.Keyframe. Any experience ? My goal is to animate two CSS properties, RotateZ & Perspective almost, simultaneously.
December 11, 201411 yr Wynn Im guessing that velocity makes use of requestAnimationFrame ? I've read a post some time ago by Paul Irish where he was saying it can often outperform css animations. I need to read more into it. Yes. There's some good links to articles about its performance at the top of the docs I linked to. Simple state changes should always use pure CSS, but anything more complicated I'd opt for Velocity. In fact, between Velocity and the Github teams window.fetch polyfill (for Ajax), jQuery is starting to loose its appeal. How about jQuery.Keyframe. Any experience ? My goal is to animate two CSS properties, RotateZ & Perspective almost, simultaneously. I've not used it. Why would you animate perspective with rotateZ ?
December 11, 201411 yr Author Yes. There's some good links to articles about its performance at the top of the docs I linked to. Simple state changes should always use pure CSS, but anything more complicated I'd opt for Velocity. In fact, between Velocity and the Github teams window.fetch polyfill (for Ajax), jQuery is starting to loose its appeal. I've not used it. Why would you animate perspective with rotateZ ? I meant Rotate Y & Z as seen here. Animating with CSS is not difficult, it's as mentioned, all the vendor prefixes. If only I could visualize the animation curve, then create all the css rules.
December 12, 201411 yr If you're using keyframes you may want to look into transform: rotate3d(x, y, z, angle);but yes you can animate as many properties simultaneously as you like, just not with $.animate.Example http://jsfiddle.net/yrqzn1yc/1/I took the css for the cube from this site:http://desandro.github.io/3dtransforms/docs/cube.html
December 12, 201411 yr Author If you're using keyframes you may want to look into transform: rotate3d(x, y, z, angle); but yes you can animate as many properties simultaneously as you like, just not with $.animate. Example http://jsfiddle.net/yrqzn1yc/1/ I took the css for the cube from this site: http://desandro.github.io/3dtransforms/docs/cube.html There is no way to preview the motion path of the animation, correct ?
December 16, 201411 yr Does anything support IE7? You're not going to be able to animate 3d on browsers that aren't capable. Browser support: Remember that 3D transforms are not supported below IE 10 and below Android 3.0, and that even 2D transforms aren't supported below IE 9. Also, remember that a perspective must be set on a parent element for 3D transforms to take effect. See MDN's transform guide to learn more.
December 16, 201411 yr Who even supports IE7 these days. No box-sizing makes layouts a pain. Weve even dropped IE8 support now apart from special cases.
December 17, 201411 yr Here is great article about animation. You can find here all main tool. In comments i saw this helpful advice: You can take a JS library like Snap SVG, combine it with the wonderful GSAP tools, and create some really amazing stuff.
December 17, 201411 yr Here is great article about animation. You can find here all main tool. In comments i saw this helpful advice: You could create some powerful animations with that, but for most projects using both libraries will be way more overhead than necessary. Velocity is ample for most animations, then GASP if you want something super complex -- another thing to note is that GASP isn't free.
December 17, 201411 yr Just a few plugins are paid. Core tools, like TweenMax (its the most used) are free. For instance in WordPress there is some paid plugins. But most are free. I am learning both now - TweenMax and Velocity. Edited December 17, 201411 yr by fleur
December 17, 201411 yr Don't use WP plugins for frontend stuff like JavaScript. WordPress is a content management system, it shouldn't influence things like Js and CSS in my opinion. By all means use some jQuery plugins but concatenate them into your main JavaScript file not as plugins. The main issue is with using a load of extra plugins or libraries is the extra data you are forcing clients to download. If it can be writtin in native JS or with a less heavy plugin then that should be the way to go. Always research if there are more efficient ways to producing the effect or animation I've seen way too many websites that are stuffed with loads of plugins and it really kills of performance, and as a result loses visitors. In a lot of these cases the effects could have easily been written by hand in a single file and the total page weight would be greatly reduced. Edited December 17, 201411 yr by rbrtsmith
December 17, 201411 yr Thank you for userful advice! I start understand that when i make template i put lots of js linked files in the <head>. After your words i start thinking and noticed that in HTML5 Boilerplate template there is two js files: main (for my hand-made code, i think) and plugins (for plugins code). In both files i should navigate by comments. In my past work our programmer said me to put all links to plugins in one js file with way document.write('<script type="text/javascript" src="js/jquery.reveal-modal.js"></script>'); But after that i start to read Flanagan 's book and he wrote that its incorrect way. Now i start understand that it would be much better if i coped code from plugins and put whole code (not link) in one plugins.js file. When i work i always thinking about how to look my site. But i see i should think about speed too and how to produce clean code. Thank you a lot for advice!
December 18, 201411 yr All your js should be in a single file, when in production -- the only cases where you would seperate is say there was a page on your site that included a load of unique js just for that page. Say you had google maps in your contact page, then it makes sense to load that only there, but generally everything should be in the same file to reduce on http requests, then the link to that file should come just before the closing </body> tag. If you are using a build system such as grunt then you can put all your scripts in seperate files and use grunt-concat to concatenate them all into a single file. This is a good way to keep things organised. Id also advise where possible to write your own js rather than relying heavily on plugins. Reasons: They're often heavy and full of bloat You don't have any quality control beyond reading reviews which may or may not be written by experts You'll learn more by trying to re-invent the wheel. There are some fantastic plugins around so I'm not saying never use them, I'm saying think about the function and try to re-create it yourself before jumping to plugins. Many people call themselves developers when all they do is just throw plugins at everything and don't concatenate them. This one oif the reasons there are so many horrendously slow webpages out there, these 'devs' blame it on the amount of animations and and so forth. There are other far more interractive websites that load lightening quick and respond to user interraction in an instant with no lag. The latter type will have followed best practices and more than likely wrote 90% of the functionality by hand.
December 19, 201411 yr Thank you for extremely useful advice! Ooh, i see i made a few mistakes in past projects. Now i am trying to write jq dynamic by myself. I will use grunt to make only one js file. And i notice that css3 transforms "jumping" on Samsung tablet and XP. Especially "scale". I will try use mostly jq animation or add class with css transition and transform. Add to that only one js file and i will reduce loading time. Thank you a lot! Edited December 19, 201411 yr by fleur
December 19, 201411 yr For the css transitions try to force the browser to create a new layer and render it using the GPU. You can do this by translating on the Z plane, translateZ(0) plus all the required prefixes will do this. This fixes a lot of the rendering bugs you get when transitioning transforms. Worth a try anyway! Regarding WinXP users should be dropping it now seen as MS no longer support security updates or anything for it. If the creators no longer support it why should we? unless a large proportion of your target market are for some reason still using it.
December 21, 201411 yr Thank you for advice with translateZ(0). I will try. Yes, in our country we still use XP. But mostly use, of cause, 7+. Today i found interesting article about GSAP vs Velocity.js https://news.ycombinator.com/item?id=8524622 http://www.smashingmagazine.com/2014/09/04/animating-without-jquery/ Look at comments in second article. Almost all use GSAP. I don't know maybe this comments written by people who move up GSAP . I understand that Velocity can be used only for DOM elements. GSAP can be used for powerful animation and it has nested tweens for that. GSAP can work also with canvas, SVG and extra plugins. I think its better to use one library for most task rather then a few libraries for a few task. Also there is a plugin which works only with animate(). http://greensock.com/jquery-gsap-plugin But i really like Wynn's example with velocity)) Now i am learning GSAP, because i start understand that if tomorrow my boss will ask me make html5 ad, i don't know exactly how to do the same animation that can be done with Flash. I think GSAP almost the same as Flash, has the same power. Edited December 21, 201411 yr by fleur
December 21, 201411 yr Author Can you tweak the motion path with GSAP ? Also do you need vector prefixes or GSAP takes care of this ?
December 21, 201411 yr You mean vendor prefixes? if so, you shouldn't care about it, GSAP do it. Yes you can tweak the motion path with GSAP. It has a special plugin. Have a quick look http://greensock.com/get-started-js#intro Also interesting discussion http://stackoverflow.com/questions/24370004/gsap-performance-structure List of userful animation libraries (in the end of article) http://www.webdesignerdepot.com/2014/07/can-web-animation-save-flat-design/ Edited December 21, 201411 yr by fleur
December 21, 201411 yr Author That is good news that GASP takes care of it, but velocity doesn't take care of vendor prefixes as well as mixing different transformations, really good ! The only issue is, if there was GUI that I could see the motion path, tweaking css properties to get things right, I could go insane Edited December 21, 201411 yr by CreativeSheep
Create an account or sign in to comment