parish parab parish parab - 1 year ago 131
Javascript Question

animate image left to right on scroll

what i am trying to do is i have around 6 inline images i want slide them left to right on specific position and stop there for each image.And images have to slide at the time the scrool comes over them.
i tried this javascript for it (totally new to JS)

function slideright(){
var a = getElementsByClassName('.onfoot1');
var stoppos = 100;
if (parseInt(< stoppos )
{ = parseInt( + 3 + "px";
setTimeout(slideright , 1);


<div class="onfoot1"></div>




Answer Source

I've put together a working examle for your code:

I've made a few assumptions there... You are using $(...) syntax so I guessed you are using JQuery. JQuery has a .animate() function which should do the trick ( Also I guessed that you may want to make the css-position of the div fixed so it stays on screen when you scroll.

EDIT: I noticed that you don't want you image on the bottom of the screen but animating when screen reaches it. Updated my fiddle to do that:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download