Javascript cleanup
This commit is contained in:
@@ -184,64 +184,4 @@ Page.Wizard = new Class({
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var ScrollSpy = new Class( {
|
||||
Implements : [ Options, Events ],
|
||||
|
||||
options : {
|
||||
min : 0,
|
||||
mode : "vertical",
|
||||
max : 0,
|
||||
container : window,
|
||||
onEnter : Function.from(),
|
||||
onLeave : Function.from(),
|
||||
onTick : Function.from()
|
||||
},
|
||||
initialize : function(b) {
|
||||
this.setOptions(b);
|
||||
this.container = $(this.options.container);
|
||||
this.enters = this.leaves = 0;
|
||||
this.timer = 0;
|
||||
|
||||
if (this.options.max == 0) {
|
||||
var c = this.container.getScrollSize();
|
||||
this.options.max = this.options.mode == "vertical" ? c.y : c.x;
|
||||
}
|
||||
this.addListener();
|
||||
},
|
||||
addListener : function() {
|
||||
var self = this;
|
||||
|
||||
self.inside = false;
|
||||
self.container.addEvent("scroll", function() {
|
||||
if(self.timer) clearTimeout(self.timer);
|
||||
self.timer = self.scrollHandler();
|
||||
});
|
||||
},
|
||||
|
||||
scrollHandler: function(){
|
||||
var self = this;
|
||||
|
||||
var b = self.container.getScroll();
|
||||
var c = self.options.mode == "vertical" ? b.y : b.x;
|
||||
|
||||
var min = typeOf(self.options.min) == 'function' ? self.options.min() : self.options.min;
|
||||
var max = typeOf(self.options.max) == 'function' ? self.options.max() : self.options.max;
|
||||
|
||||
if (c >= min && c <= max) {
|
||||
if (!self.inside) {
|
||||
self.inside = true;
|
||||
self.enters++;
|
||||
self.fireEvent("enter", [ b, this.enters ]);
|
||||
}
|
||||
self.fireEvent("tick", [ b, self.inside, self.enters, self.leaves ]);
|
||||
} else {
|
||||
if (self.inside) {
|
||||
self.inside = false;
|
||||
self.leaves++;
|
||||
self.fireEvent("leave", [ b, self.leaves ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user