andrew_biggart Posted June 15, 2009 Share Posted June 15, 2009 Does anyone know how i would go about creating this effect? When you scroll over the image it moves down and reveals another image below it. Like this http://www.iamdan.net/works.html and also at the top of the page when u clcik news i drop down box slides out. Can anyone point me in the right direction to creating these effects please? Quote Link to comment https://forums.phpfreaks.com/topic/162190-what-is-this-effect/ Share on other sites More sharing options...
Alex Posted June 15, 2009 Share Posted June 15, 2009 I made a quick example for you. One method is having 2 images and making them overlap by giving one a negative margin. Then manipulating this margin using JavaScript. Here's my JavaScript: function moveImage(id, millisec) { var speed = Math.round(millisec / 100); var timer = 0; if(parseInt(document.getElementById(id).style.marginTop.substr(0, document.getElementById(id).style.marginTop.length-2)) < -58) { for(var i = 0;i <= 100;i++) { setTimeout("setMargin('" + id + "', 'dec')",(timer * speed)); timer++; } } } function restorePlacement(id, millisec) { var speed = Math.round(millisec / 100); var timer = 0; if(parseInt(document.getElementById(id).style.marginTop.substr(0, document.getElementById(id).style.marginTop.length-2)) < 0) { for(var i = 0;i <= 100;i++) { setTimeout("setMargin('" + id + "', 'inc')",(timer * speed)); timer++; } } } function setMargin(id, movement) { if(movement == 'dec') { document.getElementById(id).style.marginTop = parseInt(document.getElementById(id).style.marginTop.substr(0, document.getElementById(id).style.marginTop.length-2)) + 1 + 'px'; } else if(movement == 'inc') { document.getElementById(id).style.marginTop = parseInt(document.getElementById(id).style.marginTop.substr(0, document.getElementById(id).style.marginTop.length-2)) - 1 + 'px'; } } And here's the html: <img id="php" src="http://farm4.static.flickr.com/3195/3131799428_962aba66f1.jpg?v=0" alt="Php" /><br /> <img id="mysql" style="margin-top: -158;" src="http://www.adwh.com/images/logo-mysql.jpg" alt="MySQL" onmouseover="moveImage('mysql', 300)" onmouseout="restorePlacement('mysql', 300);" /> Here's the result: http://alexwd.us.to:1337/test/rollover.php Quote Link to comment https://forums.phpfreaks.com/topic/162190-what-is-this-effect/#findComment-855938 Share on other sites More sharing options...
justAnoob Posted June 15, 2009 Share Posted June 15, 2009 if you dont' mind me asking, on the first site iamdan, the picture flows smoothly, on your example, you can control the picture up and down movement. Is there a simple fix to that? your example is still pretty cool though. Quote Link to comment https://forums.phpfreaks.com/topic/162190-what-is-this-effect/#findComment-855989 Share on other sites More sharing options...
Alex Posted June 15, 2009 Share Posted June 15, 2009 if you dont' mind me asking, on the first site iamdan, the picture flows smoothly, on your example, you can control the picture up and down movement. Is there a simple fix to that? your example is still pretty cool though. Yea, my example was just a quick fix. I might edit it with a better example later. But the reason why it's like that is because on the first website as long as it's within the area of either image it flows down. On my example only if it's on the MySQL image does it move, so even if you place it on the Php image once it has moved, it will go down. The solution and reason behind this is simple. You must just apply this to a <div> that contains the images, instead of applying it to images. Quote Link to comment https://forums.phpfreaks.com/topic/162190-what-is-this-effect/#findComment-856008 Share on other sites More sharing options...
Zane Posted June 15, 2009 Share Posted June 15, 2009 This is straight from the source of the site you posted <br /> $(function() {<br /> $('.wrap').hover(function() {<br /> $(this).children('.front').stop().animate({ "top" : '50px'}, 300); <br /> }, function() {<br /> $(this).children('.front').stop().animate({ "top" : '0'}, 250); <br /> });<br /> });<br /> This is called jQuery....essentially a language written from javascript statements. Quote Link to comment https://forums.phpfreaks.com/topic/162190-what-is-this-effect/#findComment-856030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.