I have an animation related to the scroll position. Whenever the user scrolls up or down, the animation starts for that position to move the item in the viewport. If the user scrolls further, these animations must queue for the element to move smoothly along the path.
var target = getAnimation(); var props = { left: [target.x, target.easing], top: target.y }; $("#ball").animate(props, 400, "easeInOutQuad");
The problem is that when several animations get in line, the ball slows down and accelerates. I would like to do something like this:
var target = getAnimation(); var props = { left: [target.x, target.easing], top: target.y }; var ball = $("#ball"), queue = ball.queue(); if(ball.queue().length) { for(var i = 1, len = queue.length; i < len; i++) {
Starting with the easeIn function, using linear in the middle and easyOut, in the end I get a much smoother animation. Is there anyway I can access and change the animation in the queue?
Edit:
Here is a fiddle to demonstrate what I'm trying to achieve: https://jsfiddle.net/reesewill/mtepvguw/
I use linear attenuation in the violin, but I would really like the overall affect to be more like easeInOutQuad. However, since I enable the queue, I cannot just apply this attenuation function without triggering the whole effect (change the linear mode to easyInOutQuad and press the queue button several times to see). So I need something like the above to create a general impression of easeInOutQuad.
javascript jquery animation
Will reese
source share