[함수] js_rolling , JS로 만든 롤링 클래스
펌입니다..
===================================================
전에 만든게 있는데, 그냥 다시 만듬
이번은 left도 됩니다.
소스가 더 간결해졌습니다.(?)
이 소스가 업데이트 된다면 제 홈페이지에만 다시 올립니다.
물론 링크따라 들어가면 어여쁜 공대여자 그림과 함께 예제를 보실 수 있습니다.
#P.S
방향을 right와 down도 계획했지만...
도저히 하는 방법을 모르겠습니다.
누구 아시면 알려주세요.
//===============================================
/*========================================
js_rolling.js
#간단설명
<div><img /><img /></div>
라고 했을 경우 div안의 img를 위, 또는 왼쪽으로 롤링 시킨다.
# 사용법
<script type="text/javascript" charset='utf-8' src="js_rolling.js"></script>
//JS스크립트 로드
<div id='div1'><img /><img /><img /><img /><img /></div>
//처럼 구성후 div의 너비와 높이는 꼭 정해주기 바랍니다.
var roll = new js_rolling('rolling');
or
var roll = new js_rolling(document.getElementById('rolling'));
// id이름을 적던지, 직접 대상을 지목해서 롤링 클래스로 객체를 만듬
roll.move_gap = 1; //움직이는 픽셀단위
roll.time_dealy = 10; //움직이는 타임딜레이
roll.time_dealy_pause = 5000;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
roll.set_direction(4); // 반향을 바꿈. 1: top, 4:left 그외의 경우 동작안함
roll.start(); //롤링 동작
#주의
div를 img대신 넣을 경우 left로 동작이 이상하게 됨
div를 롤링할 경우 direction은 top(1)만 사용하길 바람
꼭 left로 할 경우 span를 대신 사용바람
#사용제약
사용시 "공대여자는 예쁘다"를 나타내셔야합니다.
만든날 : 2007-06-07
만든이 : mins01,mins,공대여자
홈페이지 : http://mins01.zerock.net
NateOn&MSN : mins01(at)lycos.co.kr
========================================*/
var js_rolling = function(this_s){
// 시간단위는 ms로 1000이 1초
if(this_s.nodeType==1){
this.this_s = this_s;
}else{
this.this_s = document.getElementById(this_s);
}
this.is_rolling = false;
this.direction = 1; //1:top, 2:right, 3:bottom, 4:left (시계방향) // 1번과 4번만 됨
this.children = null;
this.move_gap = 1; //움직이는 픽셀단위
this.time_dealy = 100; //움직이는 타임딜레이
this.time_dealy_pause = 1000;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
this.time_timer=null;
this.time_timer_pause=null;
this.set_direction(this.direction);
this.init_event();
}
js_rolling.prototype.set_direction = function(direction){
this.direction=direction;
this.get_element_children();
}
js_rolling.prototype.init_event = function(){
var this_s=this;
this.this_s.onmouseover=function(){
if(!this_s.time_timer_pause){
this_s.pause();
}
}
this.this_s.onmouseout=function(){
if(!this_s.time_timer_pause){
this_s.resume();
}
}
}
js_rolling.prototype.get_element_children = function(){
this.this_s.style.position='relative';
this.this_s.style.overflow='hidden';
var children = this.this_s.childNodes;
this.children = children;
for(var i=(children.length-1);0<=i;i--){
if(children[i].nodeType==1){
children[i].style.position='relative';
if(this.direction==1){
children[i].style.top='0px';
}else if(this.direction==4){
children[i].style.left='0px';
this.this_s.style.whiteSpace='nowrap';
}
}else{
this.this_s.removeChild(children[i]);
}
}
}
js_rolling.prototype.act_move_up = function(){
for(var i = 0,m=this.children.length;i<m;i++){
var child = this.children[i];
child.style.top=(parseInt(child.style.top)-this.move_gap)+'px';
}
if((this.children[0].offsetHeight+parseInt(this.children[0].style.top))<=0){
this.this_s.appendChild(this.children[0]);
this.get_element_children();
if(this.time_dealy_pause){
var this_s = this;
var act = function(){this_s.resume();this_s.time_timer_pause=null;}
this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
this.pause();
}
}
}
js_rolling.prototype.act_move_left = function(){
for(var i = 0,m=this.children.length;i<m;i++){
var child = this.children[i];
child.style.left=(parseInt(child.style.left)-this.move_gap)+'px';
}
if((this.children[0].offsetWidth+parseInt(this.children[0].style.left))<=0){
this.this_s.appendChild(this.this_s.firstChild);
this.get_element_children();
if(this.time_dealy_pause){
var this_s = this;
var act = function(){this_s.resume();this_s.time_timer_pause=null;}
this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
this.pause();
}
}
}
js_rolling.prototype.start = function(){ //롤링 시작
var this_s = this;
this.stop();
this.is_rolling = true;
var act = function(){
if(this_s.is_rolling){
if(this_s.direction==1){this_s.act_move_up();}
else if(this_s.direction==4){this_s.act_move_left();}
}
}
this.time_timer = setInterval(act,this.time_dealy);
}
js_rolling.prototype.pause = function(){ //일시 멈춤
this.is_rolling = false;
}
js_rolling.prototype.resume = function(){ //일시 멈춤 해제
this.is_rolling = true;
}
js_rolling.prototype.stop = function(){ //롤링을 끝냄
this.is_rolling = false;
if(!this.time_timer){
clearInterval(this.time_timer);
}
this.time_timer = null
}
//============================================
이번은 left도 됩니다.
소스가 더 간결해졌습니다.(?)
이 소스가 업데이트 된다면 제 홈페이지에만 다시 올립니다.
물론 링크따라 들어가면 어여쁜 공대여자 그림과 함께 예제를 보실 수 있습니다.
#P.S
방향을 right와 down도 계획했지만...
도저히 하는 방법을 모르겠습니다.
누구 아시면 알려주세요.
//===============================================
/*========================================
js_rolling.js
#간단설명
<div><img /><img /></div>
라고 했을 경우 div안의 img를 위, 또는 왼쪽으로 롤링 시킨다.
# 사용법
<script type="text/javascript" charset='utf-8' src="js_rolling.js"></script>
//JS스크립트 로드
<div id='div1'><img /><img /><img /><img /><img /></div>
//처럼 구성후 div의 너비와 높이는 꼭 정해주기 바랍니다.
var roll = new js_rolling('rolling');
or
var roll = new js_rolling(document.getElementById('rolling'));
// id이름을 적던지, 직접 대상을 지목해서 롤링 클래스로 객체를 만듬
roll.move_gap = 1; //움직이는 픽셀단위
roll.time_dealy = 10; //움직이는 타임딜레이
roll.time_dealy_pause = 5000;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
roll.set_direction(4); // 반향을 바꿈. 1: top, 4:left 그외의 경우 동작안함
roll.start(); //롤링 동작
#주의
div를 img대신 넣을 경우 left로 동작이 이상하게 됨
div를 롤링할 경우 direction은 top(1)만 사용하길 바람
꼭 left로 할 경우 span를 대신 사용바람
#사용제약
사용시 "공대여자는 예쁘다"를 나타내셔야합니다.
만든날 : 2007-06-07
만든이 : mins01,mins,공대여자
홈페이지 : http://mins01.zerock.net
NateOn&MSN : mins01(at)lycos.co.kr
========================================*/
var js_rolling = function(this_s){
// 시간단위는 ms로 1000이 1초
if(this_s.nodeType==1){
this.this_s = this_s;
}else{
this.this_s = document.getElementById(this_s);
}
this.is_rolling = false;
this.direction = 1; //1:top, 2:right, 3:bottom, 4:left (시계방향) // 1번과 4번만 됨
this.children = null;
this.move_gap = 1; //움직이는 픽셀단위
this.time_dealy = 100; //움직이는 타임딜레이
this.time_dealy_pause = 1000;//하나의 대상이 새로 시작할 때 멈추는 시간, 0 이면 적용 안함
this.time_timer=null;
this.time_timer_pause=null;
this.set_direction(this.direction);
this.init_event();
}
js_rolling.prototype.set_direction = function(direction){
this.direction=direction;
this.get_element_children();
}
js_rolling.prototype.init_event = function(){
var this_s=this;
this.this_s.onmouseover=function(){
if(!this_s.time_timer_pause){
this_s.pause();
}
}
this.this_s.onmouseout=function(){
if(!this_s.time_timer_pause){
this_s.resume();
}
}
}
js_rolling.prototype.get_element_children = function(){
this.this_s.style.position='relative';
this.this_s.style.overflow='hidden';
var children = this.this_s.childNodes;
this.children = children;
for(var i=(children.length-1);0<=i;i--){
if(children[i].nodeType==1){
children[i].style.position='relative';
if(this.direction==1){
children[i].style.top='0px';
}else if(this.direction==4){
children[i].style.left='0px';
this.this_s.style.whiteSpace='nowrap';
}
}else{
this.this_s.removeChild(children[i]);
}
}
}
js_rolling.prototype.act_move_up = function(){
for(var i = 0,m=this.children.length;i<m;i++){
var child = this.children[i];
child.style.top=(parseInt(child.style.top)-this.move_gap)+'px';
}
if((this.children[0].offsetHeight+parseInt(this.children[0].style.top))<=0){
this.this_s.appendChild(this.children[0]);
this.get_element_children();
if(this.time_dealy_pause){
var this_s = this;
var act = function(){this_s.resume();this_s.time_timer_pause=null;}
this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
this.pause();
}
}
}
js_rolling.prototype.act_move_left = function(){
for(var i = 0,m=this.children.length;i<m;i++){
var child = this.children[i];
child.style.left=(parseInt(child.style.left)-this.move_gap)+'px';
}
if((this.children[0].offsetWidth+parseInt(this.children[0].style.left))<=0){
this.this_s.appendChild(this.this_s.firstChild);
this.get_element_children();
if(this.time_dealy_pause){
var this_s = this;
var act = function(){this_s.resume();this_s.time_timer_pause=null;}
this.time_timer_pause = setTimeout(act,this.time_dealy_pause);
this.pause();
}
}
}
js_rolling.prototype.start = function(){ //롤링 시작
var this_s = this;
this.stop();
this.is_rolling = true;
var act = function(){
if(this_s.is_rolling){
if(this_s.direction==1){this_s.act_move_up();}
else if(this_s.direction==4){this_s.act_move_left();}
}
}
this.time_timer = setInterval(act,this.time_dealy);
}
js_rolling.prototype.pause = function(){ //일시 멈춤
this.is_rolling = false;
}
js_rolling.prototype.resume = function(){ //일시 멈춤 해제
this.is_rolling = true;
}
js_rolling.prototype.stop = function(){ //롤링을 끝냄
this.is_rolling = false;
if(!this.time_timer){
clearInterval(this.time_timer);
}
this.time_timer = null
}
//============================================
[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]
게시글 목록
| 번호 | 제목 |
|---|---|
| 11470 |
PHP
64비트용 php5.1
|
| 11469 | |
| 11468 | |
| 11457 | |
| 29100 | |
| 11448 | |
| 11444 |
Flash
화이어폭스에서 플래시투명하게..
3
|
| 24851 | |
| 29091 |
HTML
포토샵팁 73가지
8
|
| 11440 | |
| 11434 |
JavaScript
[팁]웹상이나 포토샵에서 이미지 작업시 필요한 색상이 따로 있는걸 아세요?
5
|
| 11431 | |
| 11420 |
기타
아쿠아틱볼만들기~
10
|
| 11415 | |
| 11412 | |
| 29087 | |
| 11408 | |
| 11402 | |
| 11397 |
JavaScript
PHP에서 성능 개선을 위한 유용한 팁
4
|
| 11389 |
MySQL
PHP 초보적인 질문인데 너무 궁금해서요
7
|
| 11387 | |
| 11383 |
Flash
포토샵에 쓰이는 파일 정보
3
|
| 11375 | |
| 11370 | |
| 11362 |
기타
디카사진 보정효과
7
|
| 11354 |
JavaScript
강렬한 Sketch(스케치) 효과
7
|
| 11349 |
JavaScript
포토샵 단축키 모음
4
|
| 11348 |
JavaScript
셀렉트 박스 이뿌게 꾸미기
|
| 11347 |
JavaScript
데몬 Daemon 설명
|
| 11342 | |
| 11338 |
JavaScript
서버호스팅 트래픽 계산방법
3
|
| 29084 |
HTML
뒷배경을 채우기
2
|
| 11335 |
JavaScript
APM 설치전 필수 라이브러리 다운로드 및 설치
2
|
| 11327 | |
| 11325 |
JavaScript
Alpha 채널을 이용하여 Halftone Dot Image 만들기
1
|
| 11318 | |
| 11312 | |
| 11308 |
기타
사진에 글시 쓰기
3
|
| 11303 | |
| 11300 |
기타
이미지 합성하기
2
|
| 29077 |
HTML
부분 흑백 만들기
6
|
| 24849 | |
| 29075 |
HTML
스크롤바 색상 변경해주는 소스
1
|
| 29070 | |
| 11291 |
JavaScript
재미 있는 네비입니다.
8
|
| 11290 |
JavaScript
mod_rewrite 를 적용하기 위한 http.conf 설정
|
| 11288 | |
| 11285 |
JavaScript
잘 되던 포토샵이 갑자기 실행이 안될때
2
|
| 29068 |
HTML
단축기와 용어/팁
1
|
| 11282 | |
| 11279 | |
| 11271 |
Flash
flash source 입니다 (네비)
7
|
| 11267 |
Flash
드디어 cs3 이 출시 했다고 합니다.
3
|
| 11264 | |
| 11263 |
JavaScript
[스크립트] 이미지 없는 둥글게 테두리 DIV
|
| 29064 |
HTML
한글패치의 삭제 방법
3
|
| 11256 | |
| 11250 | |
| 11244 |
JavaScript
왜곡과 수평 바로잡기 (동영상)
5
|
| 11238 | |
| 11237 | |
| 11234 | |
| 29061 | |
| 11231 | |
| 11228 | |
| 11226 | |
| 29056 |
HTML
플래쉬 인트로자동으로 로딩되게
4
|
| 11223 | |
| 11216 |
MySQL
익스플로러7 팝업창의 주소창 없애기
6
|
| 11214 | |
| 24846 | |
| 11210 |
JavaScript
포토샵8.0cs 분할영역 도구로 일부 영역만 저장은 불가능 한가요?
3
|
| 11206 |
JavaScript
유용한 포샵단축키
3
|
| 11199 | |
| 11194 |
JavaScript
유용한 포토샵 강좌 사이트
4
|
| 11190 |
JavaScript
Jpeg등으로 압축하지 않고 Photoshop파일 사이즈 줄이기
3
|
| 29052 |
HTML
특정레이어만 선택해서 보기
3
|
| 11188 | |
| 11182 | |
| 11178 |
JavaScript
포토삽을 초기화 하고 싶을때
3
|
| 29048 | |
| 11171 |
Flash
플래쉬 네비게이션 질문입니다...
6
|
| 11163 | |
| 11159 |
기타
심볼마크와 로고
3
|
| 11154 | |
| 29047 |
HTML
파일에 이미지를 포함시키는 방법
|
| 29037 |
HTML
포토샵을 빨리 뜨게 하려면...
9
|
| 11149 |
JavaScript
포토샵에서 작업하다 글자 사이즈가 갑자기 커지거나 작아질 때.....
4
|
| 29036 |
HTML
PDF 세션에 대한 원리 및 보안
|
| 11135 |
JavaScript
고급스런 색상 만들기 혹은 선택하기...
13
|
| 29032 | |
| 11134 |
JavaScript
롤오버 자바스크립트입니다.
|
| 11129 |
JavaScript
포토샵 한영키 안먹을때..(다른 프로그램도 마찬가지..영구적용)
4
|
| 29031 | |
| 11127 | |
| 29026 |
HTML
이미지 저작권 관련 설명 7탄
4
|
| 11119 | |
| 11115 | |
| 29020 |
HTML
이미지 저작권 관련 설명 6탄
5
|
| 11113 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기