magussiro / cakejs

Automatically exported from code.google.com/p/cakejs
0 stars 0 forks source link

mousewheel event does not work #30

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I've found that `foo.when("mousewheel", ...)` never gets triggered.  Below
is a patch which will fix this :)

Index: cake.js
===================================================================
--- cake.js (revision 39)
+++ cake.js (working copy)
@@ -3660,6 +3660,17 @@
         th.absoluteMouseX = th.absoluteMouseY = th.mouseX = th.mouseY = null
     }, true)

+    this.canvas.parentNode.addEventListener('DOMMouseScroll', function(e) {
+      var nev = document.createEvent('MouseEvents')
+      nev.initMouseEvent('mousewheel', true, true, window, e.detail,
+        e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey,
+        e.shiftKey, e.metaKey, e.button, e.relatedTarget)
+      nev.sd = e.detail // Scroll Delta
+      // Note: A negative delta is scrolling up, positive delta is down
+      nev.canvasTarget = th.target
+      th.dispatchEvent(nev)
+    }, false)
+

Original issue reported on code.google.com by wole...@gmail.com on 1 Feb 2009 at 9:29

GoogleCodeExporter commented 8 years ago
Ah, true, good catch. Thank you for the patch. I think I'll rather add 
DOMMouseScroll
to the list of dispatched events though. Emulating the DOM 3 MouseWheelEvent 
with
DOMMouseScroll sounds like a good way to start getting doubled events when and 
if DOM
3 becomes supported in browsers. 

http://www.w3.org/TR/DOM-Level-3-Events/events.html#Events-MouseWheelEvent

Original comment by Ilmari.H...@gmail.com on 19 Feb 2009 at 6:42

GoogleCodeExporter commented 8 years ago
I pushed the DOMMouseScroll patch to svn now.

Original comment by Ilmari.H...@gmail.com on 19 Feb 2009 at 6:54

GoogleCodeExporter commented 8 years ago
Awesome -- thanks!

Original comment by wole...@gmail.com on 19 Feb 2009 at 7:13