Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Senior Member shoffman3572's Avatar
    Join Date
    Jul 2008
    Location
    Fullerton, CA
    Posts
    137
    Member #
    16990
    started to play around with a coverflow (kind of :nervous: ) set up. Thought I'd post the code here and see if anyone wanted to try it out/make it better! (which I'm sure someone can since my javascript skills aren't that great).

    copy the code below into a html file - I've attached the images I used for this test. create a folder called coverFlow for the images - store this folder in the root folder where your html file is..

    HTML 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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Cover Flow Experiment</title>
    <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
    
    <script type="text/javascript">
    init = new Array(4,3,2,1,5,6,7);
    run = 0;
    function runThrough(){
    	
    	
    		opFF = run/10;
    		$("#cover"+init[run]+"").animate({ opacity: ""+opFF+"" });
    		run++;
    		if (run ==7) { return; }
    	delay = setTimeout("runThrough(run)", 100);
    	}
    
    function move(box) {
    	for (i=1; i<8; i++) {
    		w = document.getElementById("box"+i+"").offsetWidth;
    		
    		if (w == 220)
    		{
    			$("#box"+i+"").animate({ width: "200px", height: "200px" });
    		}
    	}
    	slide(box);
    }	
    function slide(box){
    		mainPos = document.getElementById("box"+box+"").offsetLeft;
    		dist=0;
    		if (mainPos < 300) { dist = 300 - mainPos; } 
    		if (mainPos > 300) { dist = mainPos - 300; }
    	for (i=1; i<8; i++) {
    		if (mainPos < 300) {	
    		boxPos = document.getElementById("box"+i+"").offsetLeft;
    		$("#box"+i+"").animate({ left: boxPos + dist });
    		}
    		else
    		{
    		boxPos = document.getElementById("box"+i+"").offsetLeft;
    		$("#box"+i+"").animate({ left: boxPos - dist });
    		}
    	}
    	document.getElementById("box"+box+"").style.zIndex = 7; 
    	document.getElementById("cover"+box+"").style.opacity = 0;
    	document.getElementById("cover"+box+"").style.filter = 'alpha(opacity="0")';	
    	zIn=6;
    	for (z=box; z>0; z--){
    	  if (z != box) { document.getElementById("box"+z+"").style.zIndex = zIn; setOpacity(z);	}
    	  zIn--;
    	}
    	for (z=box; z<8; z++){
    	  if (z != box) { document.getElementById("box"+z+"").style.zIndex = zIn; setOpacity(z);	}
    	  zIn--;
    	}
    	return;
    }
    function setOpacity(value) {
    	document.getElementById("cover"+value+"").style.opacity = value/10;
    	document.getElementById("cover"+value+"").style.filter = 'alpha(opacity=' + value*10 + ')';
    	return;
    }
    
    </script>
    </head>
    
    <body onload="runThrough();">
    
    <div id="container" style="position:absolute; margin-left:20px; margin-top:20px; width:800px; height:200px; overflow:hidden" />
    
    	<div id="box1" style="position:absolute; left:0px; top:0px; width:200px; height:200px; z-index:4;" /><img src="coverFlow/image1.jpg" id="pic1" onclick="move(1)" /><div id="cover1" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic1" onclick="move(1)" /></div> </div>
    
    	<div id="box2" style="position:absolute; left:100px; top:0px; width:200px; height:200px; z-index:5;" /><img src="coverFlow/image2.jpg" id="pic2" onclick="move(2)" /><div id="cover2" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic2" onclick="move(2)" /></div> </div>
    
    	<div id="box3" style="position:absolute; left:200px; top:0px; width:200px; height:200px; z-index:6;" /><img src="coverFlow/image3.jpg" id="pic3" onclick="move(3)" /><div id="cover3" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic3" onclick="move(3)" /></div> </div>
    
    	<div id="box4" style="position:absolute; left:300px; top:0px; width:200px; height:200px;  z-index:7;" /><img src="coverFlow/image4.jpg" id="pic4" onclick="move(4)" /> <div id="cover4" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic4" onclick="move(4)" /></div></div>
    
    	<div id="box5" style="position:absolute; left:400px; top:0px; width:200px; height:200px;  z-index:3;" /><img src="coverFlow/image5.jpg" id="pic5" onclick="move(5)" /><div id="cover5" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic5" onclick="move(5)" /></div> </div>
    
    	<div id="box6" style="position:absolute; left:500px; top:0px; width:200px; height:200px;  z-index:2;" /><img src="coverFlow/image6.jpg" id="pic6" onclick="move(6)" /> <div id="cover6" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic6" onclick="move(6)" /></div></div>
    
    	<div id="box7" style="position:absolute; left:600px; top:0px; width:200px; height:200px;  z-index:1;" /><img src="coverFlow/image7.jpg" id="pic7" onclick="move(7)" /><div id="cover7" style="position:absolute; left:0px; top:0px; width:200px; height:200px; background-color:#fff; opacity:1.0;filter:alpha(opacity=100);"><img src="coverFlow/seeThrough.png" id="pic7" onclick="move(7)" /></div> </div>
    
    </div>
    
    </body>
    </html>
    Attached Images Attached Images

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:13 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com