Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7045

Show
Ignore:
Timestamp:
06/17/07 15:25:17 (1 year ago)
Author:
mislav
Message:

Prototype: mousewheel love for IE. Fixed stopObserving doesn't take string argument.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/branches/event/src/event.js

    r7044 r7045  
    8585        case 'mousewheel': 
    8686          if (B.IE) { 
     87            // this.element == window ? document : this.element 
    8788            this._callback = function(event) { 
    8889              callback.call(this, event, event.wheelDelta/120); 
     
    169170        var ob = this._callback, el = this.element, klass = this.constructor; 
    170171        this.wrapper = function(e) { return ob.call(el, klass.extendEvent(e, el)) }; 
    171         this.element.attachEvent('on' + this._type, this.wrapper); 
     172        // attach it 
     173        if (this._type == 'mousewheel') this.element['on' + this._type] = this.wrapper; 
     174        else this.element.attachEvent('on' + this._type, this.wrapper); 
    172175        this.constructor.globalCache.push(this); 
    173176      }, 
    174177      _remove: function() { 
    175         if (!this.wrapper)  
    176           this.wrapper = this.element._observers[this.type][this.callback.$$guid].wrapper; 
    177         this.element.detachEvent('on' + this._type, this.wrapper); 
     178        if (this._type == 'mousewheel') this.element['on' + this._type] = null; 
     179        else { 
     180          if (!this.wrapper)  
     181            this.wrapper = this.element._observers[this.type][this.callback.$$guid].wrapper; 
     182          this.element.detachEvent('on' + this._type, this.wrapper); 
     183        } 
    178184      } 
    179185    }); 
     
    237243      if (applyToCollection(arguments)) return; 
    238244      useCapture = useCapture || false; 
    239       var collection = element._observers; 
     245      var collection = $(element)._observers; 
    240246      if (!collection) return; 
    241247 
  • spinoffs/prototype/branches/event/test/functional/event.html

    r7044 r7045  
    163163   
    164164  <script type="text/javascript"> 
    165     var msg = $('delta') 
     165    var msg = $('delta'); 
    166166    var wheel = { 
    167167      handle: function(e, delta) { 
     
    172172      }, 
    173173      attach: function() { 
    174         Event.observe(window, 'mousewheel', this.handle); 
     174        Event.observe(this.scope, 'mousewheel', this.handle); 
    175175        msg.update('try scrolling').setStyle({ color:'crimson' }); 
    176176        msg.scrollTotal = 0; 
    177177      }, 
    178178      detach: function() { 
    179         Event.stopObserving(window, 'mousewheel'); 
     179        Event.stopObserving(this.scope, 'mousewheel'); 
    180180        msg.update('<i>DETACHED</i>').setStyle({ color:'gray' }); 
    181       } 
     181      }, 
     182      scope: $('wheel') 
    182183    } 
    183184  </script> 
  • spinoffs/prototype/branches/event/TODO

    r6616 r7045  
    11* [done] Event handling (IE) fixes and enhancements, see r6194 
    22* [done] Remove all event listeners on any element 
    3 * [broken] event.stop() instead of Event.stop(event) 
     3* [done] event.stop() instead of Event.stop(event) 
    44* [done] Node constants as per DOM/ECMAScript bindings (r6205) 
    55* [done] isLeft/Middle/RightClick 
    66* [done] support for "DOMContentLoaded" 
    77* [done] Event.findElement should extend the result 
     8* resolve special cases for mousewheel handling: 
     9  - window in IE 
     10  - document in Opera 
    811* stopImmediatePropagation 
    912  http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-Event-stopImmediatePropagation