Browse files

Updating a few things...

  • Loading branch information...
1 parent d8e1d31 commit b8808685635b4f34f7066fe651362e6212a8e5aa @darkwing committed Jan 25, 2010
Showing with 12 additions and 11 deletions.
  1. +1 −1 Source/ScrollSide-yui-compressed.js
  2. +10 −9 Source/ScrollSide.js
  3. +1 −1 package.yml
View
2 Source/ScrollSide-yui-compressed.js
@@ -15,4 +15,4 @@ provides:
- ScrollSide
...
*/
-var ScrollSide=new Class({Implements:[Options,Events],options:{reset:true,movement:75},initialize:function(a,b){this.setOptions(b);this.container=$(a);if(this.options.reset){this.container.scrollTo(0,0);}this.containerWidth=this.container.getScrollSize().x;this.position=this.container.getScroll().x;this.addListeners();},addListeners:function(){var a=(this.container==$(document.body)?window:this.container);a.addEvent("scroll",function(){this.position=this.container.getScroll().x;}.bind(this));this.container.addEvent("mousewheel",function(b){b.stop();if(b.wheel<0){this.fireEvent("onScrollUp",[b]);var c=this.position+this.options.movement;this.position=(c<=this.containerWidth?c:this.containerWidth);}else{this.fireEvent("onScrollDown",[b]);var c=this.position-this.options.movement;this.position=(c>0?c:0);}this.container.scrollTo(this.position,0);}.bind(this));}});
+var ScrollSide=new Class({Implements:[Options,Events],options:{reset:true,movement:75},initialize:function(a,b){this.setOptions(b);this.container=document.id(a);if(this.options.reset){this.container.scrollTo(0,0);}this.containerWidth=this.container.getScrollSize().x;this.position=this.container.getScroll().x;this.addListeners();},addListeners:function(){var a=(this.container==document.id(document.body)?window:this.container);a.addEvent("scroll",function(){this.position=this.container.getScroll().x;}.bind(this));this.container.addEvent("mousewheel",function(b){if(b){b.stop();}var c;if(b.wheel<0){this.fireEvent("scrollUp",[b]);c=this.position+this.options.movement;this.position=(c<=this.containerWidth?c:this.containerWidth);}else{this.fireEvent("scrollDown",[b]);c=this.position-this.options.movement;this.position=(c>0?c:0);}this.container.scrollTo(this.position,0);}.bind(this));}});
View
19 Source/ScrollSide.js
@@ -33,7 +33,7 @@ var ScrollSide = new Class({
initialize: function(container,options) {
/* set options */
this.setOptions(options);
- this.container = $(container);
+ this.container = document.id(container);
if(this.options.reset) { this.container.scrollTo(0,0); }
this.containerWidth = this.container.getScrollSize().x;
this.position = this.container.getScroll().x;
@@ -44,23 +44,24 @@ var ScrollSide = new Class({
/* listen for scrolling */
addListeners: function() {
/* scroll reset */
- var scrollContainer = (this.container == $(document.body) ? window : this.container);
+ var scrollContainer = (this.container == document.id(document.body) ? window : this.container);
scrollContainer.addEvent('scroll',function() {
this.position = this.container.getScroll().x;
}.bind(this));
/* mousewheeling */
- this.container.addEvent('mousewheel',function(event) {
- event.stop();
+ this.container.addEvent('mousewheel',function(e) {
+ if(e) { e.stop(); }
+ var pos;
/* scroll down/right */
- if(event.wheel < 0) {
- this.fireEvent('onScrollUp',[event]);
- var pos = this.position + this.options.movement;
+ if(e.wheel < 0) {
+ this.fireEvent('scrollUp',[e]);
+ pos = this.position + this.options.movement;
this.position = (pos <= this.containerWidth ? pos : this.containerWidth);
}
/* scroll up/left */
else{
- this.fireEvent('onScrollDown',[event]);
- var pos = this.position - this.options.movement;
+ this.fireEvent('scrollDown',[e]);
+ pos = this.position - this.options.movement;
this.position = (pos > 0 ? pos : 0);
}
this.container.scrollTo(this.position,0);
View
2 package.yml
@@ -1,6 +1,6 @@
name: ScrollSide
author: davidwalsh
-current: 0.1
+current: 0.5
category: Interface
tags: [events,scroll]
docs: http://davidwalsh.name/js/scrollside

0 comments on commit b880868

Please sign in to comment.