Changeset 7045
- Timestamp:
- 06/17/07 15:25:17 (1 year ago)
- Files:
-
- spinoffs/prototype/branches/event/src/event.js (modified) (3 diffs)
- spinoffs/prototype/branches/event/test/functional/event.html (modified) (2 diffs)
- spinoffs/prototype/branches/event/TODO (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinoffs/prototype/branches/event/src/event.js
r7044 r7045 85 85 case 'mousewheel': 86 86 if (B.IE) { 87 // this.element == window ? document : this.element 87 88 this._callback = function(event) { 88 89 callback.call(this, event, event.wheelDelta/120); … … 169 170 var ob = this._callback, el = this.element, klass = this.constructor; 170 171 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); 172 175 this.constructor.globalCache.push(this); 173 176 }, 174 177 _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 } 178 184 } 179 185 }); … … 237 243 if (applyToCollection(arguments)) return; 238 244 useCapture = useCapture || false; 239 var collection = element._observers;245 var collection = $(element)._observers; 240 246 if (!collection) return; 241 247 spinoffs/prototype/branches/event/test/functional/event.html
r7044 r7045 163 163 164 164 <script type="text/javascript"> 165 var msg = $('delta') 165 var msg = $('delta'); 166 166 var wheel = { 167 167 handle: function(e, delta) { … … 172 172 }, 173 173 attach: function() { 174 Event.observe( window, 'mousewheel', this.handle);174 Event.observe(this.scope, 'mousewheel', this.handle); 175 175 msg.update('try scrolling').setStyle({ color:'crimson' }); 176 176 msg.scrollTotal = 0; 177 177 }, 178 178 detach: function() { 179 Event.stopObserving( window, 'mousewheel');179 Event.stopObserving(this.scope, 'mousewheel'); 180 180 msg.update('<i>DETACHED</i>').setStyle({ color:'gray' }); 181 } 181 }, 182 scope: $('wheel') 182 183 } 183 184 </script> spinoffs/prototype/branches/event/TODO
r6616 r7045 1 1 * [done] Event handling (IE) fixes and enhancements, see r6194 2 2 * [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) 4 4 * [done] Node constants as per DOM/ECMAScript bindings (r6205) 5 5 * [done] isLeft/Middle/RightClick 6 6 * [done] support for "DOMContentLoaded" 7 7 * [done] Event.findElement should extend the result 8 * resolve special cases for mousewheel handling: 9 - window in IE 10 - document in Opera 8 11 * stopImmediatePropagation 9 12 http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-Event-stopImmediatePropagation