쓸만한 주저리

파노라마 사진 스크립트

봄돌73 2010. 5. 12. 16:18

예시 :   http://ipoll.micans.co.kr/test_panorama.html


2010년 5월 13일 <body onload=init()> 추가


<body onload=init()>

<div id=divarea style=width:800px;height:600px;overflow:hidden;position:relative>

  <div id=div1 style=position:absolute;top:0px;left:0px><img id=img1 src=a6.jpg></div>

  <div id=div2 style=position:absolute;top:0px;left:800px><img src=a6.jpg></div>

</div>


<script>

  var divarea,div1,div2,img1,tmp


  divarea=document.getElementById('divarea')

  div1=document.getElementById('div1')

  div2=document.getElementById('div2')

  img1=document.getElementById('img1')


  function init(){

    divarea.style.height=img1.offsetHeight

    autoscroll(30,1)

  }


  function autoscroll(nexttime,scrollamount){

    div1.style.left=parseInt(div1.style.left)-scrollamount

    if(parseInt(div1.style.left)<((-1*img1.offsetWidth)+divarea.offsetWidth)){

      div2.style.left=parseInt(div2.style.left)-scrollamount

      if(parseInt(div1.style.left)==(-1*img1.offsetWidth)){

        tmp=div1

        div1=div2

        div2=tmp

        div2.style.left=divarea.offsetWidth

      }

    }

    setTimeout('autoscroll('+nexttime+','+scrollamount+')',nexttime)

  }

</script>