jcdevelopment
06-18-2008, 07:53 PM
I have an application i have been working on for a few days, and i am almost done thanks to CF. Heres the last little add-on i want for this application. Its for a real estate company and they use this application to adjust the pictures in their gallery. They switch just fine without any problems. What i want is instead of them just switching i want animation.
I want them to move to the opposing div. Like if i were to select the "div1" and selected "div4". I would want the "div1" to start moving towards "div4"'s loacation and "div4" to start moving towards "div1"s location. Doeas anyone know where i can find an example like this or even a tutorial? Thanks for any help.
here is my page and what it looks like now.
<!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>Untitled Document</title>
<style type="text/css">
* {
margin:0px;
padding:0px;
}
body {
background-color:#f2f2f2;
}
#pictrueContainer {
width:300px;
text-align:center;
margin:10px;
border:1px solid #666666;
background-color:#FFFFFF;
padding-bottom:3px;
}
#outsidePictrueContainer {
width:300px;
margin:10px;
border:1px solid #666666;
background-color:#FFFFCC;
padding-bottom:3px;
}
.pictureEven {
height:75px;
width:295px;
background-color:#CCCCCC;
border:1px solid #000000;
margin-top:3px;
text-align:left;
position:relative;
}
.pictureEven img {
height:75px;
width:75px;
background-color:#CCCCCC;
border-right:1px solid #000000;
border-bottom:0px;
border-left:0px;
border-top:0px;
}
.pictureEven img:hover {
filter:alpha(opacity=50);
-moz-opacity:.50;
opacity:.50;
cursor:pointer;
}
.pictureOdd {
height:75px;
width:295px;
background-color:#CCCCCC;
border:1px solid #000000;
margin-top:3px;
text-align:left;
position:relative;
}
.pictureOdd img {
height:75px;
width:75px;
background-color:#CCCCCC;
border-right:1px solid #000000;
border-bottom:0px;
border-left:0px;
border-top:0px;
}
.pictureOdd img:hover {
filter:alpha(opacity=50);
-moz-opacity:.50;
opacity:.50;
cursor:pointer;
}
.link_style {
position:relative;
vertical-align:top;
left:60px;
top:27px;
font-family:"Courier New", Courier, monospace;
font-size:12px;
color:#333333;
}
</style>
<script type="text/javascript">
var foo = null; // object
function doMove() {
foo.style.top = parseInt(foo.style.top)+3+'px';
setTimeout(doMove,5); // call doMove in 20msec
}
function init() {
foo = document.getElementById('title'); // get the "foo" object
foo.style.top = '0px'; // set its initial position to 0px
foo.style.zIndex='100';
doMove(); // start animating
}
var selectedCount = 0;
var firstSelectedDiv;
var secondSelectedDiv;
function toggleTiles(tile)
{
switch (selectedCount)
{
case 0:
selectedCount = 1;
firstSelectedDiv = document.getElementById(tile);
firstSelectedDiv.style.opacity = '0.5';
firstSelectedDiv.style.filter ="alpha(opacity='50')";
break;
case 1:
selectedCount = 2;
secondSelectedDiv = document.getElementById(tile);
if ( secondSelectedDiv == firstSelectedDiv )
{
alert("Must Select Two images");
selectedCount = 1;
} // end: if
else //
{
secondSelectedDiv.style.opacity = '0.5';
secondSelectedDiv.style.filter ="alpha(opacity='50')";
toggleTiles(null);
} // end: else
break;
case 2:
var swapTileContents = firstSelectedDiv.innerHTML;
firstSelectedDiv.innerHTML = secondSelectedDiv.innerHTML;
secondSelectedDiv.innerHTML = swapTileContents;
alert('swapped');
firstSelectedDiv.style.opacity = '1.0';
firstSelectedDiv.style.filter ="alpha(opacity='100')";
secondSelectedDiv.style.opacity = '1.0';
secondSelectedDiv.style.filter ="alpha(opacity='100')";
selectedCount = 0;
break;
}
}
</script>
</head>
<body>
<div id="pictrueContainer">
<div class="pictureOdd" id="tile0x0" onclick="toggleTiles(this.id);" > <img src="picUpload/pic1.jpg" alt="1" /> <a href="#" class="link_style">Listing_11.jpg</a> </div>
<div class="pictureEven" id="tile0x1" onclick="toggleTiles(this.id);" ><img src="picUpload/pic2.jpg" alt="2" /> <a href="#" class="link_style">Listing_21.jpg</a> </div>
<div class="pictureOdd" id="tile0x2" onclick="toggleTiles(this.id);" ><img src="picUpload/pic3.jpg" alt="3" /> <a href="#" class="link_style">Listing_22.jpg</a></div>
<div class="pictureEven" id="tile0x3" onclick="toggleTiles(this.id);" ><img src="picUpload/pic4.jpg" alt="4" /> <a href="#" class="link_style">Listing_23.jpg</a></div>
<div class="pictureOdd" id="tile0x4" onclick="toggleTiles(this.id);"><img src="picUpload/pic5.jpg" alt="5" /> <a href="#" class="link_style">Listing_24.jpg</a></div>
<div class="pictureEven" id="tile0x5" onclick="toggleTiles(this.id);"><img src="picUpload/pic6.jpg" alt="6"/> <a href="#" class="link_style">Listing_25.jpg</a></div>
<div class="pictureOdd" id="tile0x6" onclick="toggleTiles(this.id);"><img src="picUpload/pic7.jpg" alt="7" /><a href="#" class="link_style">Listing_26.jpg</a></div>
<div class="pictureEven" id="tile0x7" onclick="toggleTiles(this.id);"><img src="picUpload/pic8.jpg" alt="8" /> <a href="#" class="link_style">Listing_27.jpg</a></div>
<div class="pictureOdd" id="tile0x8" onclick="toggleTiles(this.id);"><img src="picUpload/pic9.jpg" alt="9" /> <a href="#" class="link_style">Listing_28.jpg</a></div>
<div class="pictureEven" id="tile0x9" onclick="toggleTiles(this.id);"><img src="picUpload/pic10.jpg" alt="10" /> <a href="#" class="link_style">Listing_29.jpg</a></div>
</div>
<div id="outsidePictrueContainer">
<img src="picUpload/pic11.jpg" />
</div>
</body>
</html>
I want them to move to the opposing div. Like if i were to select the "div1" and selected "div4". I would want the "div1" to start moving towards "div4"'s loacation and "div4" to start moving towards "div1"s location. Doeas anyone know where i can find an example like this or even a tutorial? Thanks for any help.
here is my page and what it looks like now.
<!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>Untitled Document</title>
<style type="text/css">
* {
margin:0px;
padding:0px;
}
body {
background-color:#f2f2f2;
}
#pictrueContainer {
width:300px;
text-align:center;
margin:10px;
border:1px solid #666666;
background-color:#FFFFFF;
padding-bottom:3px;
}
#outsidePictrueContainer {
width:300px;
margin:10px;
border:1px solid #666666;
background-color:#FFFFCC;
padding-bottom:3px;
}
.pictureEven {
height:75px;
width:295px;
background-color:#CCCCCC;
border:1px solid #000000;
margin-top:3px;
text-align:left;
position:relative;
}
.pictureEven img {
height:75px;
width:75px;
background-color:#CCCCCC;
border-right:1px solid #000000;
border-bottom:0px;
border-left:0px;
border-top:0px;
}
.pictureEven img:hover {
filter:alpha(opacity=50);
-moz-opacity:.50;
opacity:.50;
cursor:pointer;
}
.pictureOdd {
height:75px;
width:295px;
background-color:#CCCCCC;
border:1px solid #000000;
margin-top:3px;
text-align:left;
position:relative;
}
.pictureOdd img {
height:75px;
width:75px;
background-color:#CCCCCC;
border-right:1px solid #000000;
border-bottom:0px;
border-left:0px;
border-top:0px;
}
.pictureOdd img:hover {
filter:alpha(opacity=50);
-moz-opacity:.50;
opacity:.50;
cursor:pointer;
}
.link_style {
position:relative;
vertical-align:top;
left:60px;
top:27px;
font-family:"Courier New", Courier, monospace;
font-size:12px;
color:#333333;
}
</style>
<script type="text/javascript">
var foo = null; // object
function doMove() {
foo.style.top = parseInt(foo.style.top)+3+'px';
setTimeout(doMove,5); // call doMove in 20msec
}
function init() {
foo = document.getElementById('title'); // get the "foo" object
foo.style.top = '0px'; // set its initial position to 0px
foo.style.zIndex='100';
doMove(); // start animating
}
var selectedCount = 0;
var firstSelectedDiv;
var secondSelectedDiv;
function toggleTiles(tile)
{
switch (selectedCount)
{
case 0:
selectedCount = 1;
firstSelectedDiv = document.getElementById(tile);
firstSelectedDiv.style.opacity = '0.5';
firstSelectedDiv.style.filter ="alpha(opacity='50')";
break;
case 1:
selectedCount = 2;
secondSelectedDiv = document.getElementById(tile);
if ( secondSelectedDiv == firstSelectedDiv )
{
alert("Must Select Two images");
selectedCount = 1;
} // end: if
else //
{
secondSelectedDiv.style.opacity = '0.5';
secondSelectedDiv.style.filter ="alpha(opacity='50')";
toggleTiles(null);
} // end: else
break;
case 2:
var swapTileContents = firstSelectedDiv.innerHTML;
firstSelectedDiv.innerHTML = secondSelectedDiv.innerHTML;
secondSelectedDiv.innerHTML = swapTileContents;
alert('swapped');
firstSelectedDiv.style.opacity = '1.0';
firstSelectedDiv.style.filter ="alpha(opacity='100')";
secondSelectedDiv.style.opacity = '1.0';
secondSelectedDiv.style.filter ="alpha(opacity='100')";
selectedCount = 0;
break;
}
}
</script>
</head>
<body>
<div id="pictrueContainer">
<div class="pictureOdd" id="tile0x0" onclick="toggleTiles(this.id);" > <img src="picUpload/pic1.jpg" alt="1" /> <a href="#" class="link_style">Listing_11.jpg</a> </div>
<div class="pictureEven" id="tile0x1" onclick="toggleTiles(this.id);" ><img src="picUpload/pic2.jpg" alt="2" /> <a href="#" class="link_style">Listing_21.jpg</a> </div>
<div class="pictureOdd" id="tile0x2" onclick="toggleTiles(this.id);" ><img src="picUpload/pic3.jpg" alt="3" /> <a href="#" class="link_style">Listing_22.jpg</a></div>
<div class="pictureEven" id="tile0x3" onclick="toggleTiles(this.id);" ><img src="picUpload/pic4.jpg" alt="4" /> <a href="#" class="link_style">Listing_23.jpg</a></div>
<div class="pictureOdd" id="tile0x4" onclick="toggleTiles(this.id);"><img src="picUpload/pic5.jpg" alt="5" /> <a href="#" class="link_style">Listing_24.jpg</a></div>
<div class="pictureEven" id="tile0x5" onclick="toggleTiles(this.id);"><img src="picUpload/pic6.jpg" alt="6"/> <a href="#" class="link_style">Listing_25.jpg</a></div>
<div class="pictureOdd" id="tile0x6" onclick="toggleTiles(this.id);"><img src="picUpload/pic7.jpg" alt="7" /><a href="#" class="link_style">Listing_26.jpg</a></div>
<div class="pictureEven" id="tile0x7" onclick="toggleTiles(this.id);"><img src="picUpload/pic8.jpg" alt="8" /> <a href="#" class="link_style">Listing_27.jpg</a></div>
<div class="pictureOdd" id="tile0x8" onclick="toggleTiles(this.id);"><img src="picUpload/pic9.jpg" alt="9" /> <a href="#" class="link_style">Listing_28.jpg</a></div>
<div class="pictureEven" id="tile0x9" onclick="toggleTiles(this.id);"><img src="picUpload/pic10.jpg" alt="10" /> <a href="#" class="link_style">Listing_29.jpg</a></div>
</div>
<div id="outsidePictrueContainer">
<img src="picUpload/pic11.jpg" />
</div>
</body>
</html>