commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbe...@apache.org
Subject svn commit: r984045 - /commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
Date Tue, 10 Aug 2010 14:21:42 GMT
Author: jbeard
Date: Tue Aug 10 14:21:41 2010
New Revision: 984045

URL: http://svn.apache.org/viewvc?rev=984045&view=rev
Log:
Now works in webkit. Had to work around strange behaviour where events were not being dispatched
to svg root element.

Modified:
    commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html

Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html?rev=984045&r1=984044&r2=984045&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
(original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/demo/drawing-tool/drawing-tool-precompiled.html
Tue Aug 10 14:21:41 2010
@@ -123,21 +123,32 @@
                   stroke:"black"
                 });
 
+								//workaround for webkit: svg root element does not receive events on its own, 
+								//so we create a white background rect, and proxy events to svg element
+								if($.browser.webkit){
+									 var backgroundRect = svg.rect(0,0,"100%","100%",{
+										stroke:"none",
+										fill:"white"
+									}) 
+									console.log(backgroundRect);
+
+									$(["mousedown","mouseup","mousemove"]).each(function(index,eventName){
+										backgroundRect.addEventListener(eventName,function(e){
+											svg.root().dispatchEvent(e);
+										},false)
+									});
+								}
+
 								var scaleHandle = svg.path("M 0 0 L -4 6 L -2 6 L -2 12 L -4 12 L 0 18 L 4 12 L 2
12 L 2 6 L 4 6 L 0 0 z",{
 									transform:"rotate(-45)",
 									visibility:"hidden"
 								})
+
 								var rotationHandle =  svg.path("M 12 0 L 17 5 L 15 5 Q 15 15 5 15 L 5 17 L 0 12 L
5 7 L 5 9 Q 9 9 9 5 L 7 5 L 12 0 z",{
 									visibility:"hidden",
 									transform:"translate(0,0)"
 								})
 
-/*
-								var backgroundRect = svg.rect(0,0,"100%","100%",{
-									stroke:"none",
-									fill:"white"
-								});
-*/
 
                 function hookUpDOMEvents(node,compiledStatechartInstance){
                   //hook up DOM events
@@ -145,6 +156,7 @@
                     if(compiledStatechartInstance[eventName]){
                       node.addEventListener(eventName,function(e){
                         e.preventDefault();
+												console.log(e);
                         compiledStatechartInstance[eventName](e)
                       },false);
                     }
@@ -182,6 +194,7 @@
 
 										hookUpDOMEvents(svg.root(),canvasSC);
 										hookUpDOMEvents(toolbar.root(),canvasSC);
+
 								});
               }  
             })



Mime
View raw message