/    Sign up×
Community /Pin to ProfileBookmark

How would I do this animation?

I’m looking for a way to do a particular animation. I have to images side-by-side horizontally. When the left image is clicked, the left image rolls out to the right covering the right image. When the right image is clicked, the right image rolls out to the left covering the left image.

Is there something like this already out there? I have very limited experience with MooTools (I’ve used a few slideshows) so I don’t really know what’s out there. Thanks for your help.

[upl-file uuid=5d2ebe88-5b6c-44b8-a644-b6892886d07d size=11kB]2images.JPG[/upl-file]

[upl-file uuid=867c2c96-9c89-4643-9fbe-8df0ffd37f2f size=11kB]roll.JPG[/upl-file]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@vwphillipsAug 22.2011 — [CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>
<style type="text/css">
/*<![CDATA[*/

#tst {
position:relative;left:50px;top:50px;width:400px;height:150px;
}

#tst IMG{
position:relative;float:left;
}

/*]]>*/
</style>

</head>

<body>

<div id="tst" >
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" />
<img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt6.jpg" alt="img" />
</div>

<script type="text/javascript">
/*<![CDATA[*/

function zxcSlide(o){
var oop=this,obj=document.getElementById(o.ID),ms=o.Duration,imgs=obj.getElementsByTagName('IMG');
this.obj=obj;
this.ms=typeof(ms)=='number'?ms:1000;
this.dyl=null;
imgs[0].onmouseup=function(){ oop.slide(this,imgs[0].width); }
imgs[1].onmouseup=function(){ oop.slide(this,-imgs[1].width); }
}

zxcSlide.prototype={

visibility:function(){
this.obj.style.visibility=this.top()>=this.view?'visible':'hidden';
},

slide:function(img,to){
clearTimeout(this.dly);
img.style.zIndex='2';
img.onmouseup=null;
this.img=img;
this.animate(0,to,new Date().getTime(),this.ms);
},

animate:function(s,f,srt,mS){
var oop=this,op=oop.oop,ms=new Date().getTime()-srt,d=(f-s)/mS*ms+s;
if (isFinite(d)){
oop.now=d;
}
this.img.style.left=oop.now+'px';
if (ms<mS){
oop.dly=setTimeout(function(){oop.animate(s,f,srt,mS); },10);
}
else {
this.img.style.left=f+'px';
}
}

}


new zxcSlide({
ID:'tst', // the unique ID name of the 'float' element. (string)
Duration:1000 //(optional) the scroll duration in milli seconds. (number, default = 1000)
});





/*]]>*/
</script>

</body>

</html>[/CODE]
×

Success!

Help @DeLorean719 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...