[함수] 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에서 이동 됨]
게시글 목록
| 번호 | 제목 |
|---|---|
| 10853 |
JavaScript
속도를 위해 데이터를 접속자 메모리에
|
| 10852 | |
| 10850 | |
| 28848 | |
| 10849 |
JavaScript
백그라운드에음악걸기
|
| 28847 |
HTML
배경에 그림스타일지정
|
| 10846 |
기타
메신저형식의광고
2
|
| 28846 |
HTML
많이 쓰이는 자바스크립트
|
| 10845 | |
| 28845 |
HTML
마우스로 이미지크기 변경하기
|
| 10844 |
JavaScript
도메인 주소에 자동으로 www 붙이기 (php)
|
| 28844 |
HTML
다음부동산매물스크립트1
|
| 28843 |
HTML
다음부동산매물스크립트
|
| 10843 |
JavaScript
다각형이미지슬라이드쇼(익스네츠)
|
| 28842 |
HTML
날짜 형식 입력 받은 값 확인하기
|
| 10842 | |
| 28841 |
HTML
그림클릭시 레이어 띄우기
|
| 10841 |
MySQL
그림을 디비에 저장하는 방법
|
| 28840 |
HTML
그림 앨범 스크립트
|
| 28839 |
HTML
간단한 팝업오브젝트 예제
|
| 10840 |
JavaScript
가운데 정렬된 홈페이지에서 따라다니는 레이어
|
| 10839 | |
| 24791 | |
| 24789 | |
| 10836 |
기타
외부 링크 막기
2
|
| 28838 | |
| 24788 | |
| 24787 | |
| 24786 |
계약서
농지임대차계약서
|
| 28837 | |
| 28834 |
HTML
URL옆에 뜨는 숏컷아이콘만들기.
2
|
| 10835 |
JavaScript
클릭시 펼쳐지는 메뉴
|
| 10834 |
정규표현식
수수료계산
|
| 28833 |
HTML
기본적인 페이징
|
| 28829 |
HTML
만 19세 확인하기
3
|
| 10833 |
JavaScript
IE에서 쓰는 CSS filter 사이트 소개
|
| 10831 | |
| 10830 | |
| 10829 |
JavaScript
iconv 함수 사용시 일부 글자가 변환되지 않는경우
|
| 28828 |
HTML
금액에 점찍고 한글 표시하기
|
| 10828 | |
| 10827 |
MySQL
mysql link 추가로 만들기
|
| 10823 | |
| 10822 |
기타
[펌] SAMBA 설정
|
| 10821 |
JavaScript
1-1000 까지 누락된 숫자 구하기
|
| 10820 | |
| 28822 |
HTML
간단하게 만들어본 프레임워크
5
|
| 10814 | |
| 10812 |
Flash
vr기능-도와주셈
1
|
| 10811 | |
| 10810 |
JavaScript
mod_cband 간단 정리
|
| 10808 |
Flash
간단한 플래시 보완패치입니다.
1
|
| 10804 |
JavaScript
cs..cs2 버젼...윈도우즈 탐색기프리뷰 패치(psd,ai)...
3
|
| 10797 | |
| 28821 |
HTML
IeTagConvertor
|
| 10796 | |
| 10795 |
JavaScript
ncftp 서브 디렉토리 포함 모두 전송
|
| 10794 |
JavaScript
테이블 각 row 마우스오버시 색깔바꾸기
|
| 10792 | |
| 10789 |
MySQL
apache - mod_ssl 설치하기
2
|
| 10785 | |
| 10781 | |
| 10780 |
정규표현식
자바스크립트 이메일 체크 함수
|
| 28820 |
HTML
PHP에서 홈페이지 주소 검사
|
| 10776 |
PHP
문자셋(인코딩 바꾸는 팁
3
|
| 10769 |
JavaScript
당장써먹어야 할 팁) 앞으로 gif는 물러가고 png시대가 될거 같네요
6
|
| 10766 |
JavaScript
full-down메뉴[펌]
2
|
| 10765 |
JavaScript
플래쉬 무비 전체 화면으로 뜨게 하는 fscommand
|
| 10758 |
JavaScript
코딩시 테이블을 줄입시다.
6
|
| 28818 | |
| 10754 |
JavaScript
모든 폰트 설정 한번에 바꾸기(식별자 *의 사용법)
3
|
| 10753 | |
| 10750 | |
| 28817 |
HTML
자바스크립트에서 변수 없애기
|
| 10749 | |
| 10748 | |
| 10747 | |
| 10746 |
JavaScript
[소개]윈도우 미디어 플레이어 - 컨트롤 버튼
|
| 10740 |
JavaScript
iframe사용시 높이 자동 조정
5
|
| 10738 |
Flash
플래시 무비에 레이어 올리기
1
|
| 10735 |
JavaScript
도움말 띄우기 - 관리자 페이지에 있는 것을 추림
2
|
| 10734 | |
| 28812 | |
| 10730 | |
| 10726 | |
| 10725 |
기타
자바스크립트 기초문서
|
| 28811 | |
| 10724 |
JavaScript
숫자를 한글로 변환하기
|
| 10723 |
JavaScript
디렉터리 파일 찾기 순서 DirectoryIndex
|
| 10722 | |
| 10721 | |
| 10717 | |
| 10716 |
기타
Apache 보안 팁
|
| 10715 |
JavaScript
문서루트 위치 DocumentRoot
|
| 10713 |
Linux
lilo.conf
1
|
| 10712 | |
| 10711 | |
| 10710 |
JavaScript
웹 서버가 기다리는 포트(Port)
|
| 10709 |
JavaScript
logrotate.conf의 설정및 옵션에 대한 설명
|
| 10708 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기