Animate positions over short distances over long durations in jQuery

Looking at the inclusion of some very subtle animations on the page (think clouds are floating slowly over the sky).

$('DIV#clouds').animate( { left: '100px' }, 30 *1000 ); 

I tried to implement this in jQuery, and it seems that jQuery cannot do less than 1px increments (like flash). The animation works, it’s just not smooth, it looks nervous every time the cloud moves even one pixel in a few milliseconds.

My assumption is that subpixel movements are not possible, I just ask you to hope that I'm wrong.

+1
source share
1 answer

No, because the left property can only have integer pixels as a value. All jQuery does is add a pixel to left up to 100px. You cannot expect it to add half a pixel to animate a smoother one, sorry. Flash may do this with anti-aliasing.

In addition, { left : '100px'} must have single quotes around the px value.

+1
source

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


All Articles