Cms = {}; Cms.UpRoller = function(rid, speed, isSleep, sleepTime, rollRows, rollSpan, unitHight) { this.speed = speed; this.rid = rid; this.isSleep = isSleep; this.sleepTime = sleepTime; this.rollRows = rollRows; this.rollSpan = rollSpan; this.unitHight = unitHight; this.proll = $('#roll-' + rid); this.prollOrig = $('#roll-orig-' + rid); this.prollCopy = $('#roll-copy-' + rid); // this.prollLine = $('#p-roll-line-'+rid); this.sleepCount = 0; this.prollCopy[0].innerHTML = this.prollOrig[0].innerHTML; var o = this; this.pevent = setInterval(function() { o.roll.call(o) }, this.speed); } Cms.UpRoller.prototype.roll = function() { if (this.proll[0].scrollTop > this.prollCopy[0].offsetHeight) { this.proll[0].scrollTop = this.rollSpan + 1; } else { if (this.proll[0].scrollTop % (this.unitHight * this.rollRows) == 0 && this.sleepCount <= this.sleepTime && this.isSleep) { this.sleepCount++; if (this.sleepCount >= this.sleepTime) { this.sleepCount = 0; this.proll[0].scrollTop += this.rollSpan; } } else { var modCount = (this.proll[0].scrollTop + this.rollSpan) % (this.unitHight * this.rollRows); if (modCount < this.rollSpan) { this.proll[0].scrollTop += this.rollSpan - modCount; } else { this.proll[0].scrollTop += this.rollSpan; } } } } Cms.LeftRoller = function(rid, speed, rollSpan) { this.rid = rid; this.speed = speed; this.rollSpan = rollSpan; this.proll = $('#roll-' + rid); this.prollOrig = $('#roll-orig-' + rid); this.prollCopy = $('#roll-copy-' + rid); this.prollCopy[0].innerHTML = this.prollOrig[0].innerHTML; var o = this; this.pevent = setInterval(function() { o.roll.call(o) }, this.speed); } Cms.LeftRoller.prototype.roll = function() { if (this.proll[0].scrollLeft > this.prollCopy[0].offsetWidth) { this.proll[0].scrollLeft = this.rollSpan + 1; } else { this.proll[0].scrollLeft += this.rollSpan; } }