javascript 상하 롤링 v1.0
script 2010. 1. 31. 22:39/**
* rolling js v1.0
* by junyong (http://junyong.pe.kr)
*/
function rolling(options) {
var self = this;
this.object = document.getElementById(options.rollId);
this.object.onmouseover = function() { self.stop(); };
this.object.onmouseout = function() { self.play(); };
this.delay = options.delay || 1000;
this.speed = options.speed || 50;
this.step = options.step || 1;
this.mover = options.mover || false;
this.elChildHeight = options.childHeight;
this.elHeight = this.object.offsetHeight;
this.elPosition = 0;
this.object.appendChild(this.object.cloneNode(true));
this.control = setTimeout(function() {self.play()}, this.delay);
}
rolling.prototype = {
play:function() {
var self = this, time;
this.elPosition = this.elPosition>(this.mover?this.elHeight:0) ? this.elPosition-this.elHeight : this.elPosition+1;
this.object.style.top = (this.mover ? -this.elPosition : this.elPosition) + "px";
this.control = setTimeout(function() {self.play()}, this.elPosition%(this.elChildHeight*this.step)==0?this.delay:this.speed);
},
stop:function() {
clearTimeout(this.control);
}
}
간단하게 사용할 수 있는 상하 롤링 스크립트 소스
사용은 아래와 같이
roll1 = new rolling({rollId: "rollText1", delay: 1000, speed: 10, step: 2, mover: true, childHeight: 18});
간단 예제 파일첨부
다음버전은 좌우 롤링도..
'script' 카테고리의 다른 글
| 익스플로러에서 window.open() 팝업 창의 width가 250 이하로 조정이 안될때 (0) | 2010.09.30 |
|---|---|
| [Link] Google Maps Plugin for jQuery (0) | 2010.09.20 |
| [Link] javascript CDN(Content Delivery Network) Catalog (0) | 2010.07.08 |
| javascript document.referrer (0) | 2010.03.31 |
| javascript 세자리마다 콤마(,) 찍기 (0) | 2010.02.18 |
| jQuery 1.4 Released (0) | 2010.01.16 |
| jQuery - live() (0) | 2010.01.13 |
| jQuery - data(), removeData() (0) | 2010.01.12 |
| window.onload 여러곳에서 사용하기 (0) | 2009.12.04 |
| [Link] jQuery Cheat Sheet (0) | 2009.11.05 |
rolling.html