[함수] 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에서 이동 됨]
게시글 목록
| 번호 | 제목 |
|---|---|
| 28772 |
HTML
오늘 날짜와 요일 넣기
1
|
| 10555 | |
| 10554 |
JavaScript
홈에 머문시간을 제목표시줄과 상태바에 실시간으로 알려줍니다
|
| 10553 | |
| 28770 |
HTML
창의 사이즈 변경 금지 시키기
1
|
| 28769 |
HTML
손님의 방문 횟수를 알려 줍니다
|
| 10552 | |
| 10551 | |
| 28768 |
HTML
자바스크립트 버튼에 링크 걸기
|
| 10550 | |
| 10549 |
JavaScript
들어올때나 나갈때나 인사는 착실히 해야죠..ㅋㅋㅋㅋ
|
| 10548 | |
| 10547 | |
| 28767 |
HTML
이름을 물어보고 인사하는 스크립트
|
| 10546 | |
| 10545 |
JavaScript
창을 열면 인사하는 간단한 스크립트
|
| 10544 | |
| 28766 | |
| 10541 | |
| 10540 | |
| 10538 | |
| 10537 |
기타
순발력테스트
|
| 10535 |
Flash
Ajax강의
1
|
| 10534 |
JavaScript
named -- dns서버
|
| 10533 |
JavaScript
문서내 이미지갯수 출력
|
| 10532 | |
| 28760 | |
| 10531 | |
| 10530 |
JavaScript
리눅스 부팅후 자동 실행
|
| 28759 |
HTML
버튼에 스타일주기(익스)
|
| 10527 | |
| 10525 | |
| 10523 | |
| 10520 |
Flash
swish 서브메뉴 제작방법
2
|
| 28758 |
HTML
오른쪽마우스클릭시메뉴(익스전용)
|
| 28757 |
HTML
오른쪽마우스클릭시메뉴(익스전용)
|
| 10519 | |
| 10518 |
MySQL
mysql 자동 최적화 / 복구 스크립트
|
| 10517 |
JavaScript
내용 복사해서 붙어넣기 하면 출처까지가 따라서 나옴 (출처:네이버 소스)
|
| 10515 |
JavaScript
ncftp사용법
1
|
| 28756 |
HTML
영카트에서 카테고리 검색하기
|
| 10514 | |
| 10512 | |
| 10511 |
JavaScript
영어철저가 의심스러울때
|
| 10510 |
JavaScript
로그인할때 나오는 메시지 바꾸기
|
| 10509 | |
| 10508 | |
| 10507 | |
| 28755 |
HTML
자바스크립트로 url 획득
|
| 28751 | |
| 10506 |
JavaScript
파일을 엑셀 혹은 워드로 다운 받기
|
| 10505 | |
| 10504 |
JavaScript
테이블속성연습
|
| 10503 | |
| 10499 | |
| 10487 | |
| 28748 |
HTML
투명도조절
2
|
| 10486 | |
| 28747 | |
| 10484 |
JavaScript
날짜 계산하기
1
|
| 10483 |
기타
폼필드로 바탕색상조정
|
| 10482 | |
| 28746 |
HTML
버튼 하나로 링크두개를 열어보자
|
| 10480 |
JavaScript
접속시도를 여러번 하는 IP 자동 블락하기
1
|
| 10476 | |
| 10473 |
JavaScript
팝업창.. 지정한 시간대에 열기
2
|
| 10472 |
기타
한글 영문으로 변환
|
| 28745 |
HTML
[펌]다중 업로드
|
| 10460 | |
| 10456 | |
| 28739 | |
| 10455 | |
| 28738 | |
| 10451 | |
| 10448 | |
| 10446 |
JavaScript
font-weight 숫자로도 가능
1
|
| 10445 |
JavaScript
에디터 수정해서 쓰세요!
|
| 10444 |
기타
리사이즈 팝업
|
| 10442 | |
| 10439 |
JavaScript
배경음악 또는 배경이미지 등 브라우저를 열고 처음 접속시 한번만 실행
2
|
| 10408 |
Flash
무료 플래시 209개
30
|
| 10403 | |
| 10400 |
JavaScript
문서내에 글씨 찾기
2
|
| 10398 | |
| 10397 | |
| 10396 |
JavaScript
ssh dictionary attack 막기
|
| 10391 | |
| 10390 | |
| 28733 |
HTML
밑의 갤러리 압축 화일
4
|
| 10389 |
JavaScript
까만도둑님께서 플래쉬 갤러리가 필요하시다고 해서...
|
| 10383 | |
| 10378 |
Flash
플래시에서 tabIndex 적용하기
4
|
| 28732 | |
| 10342 |
Flash
간단하지만 유용한 배너관리 시스템
35
|
| 28731 | |
| 10335 |
Flash
플래시 자동 슬라이더
6
|
| 28730 |
HTML
cart클래스2
|
| 28729 |
HTML
cart클래스1
|
| 28727 |
HTML
비교 복사
1
|
| 10332 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기