I'm using Velocity.js library to provide different animations on my page. I would like to use it also to reveal animations when I scroll (similar to WOW.js), so I'm using this code (with appear.js library to reveal animations on scroll):
$('[data-animation="velocity"]').each(function() {
var animationName = $(this).attr('data-animation-name'),
delay = parseInt($(this).attr('data-animation-delay'), 10),
duration = parseInt($(this).attr('data-animation-duration'), 10);
$(this).appear(function() {
$(this).velocity(animationName, {
visibility: 'visible',
delay: delay,
duration: duration
});
});
});
Thanks to that I can choose between different animations provided by Velocity.js library, set duration and delay.
Example
My question is: how about performance (for example on mobile or weaker PC's)? Isn't that overkill (I use Velocity.js for other things so I don't want to add another library like WOW.js and Animate.CSS)? I'm asking because WOW.js uses CSS for animations (by adding CSS class). On the other hand, Velocity.js uses JavaScript to change the values of CSS properties like opacity, transform etc. It's working good for me on my iMac even with many animated elements, but I didn't test it on other less performant devices.