fx.Background = Class.create(); fx.Background.prototype = Object.extend(new fx.Base(), { initialize: function(el, options) { this.el = $(el); this.setOptions(options); this.now = 0; }, increase: function() { this.el.style.marginLeft = this.now + "px"; }, scroll: function(howMuch){ this.clearTimer(); // calculate the width of elements, including padding/border var scroll_limit = this.el.offsetWidth - this.el.parentNode.offsetWidth; if (((this.now + howMuch) <= 0) && ((this.now + howMuch) >= -(Math.abs(howMuch) + scroll_limit))) { this.custom(this.now, this.now + howMuch); } } }); window.onload = function() { myNewEffect = new fx.Background('examplescrolling', {duration: 210});