Javascript simple floating and forever moving image

In this example, I will show you how to  animate an element and make it moving up and down infinitely. And I will do it without any explicit Loop construct (no for, while loops), with the help of the jQuery.

HTML:

Javascript

 How it works

In CSS, we set the element (the IMG) to absolute position so that it “float up” and detach from the normal layout. With this, we can move the image up and down by changing the “top” CSS property.

In Javascript, we define two functions, bannerMoveDown() and bannerMoveUp(). In each function, we use the jQuery animate() method to animate the IMG element, and after the each animation ends, we call the other one respectively, thus making it loop forever.

Finally, we call bannerMoveDown() to initiate the animation loop.

Fully functional example

Please checkout a fully function example here on JSFiddle: http://jsfiddle.net/madcoda/mN3n8/

Thanks for reading, Leave your comments down below if you encounter any problem!

Extremely slow installation of OSX 10.10 Yosemite

I was experiencing very lengthy install while upgrading my Mac mini 2011 from 10 find out here now.9 Mavericks to 10.10 Yosemite Developer Preview. The install process just appeared to hang at “5mins left”.

After some research, I believe that the cause of this is the MacTex library. If you have installed the MaxTex or any Tex library, you may experience this. The solution is just to wait, it may take a good couple of hours. Leave it overnight and it should be ready the next morning 🙂