I'm trying to animate a CSS gradient using jQuery but I haven't been able to find a solution yet. Does anyone have any ideas? The challenge is that I can't animate from one class to another because the RGBA values are random (I've created something using the mousemove event).
Here's my current code:
$(this).css(
{background: '-webkit-gradient(linear, left top, right top, from(rgba('+ a +','+ b +','+ c +','+ alpha +')), to(rgba('+ a2 +','+ b2 +','+ c2 +','+ alpha +')))'
});
But what I'd like to achieve is something like this:
$(this).stop().animate(
{background: '-webkit-gradient(linear, left top, right top, from(rgba('+ a +','+ b +','+ c +','+ alpha +')), to(rgba('+ a2 +','+ b2 +','+ c2 +','+ alpha +')))'},
{
duration: 1500,
easing: 'easeOutBounce'
}
);
The issue I'm facing is that it changes the background color with the first RGBA value instead of transitioning the gradient smoothly.
Basically, the css() method is too abrupt for my liking, I want a smoother transition. I've tried using animate with backgroundColor only and it works fine, but not with the gradient.
Any suggestions would be greatly appreciated!
EDIT : Check out my full JavaScript code here.
EDIT #2 : You can find all my responses here on jqueryscript.net.