본문 바로가기
Web Program/Html Lecture

쇼핑몰에서 상품 리스트 상 하로 스크롤 하기

by 현이빈이 2008. 11. 3.
반응형

<html>
<head>
<title>상품스크롤하기</title>
<script language=javascript>
<!--
var downLayerId;
var dropDegree = 5; //스크롤 속도
var doDirect;
var DirectTerm = 4000; //스크롤 지연시간
var curDropIdx = 0;

function DirectDown()
{
clearInterval(doDirect);
clearInterval(downLayerId);

for(i = curDropIdx ;i < document.all["DropHit"].length + curDropIdx;i++){
  document.all["DropHit"][i%document.all["DropHit"].length].style.posTop = document.all["DropHit"][i%document.all["DropHit"].length].style.posHeight * (-1*((i-curDropIdx)%document.all["DropHit"].length));
}
var temp = 'setInterval("DownLayer()",20)';
downLayerId = eval(temp);
direction = "down";
}
function DownLayer()
{
if(document.all["DropHit"][curDropIdx].style.posTop < document.all["DropHit"][curDropIdx].style.posHeight){
  for(j = curDropIdx ;j < document.all["DropHit"].length + curDropIdx;j++){
   document.all["DropHit"][j%document.all["DropHit"].length].style.posTop += dropDegree;
  }
}else{
  clearInterval(downLayerId);
  for(j = curDropIdx ;j < document.all["DropHit"].length + curDropIdx;j++){
   document.all["DropHit"][j%document.all["DropHit"].length].style.posTop = document.all["DropHit"][j%document.all["DropHit"].length].style.posHeight *((-1*((j-curDropIdx)%document.all["DropHit"].length))+1);
  }
  curDropIdx = (curDropIdx + 1) ;
  curDropIdx = curDropIdx > document.all["DropHit"].length-1 ? curDropIdx%document.all["DropHit"].length:curDropIdx;
  var temp = 'setInterval("DirectDown()",DirectTerm)';
  doDirect = eval(temp);
}
}
function DirectUp()
{
clearInterval(doDirect);
clearInterval(downLayerId);
var tempIdx = 0;
for(i = 0;i<document.all["DropHit"].length;i++){
  tempIdx = (document.all["DropHit"].length + curDropIdx - i) %document.all["DropHit"].length;
  document.all["DropHit"][tempIdx].style.posTop = i*document.all["DropHit"][tempIdx].style.posHeight;
}
var temp = 'setInterval("UpLayer()",20)';
downLayerId = eval(temp);
direction = "up";
}
function UpLayer()
{
var tempIdx = 0;
if(document.all["DropHit"][curDropIdx].style.posTop < document.all["DropHit"][curDropIdx].style.posHeight && document.all["DropHit"][curDropIdx].style.posTop > document.all["DropHit"][curDropIdx].style.posHeight * (-1)){
  for(j = 0 ;j < document.all["DropHit"].length;j++){
   tempIdx = (document.all["DropHit"].length + curDropIdx - j) %document.all["DropHit"].length;
   document.all["DropHit"][tempIdx].style.posTop -= dropDegree;
  }
}else{
  clearInterval(downLayerId);
  for(j = 0;j<document.all["DropHit"].length;j++){
   tempIdx = (document.all["DropHit"].length + curDropIdx - j) % document.all["DropHit"].length;
   document.all["DropHit"][tempIdx].style.posTop = (j-1)*(document.all["DropHit"][tempIdx].style.posHeight);
  }
  curDropIdx = (curDropIdx - 1) ;
  curDropIdx = curDropIdx < 0 ? document.all["DropHit"].length-1:curDropIdx;
  var temp = 'setInterval("DirectUp()",DirectTerm)';
  doDirect = eval(temp);
}
}
//-->
</script>
</head>
<body onLoad="DirectDown();">
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td>
  <div style="left:0px; overflow:hidden; width:635px; position:relative; top:0px; height:130px">
   <div id=DropHit style="left:0px; visibility:visible; width:635px; position:absolute; top:0px; height:130px">
    <table border=0 cellpadding=0 cellspacing=0 width=635>
    <tr>
     <td><img border=0 src=img/1.gif></td>
     <td><img border=0 src=img/2.gif></td>
     <td><img border=0 src=img/3.gif></td>
  <td><img border=0 src=img/4.gif></td>
  <td><img border=0 src=img/5.gif></td>
    </tr>
    </table>
   </div>
   <div id=DropHit style="left:0px; visibility:visible; width:635px; position:absolute; top:-200px; height:130px">
    <table border=0 cellpadding=0 cellspacing=0 width=635>
    <tr>
     <td><img border=0 src=img/6.gif></td>
  <td><img border=0 src=img/7.gif></td>
  <td><img border=0 src=img/8.gif></td>
  <td><img border=0 src=img/9.gif></td>
  <td><img border=0 src=img/10.gif></td>
    </tr>
    </table>
   </div>
  </div>
</td>
<td>
  <table cellspacing=0 cellpadding=0 width=13 border=0>
  <tr><td><a href="javascript:DirectUp()"><img border=0 src=img/up.gif></a></td></tr>
    <tr><td align=center><img height=100 width=1 src=binimg.gif></td></tr>
  <tr><td><a href="javascript:DirectDown()"><img border=0 src=img/down.gif></a></td></tr>
  </table>
</td>
</tr>
</table>

</body>
</html>


출처 :http://www.happycgi.com

반응형