setTimeout 함수에 대해 알고 싶습니다.. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

setTimeout 함수에 대해 알고 싶습니다.. 정보

setTimeout 함수에 대해 알고 싶습니다..

본문

궁금한게 있습니다..
 
현재 제 홈페이지에 setTimeout 함수가 한 페이지마다
두개씩 호출되서 두가지가 계속 setTimeout호출하는데요..
시간도 1초2초 비슷합니다.. 둘이상쓰니깐.. 화면상으로 볼때
둘중에 하나는 잠깐 쉬다가 다른거 한번끝나면 다른 setTimeout 동작되는거 같고
좀 느린감이 잇어서 질문드립니다.
 
여기 그누보드 리스트 스크롤 같은게 두개 이상 돌아간다고 생각하시면 되는데요..
 
시스템이 버벅거리는게 당연한건지요? 개념도 잘모르지만.. 용기내서 질문올립니다..
setTimeout 이 3개 이상 쓰면 더 시스템이 버벅거리겠죠?

댓글 전체

<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$thumb_exif=explode(";",$board[bo_1]);

//이미지 한줄스크롤되는 최신글
?>
<script>
function scroll() {
this.name = "scroll";
this.item = new Array();
this.itemcount = 0;
this.currentspeed = 0;
this.scrollspeed = 10;
this.pausedelay = 1000;
this.pausemouseover = false;
this.stop = false;
this.type = 1;
this.height = 160;
this.width = 213;
this.stopHeight=0;
this.add =function () {
var text = arguments[0];
this.item[this.itemcount] = text;
this.itemcount = this.itemcount + 1;
};
this.start = function () {
this.display();
this.currentspeed = this.scrollspeed;
setTimeout(this.name+'.scroll()',this.currentspeed);
};
this.display =function () {
document.write('<div id="'+this.name+'" style="height:'+this.height+';width:'+this.width+';position:relative;overflow:hidden;" OnMouseOver="'+this.name+'.onmouseover();" OnMouseOut="'+this.name+'.onmouseout();">');
for(var i = 0; i < this.itemcount; i++) {if ( this.type == 1) {
document.write('<div id="'+this.name+'item'+i+'"style="left:0px;width:'+this.width+';position:absolute;top:'+(this.height*i+1)+'px;">');
document.write(this.item[i]);
document.write('</div>');
}
else if ( this.type == 2 ) {
document.write('<div id="'+this.name+'item'+i+'"style="left:'+(this.width*i+1)+'px;width:'+this.width+';position:absolute;top:0px;">');
document.write(this.item[i]);
document.write('</div>');
}
}
document.write('</div>');
};
this.scroll = function () {
this.currentspeed = this.scrollspeed;if ( !this.stop ) {
for (i = 0; i < this.itemcount; i++) {
obj = document.getElementById(this.name+'item'+i).style;if ( this.type == 1 ) {
obj.top = parseInt(obj.top) - 1;
if ( parseInt(obj.top) <= this.height*(-1) ) obj.top = this.height * (this.itemcount-1);
if ( parseInt(obj.top) == 0 || ( this.stopHeight > 0 && this.stopHeight - parseInt(obj.top) == 0 ) ) this.currentspeed = this.pausedelay;
}
else if ( this.type == 2 ) {
obj.left = parseInt(obj.left) - 1;
if ( parseInt(obj.left) <= this.left*(-1) ) obj.left = this.left* (this.itemcount-1);
if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
}
}
}
window.setTimeout(this.name+".scroll()",this.currentspeed);
};
this.onmouseover = function () {
if ( this.pausemouseover ) {
this.stop = true;}
};
this.onmouseout = function () {
if ( this.pausemouseover ) {
this.stop = false;
}
};
}
</script>
<center>
<table width="213" height="160" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align='left'>

<script>
cont = new scroll();
cont.name = "cont";
cont.height = 160;
cont.width = 213;
cont.scrollspeed = 20;
cont.pausedelay = 3000;
cont.pausemouseover = true;
<? for ($i=0; $i<count($list); $i++) { ?>
<?
    if ($list[$i][wr_4] == "0") $_cutline="전체관람가";
    else $_cutline=$list[$i][wr_4]."세이상";


    $thumb_file = $g4[path]."/data/file/".$bo_table."/thumb"."/".urlencode($list[$i][file][0][file]);
    if (file_exists($thumb_file)) $image = "<img src='$thumb_file' width='100' border=0 style='border:1px solid #DFDFDF'>";
    else $image = "<img src='$board_skin_path/img/noimage.gif' border=0 width='$thumb_exif[0]' title='No IMG'>";

?>
      cont.add("<table width=100% cellpadding=0 cellspacing=0 border=0><tr><td><a href='<?=$list[$i][href]?>' onfocus=blur()><?=$image?></a></td><td width=5px></td><td valign=top><a href='<?=$list[$i][href]?>' onfocus=blur()><font style='font-family:굴림; font-size:8.5pt; color:#719EDB;'><b><?=$list[$i][subject]?></b></font><font style='font-family:굴림; font-size:8.5pt; color:#535353;'><br><br>영화관 : <?=$list[$i][ca_name]?>시네마<br> 개봉관 : <?=$list[$i][wr_6]?>관<br> 등급 : <?=$_cutline?><br> 쟝르 : <?=$list[$i][wr_3]?><br></a><br></font><a href=javascript:popup('http://aff.ticketlink.co.kr/ticketlink/aff_home.jsp?def_user_cd=543&aff_kind=cinema','800','560','auto','auto','0','0','0') onfocus=blur()><img src='<?=$g4[path]?>/skin/latest/movie_scroll/img/icon_movie.gif' align=absmiddle></a></td></td></tr></table>");
<?}?>
cont.start(); </script>
</td>
</tr>
</table>
</center>


예를들어.. 이런 latest 스킨이 두개이상 존재해서요..
대충.... ^^;;; 이런 이미지 스크롤 소스나 최신 게시물 소스가 한 페이지에
두개 이상 들어가네요... 이때.. setTimeout 이..

어떠케 관리해야 효율적인지 모르겟네요.. ㅠㅠ
이제 총 세개가.. 한페이지당 대충 들어가니..
그 스크롤 되는 부분이 느리더라구요... 서로가~
다른 방법이나.. 아니면 그런걸 최소화하려면 스크롤 하나만 나비두고 두개는 빼야 될까요?
화면에 일부분은 한 픽셀씩 위로 올리는 효과를 내는 것이 스크롤입니다. 이런 것이 많으면 느려질 수밖에 없습니다.
setTimeout 함수 자체와는 상관없이 느리죠.

느려진다면 아래 값들을 크게 해 주면 도움이 됩니다.
cont.scrollspeed = 20;
cont.pausedelay = 3000;

전 이거 해 줄 때 한 라인씩 위로 올라가게 한 것도 있습니다.
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT