[JS] 스크롤메뉴
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| var min = 350; // 레이어 top 초기 값 (레이어 top 값과 일치시킴)
var max = 0;
var moving_speed = 10 // 속도(낮을 수록 빠름)
var moving_amount = 10 // 움직임 (낮을 수록 부드러움)
var action_time = 500 // 반응시간 (*/1000 초 후에 반응)
function left_move_init() {
itm = document.getElementById("topButton");
//itm.set_pos = function(y){itm.style.top=y;}; 파폭에서 안됨
itm.set_pos = function(y){itm.style.top=y+"px";};
itm.y = min;
itm.set_pos(itm.y);
max = document.body.scrollHeight - itm.scrollHeight - min;
setTimeout("left_move_func()", moving_amount);
}
function left_move_func() {
tmp = document.body.scrollTop + min;
itm.y += Math.floor((tmp-itm.y)/moving_speed);
if( itm.y>max ) itm.y = max;
if( itm.y<min ) itm.y = min;
itm.set_pos(itm.y);
setTimeout("left_move_func()", moving_amount);
}
setTimeout("left_move_init()", action_time); |
This entry was posted
on Sunday, September 3rd, 2006 at 11:49 pm and is filed under JavaScript.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.