From 35d51085a14319a767bcafa79617a6d3413cae0f Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sat, 14 May 2011 12:59:21 +0200 Subject: [PATCH 1/2] Tool: fix problem where document was being redrawn onMouseMove with only an onMouseDrag handler (should only happen on touch devices) --- src/tool/Tool.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tool/Tool.js b/src/tool/Tool.js index 0717fccd..3a5a9f90 100644 --- a/src/tool/Tool.js +++ b/src/tool/Tool.js @@ -45,7 +45,8 @@ var Tool = this.Tool = ToolHandler.extend(new function() { // If the event was triggered by a touch screen device, // prevent the default behaviour, as it will otherwise // scroll the page: - if (event && event.targetTouches) + var touchDevice = event && event.targetTouches; + if (touchDevice) event.preventDefault(); var point = event && viewToArtwork(event, that._document); // If there is only an onMouseMove handler, call it when @@ -58,7 +59,7 @@ var Tool = this.Tool = ToolHandler.extend(new function() { } else if (!dragging || onlyMove) { that.onHandleEvent('mousemove', point, event); } - if (that.onMouseMove || that.onMouseDrag) + if (that.onMouseMove || (touchDevice && that.onMouseDrag)) that._document.redraw(); }, From 2bfe42da0515bcdfa45fe2678f7a7d7701ac7db0 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Sat, 14 May 2011 13:03:18 +0200 Subject: [PATCH 2/2] Have the CompoundPath constructor reverse the segments of all paths passed to it except for the first one. Introduce 'keepDirection' option to allow importing of already existing CompoundPath items. --- src/path/CompoundPath.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 772d1044..1189327a 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -15,12 +15,20 @@ */ var CompoundPath = this.CompoundPath = PathItem.extend({ - initialize: function(items) { + // PORT: port the reversing of segments and keepDirection flag + initialize: function(items, keepDirection) { this.base(); this.children = []; if (items) { - for (var i = 0, l = items.length; i < l; i++) + for (var i = 0, l = items.length; i < l; i++) { + var item = items[i]; + // All paths except for the first one are reversed when + // creating a compound path, so that they draw holes. + // When keepDirection is set to true, child paths aren't reversed. + if (!keepDirection && i != l - 1) + item.reverse(); this.appendTop(items[i]); + } } },