My Custom Rack I Built
Reply to topic
 
Trouble with JS gallery w/in a JS sliding Div



Joined:01 Jul 2007
Posts:2
Location:Seattle, WA
Reply with quote
Hiya,

I'm working on a small portfolio of my design work, and I'm using a horizontal sliding function. Within one section of that horizontal sliding function, I want to include a javascript gallery.

I've tested each one independenly, and I've tested them together and nothing seems to work. Any advice for a no0b? I've been putting together a lot of existing code to make what I want...so bear with me.

Code as follows:

Code:

var timerlen = 5;
var slideAniLen = 500;
var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();
function slidedown(objname){
  if(moving[objname])
    return;
 
  if(document.getElementById(objname).style.display != "none")
    return; // cannot slide down something that is already visible
 
  moving[objname] = true;
  dir[objname] = "down";
  startslide(objname);
}
 
function slideup(objname){
  if(moving[objname])
    return;
 
  if(document.getElementById(objname).style.display == "none")
    return; // cannot slide up something that is already hidden
 
  moving[objname] = true;
  dir[objname] = "up";
  startslide(objname);
}

function startslide(objname){
  obj[objname] = document.getElementById(objname);
 
  endHeight[objname] = parseInt(obj[objname].style.height);
  startTime[objname] = (new Date()).getTime();
 
  if(dir[objname] == "down"){
    obj[objname].style.height = "1px";
  }
 
  obj[objname].style.display = "block";
 
  timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}
function slidetick(objname){
  var elapsed = (new Date()).getTime() - startTime[objname];
 
  if (elapsed > slideAniLen)
    endSlide(objname)
  else {
    var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
    if(dir[objname] == "up")
      d = endHeight[objname] - d;
 
    obj[objname].style.height = d + "px";
  }
 
  return;
}

function endSlide(objname){
  clearInterval(timerID[objname]);
 
  if(dir[objname] == "up")
    obj[objname].style.display = "none";
 
  obj[objname].style.height = endHeight[objname] + "px";
 
  delete(moving[objname]);
  delete(timerID[objname]);
  delete(startTime[objname]);
  delete(endHeight[objname]);
  delete(obj[objname]);
  delete(dir[objname]);
 
  return;
}
function toggleSlide(objname){
  if(document.getElementById(objname).style.display == "none"){
    // div is hidden, so let's slide down
    slidedown(objname);
  }else{
    // div is not hidden, so slide up
    slideup(objname);
  }
}

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);

ns3up = (browserName == "Netscape" && browserVer >= 3);
ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

function doPic(imgName) {
if (ns3up || ie4up) {
imgOn = ("" + imgName);
document.mainpic.src = imgOn;
   }
}
</script>
</head>

<body>
<div id="masthead">
  <h1 id="siteName">I Heart Design </h1>
  <div id="globalNav"> <a href="javascript:;" onmousedown="toggleSlide('portfolio');">work</a> | <a href="javascript:;" onmousedown="toggleSlide('education');">education</a> | <a href="javascript:;" onmousedown="toggleSlide('services');">services </a> | <a href="javascript:;" onmousedown="toggleSlide('aboutme');">about me</a> </div>
  <h3 id="pageName">Maureen Jann's Portfolio </h3>
  <div id="breadCrumb"> Acquiring simplicity since 1996... </div>
</div>

<div id="portfolio" style="display:none; overflow:hidden; height:500px;">
<h3>Portfolio</h3>
Web Design | Print Design | Branding
<p>
<a name="webdesign" id="webdesign">Web Design</a>
<center>
<table width=360 border=0 cellspacing=0 cellpadding=0>
<tr>
<td><a href="javascript:doPic('p1.jpg');"><img src="p1.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p2.jpg');"><img src="p2.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p3.jpg');"><img src="p3.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p4.jpg');"><img src="p4.jpg" width=90 height=60 border=0></a></td>
</tr>
<tr>
<td colspan=4 align=center><img name="mainpic" src="p1.jpg" width=360 height=240 border=0></td>
</tr>
<tr>
<td><a href="javascript:doPic('p5.jpg');"><img src="p5.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p6.jpg');"><img src="p6.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p7.jpg');"><img src="p7.jpg" width=90 height=60 border=0></a></td>
<td><a href="javascript:doPic('p8.jpg');"><img src="p8.jpg" width=90 height=60 border=0></a></td>
</tr>
</table>
</center>
<a name="printdesign" id="printdesign">Print Design</a>


<a href="javascript:;" onmousedown="toggleSlide('portfolio');"> Put this section away</a></p>
</div>
<div id="mydiv2" style="display:none; overflow:hidden; height:95px;">
Text
<a href="javascript:;" onmousedown="toggleSlide('mydiv2');"> Put this section away</a>
[/code]
View user's profileFind all posts by iheartiheartSend private messageAIM AddressYahoo MessengerMSN Messenger
Trouble with JS gallery w/in a JS sliding Div

Senior Journeyman (L6)

Senior Journeyman (L6)

Joined:07 Feb 2004
Posts:574
Location:Portsmouth GB
Reply with quote
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
  <title></title>
<script language="JavaScript" type="text/javascript">
<!--
// Change Left, Top, Width, Height, Color, Opacity (06-March-2007) DRAFT
// by Vic Phillips http://www.vicsjavascripts.org.uk

// To progressively change the Left, Top, Width, Height, Color, Opacity style
// (or other 'px' style properties) of an element over a specified period of time.

// **** Application Notes

// **** The HTML Code
//
// when moving an element the inline or class rule style position of the element should be assigned as
// 'position:relative;' or 'position:absolute;'
// If not assigned the style position of the element will be assigned as 'position:absolute;' by the script.
//
// The element would normally be assigned a unique ID name.
//

// **** Executing the Effect(Script)
//
// The effect is executed by an event call to function 'zxcChangeLTWHCO('left','tst1',20,260,'sin',2000);'
// where:
// parameter 0 = 'left', 'top', 'width', 'height', 'color', 'background-Color', 'opacity' etc.             (string)
//               Note: the first character after the hyphen must be be upper case, all others lower case.
//                     With the exception of opacity and color the property value units is in 'px'.
// parameter 1 = the unique ID name or element object.                                                     (string or element object)
// parameter 1 = the start position of the effect.                                                         (digits, for opacity minimum 0, maximum 100)
// parameter 2 = the finish position of the effect.                                                        (digits, for opacity minimum 0, maximum 100)
// parameter 3 = (optional) there are two types of progressive change 'sin' and 'cos' plus a liner change. ('sin', 'cos' or liner, defaults to liner)
//                'sin' progression starts fast and ends slow.
//                'cos' progression starts slow and ends fast.
// parameter 4 = (optional) period of time between the start and finish of the effect in milliseconds.     (digits or defaults to 2000 milliSeconds)
//
//  The function may be re-executed with a different set of parameters (start/finish time, progression type or period)
//  whenever required, say from an onclick/mouseover/out event. The original progression type and period parameters
//  will be retained unless re-specified, the start and finish parameters must be specified.
//

// **** General
//
// All variable, function etc. names are prefixed with 'zxc' to minimise conflicts with other JavaScripts.
// These characters may be changed to characters of choice using global find and replace.
//
// The Functional Code (about 3.7K) is best as an External JavaScript.
//
// Tested with IE7 and Mozilla FireFox on a PC.
//



// **** Functional Code - NO NEED to Change

var zxcOOPCnt=0;

function zxcChangeLTWHCO(zxcmde,zxcobj,zxcsrt,zxcfin,zxccurve,zxctime,zxcplot){
 if (typeof(zxcobj)=='string'){ zxcobj=document.getElementById(zxcobj); }
 if (!zxcobj||(!zxcsrt&&!zxcfin)) return;
 var zxcoop=zxcobj[zxcmde.replace('-','')+'oop'];
 if (zxcoop) zxcoop.cngparameters(zxcmde,[zxcsrt,zxcfin],zxccurve,zxctime,zxcplot);
 else zxcobj[zxcmde.replace('-','')+'oop']=new zxcLTWHCOOOP(zxcmde,zxcobj,[zxcsrt,zxcfin],zxccurve,zxctime,zxcplot);
}

function zxcLTWHCOOOP(zxcmde,zxcobj,zxcsrtfin,zxccurve,zxctime,zxcplot){
 if (zxcsrtfin[0]==zxcsrtfin[1]) return;
 if (zxcStyleValue(zxcobj,'position')=='static'&&(zxcmde=='left'||zxcmde=='top')) zxcobj.style.position='absolute';
 this.to=null;
 this.ref='zxcltwhco'+zxcOOPCnt++;
 window[this.ref]=this;
 this.obj=zxcobj;
 this.cngparameters(zxcmde,zxcsrtfin,zxccurve,zxctime,zxcplot);
}

zxcLTWHCOOOP.prototype.cngparameters=function(zxcmde,zxcsrtfin,zxccurve,zxctime,zxcplot){
 clearTimeout(this.to);
 this.mde=this.mde||zxcmde;
 zxccurve=zxccurve||this.curve||'';
 this.time=zxctime||this.time||2000;
 if (zxcsrtfin[0]==zxcsrtfin[1]) return;
 for (var zxc0=0;zxc0<zxcsrtfin.length;zxc0++){
  var zxcobj=document.getElementById(zxcsrtfin[zxc0]);
  if (zxcobj){ zxcsrtfin[zxc0]=zxcStyleValue(zxcobj,zxcmde); if (!this.mde.match('olor')) zxcsrtfin[zxc0]=parseInt(zxcsrtfin[zxc0]); }
  if (zxcsrtfin[zxc0]==0) zxcsrtfin[zxc0]=0.00001;
 }
 if (this.mde=='opacity'&&(zxcsrtfin[0]<0||zxcsrtfin[0]>100||zxcsrtfin[0]<0||zxcsrtfin[0]>100)) return;
 this.curve=zxccurve.charAt(0).toLowerCase();
 this.sf=[(!zxcmde.match('olor'))?[zxcsrtfin[0]]:zxcRGBSplit(zxcsrtfin[0]),(!zxcmde.match('olor'))?[zxcsrtfin[1]]:zxcRGBSplit(zxcsrtfin[1]),[]];
 this.srttime=new Date().getTime();
 this.inc=Math.PI/(2*this.time);
 this.cngltwhco();
}

zxcLTWHCOOOP.prototype.cngltwhco=function(){
 var zxcms=new Date().getTime()-this.srttime;
 for (var zxc0 in this.sf[1]){ this.sf[2][zxc0]=(this.curve=='s')?Math.floor((this.sf[1][zxc0]-this.sf[0][zxc0])*Math.sin(this.inc*zxcms)+this.sf[0][zxc0]):(this.curve=='c')?(this.sf[1][0])-Math.floor((this.sf[1][zxc0]-this.sf[0][zxc0])*Math.cos(this.inc*zxcms)):(this.sf[1][zxc0]-this.sf[0][zxc0])/this.time*zxcms+this.sf[0][zxc0]; }
 this.cngstyle(this.sf[2]);
 if (zxcms<this.time) this.setTimeOut('cngltwhco();',10);
 else this.cngstyle(this.sf[1]);
}

zxcLTWHCOOOP.prototype.cngstyle=function(zxcltwhco){
 if (this.mde.match('olor')) this.obj.style[this.mde.replace('-','')]='rgb('+zxcltwhco[0]+','+zxcltwhco[1]+','+zxcltwhco[2]+')';
 else if (this.mde!='opacity') this.obj.style[this.mde.replace('-','')]=Math.max(zxcltwhco[0],0)+'px';
 else this.opacity(zxcltwhco[0]);
}

zxcLTWHCOOOP.prototype.opacity=function(zxcopc){
 if (zxcopc<0||zxcopc>100) return;
 if (this.obj.style.MozOpacity!=null) this.obj.style.MozOpacity=(zxcopc/100)-.001;
 else if (this.obj.style.opacity!=null) this.obj.style.opacity=(zxcopc/100)-.001;
 else if (this.obj.style.filter!=null) this.obj.style.filter='alpha(opacity='+zxcopc+')';
 else if (this.obj.KHTMLOpacity!=null) this.obj.KHTMLOpacity=(zxcopc/100)-.001;
}

zxcLTWHCOOOP.prototype.setTimeOut=function(zxcf,zxcd){
 this.to=setTimeout('window.'+this.ref+'.'+zxcf,zxcd);
}

function zxcStyleValue(zxcel,zxcp){
 if (zxcel.currentStyle) return zxcel.currentStyle[zxcp.replace('-','')];
 return document.defaultView.getComputedStyle(zxcel,null).getPropertyValue(zxcp.toLowerCase());
}

function zxcRGBSplit(zxccol){
 if (zxccol.match('#')){ zxccol=parseInt(zxccol.substring(1,3),16)+','+parseInt(zxccol.substring(3,5),16)+','+parseInt(zxccol.substring(5,7),16); }
 zxccol=zxccol.replace(/[rgb()\s]/g,'').split(',');
 return [parseInt(zxccol[0]),parseInt(zxccol[1]),parseInt(zxccol[2])];
}


//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
//function zxcChangeLTWHCO(zxcmde,zxcobj,zxcsrt,zxcfin,zxccurve,zxctime,zxcplot){
var zxcLst;

function toggleSlide(zxcid,zxch){
 var zxcobj=document.getElementById(zxcid)
 if ((zxcLst&&zxcobj!=zxcLst)||(zxcLst&&!zxcid)){
  zxcLst.style.zIndex='0';
  zxcChangeLTWHCO('height',zxcLst,parseInt(zxcLst.style.height),0,'sin',2000);
 }
 if (zxcobj&&zxcobj!=zxcLst){
  zxcLst=zxcobj;
  zxcLst.style.zIndex='1';
  zxcChangeLTWHCO('height',zxcLst,0,zxch,'sin',2000);
 }
}

function Swap(zxcobj,zxcid){
 document.getElementById(zxcid).src=zxcobj.src;
}

//-->
</script>

</head>

<body>
<div id="masthead">
  <h1 id="siteName">I Heart Design </h1>
  <div id="globalNav"> <a href="javascript:;" onmousedown="toggleSlide('portfolio',500);">work</a> | <a href="javascript:;" onmousedown="toggleSlide('education',500);">education</a> | <a href="javascript:;" onmousedown="toggleSlide('services',500);">services </a> | <a href="javascript:;" onmousedown="toggleSlide('aboutme',500);">about me</a> </div>
  <h3 id="pageName">Maureen Jann's Portfolio </h3>
  <div id="breadCrumb"> Acquiring simplicity since 1996... </div>
</div>

<div style="position:relative;width:500px;height:500px;border:solid black 1px;" >
 <div id="portfolio" style="position:absolute;left:0px;top:0px;overflow:hidden; height:0px;background-Color:white;">
  <h3>Portfolio</h3>
  Web Design | Print Design | Branding
  <p>
  <a name="webdesign" id="webdesign">Web Design</a>
 <center>
 <table width=360 border=0 cellspacing=0 cellpadding=0>
 <tr>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Three.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Four.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 </tr>
 <tr>
 <td colspan=4 align=center><img name="mainpic" src="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif" width=360 height=240 border=0></td>
 </tr>
 <tr>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Five.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Six.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Seven.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 <td><img src="http://www.vicsjavascripts.org.uk/StdImages/Eight.gif" width=90 height=60 border=0 onclick="Swap(this,'mainpic');" ></td>
 </tr>
 </table>
 </center>
 <a name="printdesign" id="printdesign">Print Design</a>
 <a href="javascript:;" onmousedown="toggleSlide();"> Put this section away</a></p>
 </div>

 <div id="education" style="position:absolute;left:0px;top:0px;overflow:hidden;width:360px;height:50px;background-Color:red;">
 education
 </div>

</div>



</body>

</html>

_________________
Vic

http://www.vicsjavascripts.org.uk

God loves you and will never love you less.
View user's profileFind all posts by vwphillipsSend private messageVisit poster's website
Trouble with JS gallery w/in a JS sliding Div



Joined:01 Jul 2007
Posts:2
Location:Seattle, WA
Reply with quote
Thanks Vic, I can't wait to try that when I get home.
View user's profileFind all posts by iheartiheartSend private messageAIM AddressYahoo MessengerMSN Messenger
Trouble with JS gallery w/in a JS sliding Div
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
All times are GMT - 6 Hours  
Page 1 of 1  


  
  
 Reply to topic