JQuery animation, not animation

I use the animate () function to change the background position of the button on hover, the problem is that instead of β€œanimating” it just waits for the duration (500) and clicks in the new background position - without a smooth transition.

$('.confirm').hover(function() { $(this).animate({backgroundPosition: '0, -40px'}); }, function() { $(this).animate({backgroundPosition: '0, 0'}); }); 

What I use JS. Any ideas why this doesn't make a smooth transition? It acts like a timeout. I have both jQuery and UI.

Thanks!

+6
source share
3 answers

You cannot revive the background position. Animation properties expect a single value, such as opacity:1 , left:'50px' , etc.

This plugin should add the features you need: http://www.protofunc.com/scripts/jquery/backgroundPosition/

+9
source

Well, I was not able to get it to work without the plugin, but the good news is that it is. You can try http://www.protofunc.com/scripts/jquery/backgroundPosition/

edit .... rats ... sorry ... just saw that XD had already been sent

0
source

Try to extract the section animation from the callback. And call it asynchronously, but with .delay (500) in front of it.

-1
source

Source: https://habr.com/ru/post/893207/


All Articles