Info: Can I globally swap out $.animate() with $.velocity()?
See original GitHub issueI was messing around with swapping out the animate function entirely to see if I could utilize velocity without having to alter third-party scripts (in this case a Wordpress theme). Is this something that is supported and/or recommended?
I put the following after both jQuery and velocity are included:
jQuery.fn.animate = jQuery.velocity.animate;
Any tips or ideas appreciated. Thanks for the work on this great plugin!
Issue Analytics
- State:
- Created 9 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
.animate() | jQuery API Documentation
animate() , can be turned off globally by setting jQuery.fx.off = true , which effectively sets the duration to 0. For more information,...
Read more >animate.css animation speed control - Stack Overflow
You can change animation duration globally for everything with .animated class. For example, here I changed it to 0.6s and worked well for...
Read more >animation-timing-function - CSS: Cascading Style Sheets | MDN
The animation-timing-function CSS property sets how an animation progresses through the duration of each cycle.
Read more >Set the start time and speed of an animation effect
On the Animations tab, in the Duration box, enter the number of seconds that you want the effect to run.
Read more >The ultimate guide to proper use of animation in UX
Generally speaking, we can use it for the states when an object does not change its position. Ease-in or acceleration curve. We can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Once Velocity has loaded, you would include this:
jQuery.fn.animate = jQuery.fn.velocity;
The reason Velocity doesn’t overwrite $.animate() automatically is because it’s considered bad practice to overwrite third-party API’s since you can never guarantee 100% API compatibility, and I do not claim to do so with Velocity.
I wouldn’t want to go on record as recommending you do it, but by all means you can try it 😃
Thanks a bunch for reporting back, Jason. This is really helpful for others.
The implementations of “stop” are also different in jQuery and Velocity: http://julian.com/research/velocity/#stop
Indeed, there’s a reason Velocity compresses to 7kb and jQuery compresses to 33kb. jQuery is a swiss-army knife, and that’s its power.
Stay tuned for the removal of the jQuery dependency thanks to @nmussy.