Skip to content

Commit 711cfbe

Browse files
Merge pull request #1 from simpleclub-extended/fix/invalid-remove-off-canvas-path-relative-move
fix(removeOffCanvasPaths): Invalid removal when line path starts with relative move
2 parents f3495ff + 714db6a commit 711cfbe

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ test/cli/output
1414
coverage
1515
.DS_Store
1616
.vscode
17+
.idea
1718
*.log
1819
package-lock.json
1920

plugins/_path.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,18 @@ export const intersects = function (path1, path2) {
253253

254254
// Check intersection of every subpath of the first path with every subpath of the second.
255255
return hullNest1.some(function (hull1) {
256-
if (hull1.list.length < 3) return false;
256+
if (hull1.list.length < 3) {
257+
// When there are only two points in the convex hull, add the first point to close the polygon.
258+
// This can happen when the path is only a line.
259+
hull1.list.push(hull1.list[0]);
260+
}
257261

258262
return hullNest2.some(function (hull2) {
259-
if (hull2.list.length < 3) return false;
263+
if (hull2.list.length < 3) {
264+
// When there are only two points in the convex hull, add the first point to close the polygon.
265+
// This can happen when the path is only a line.
266+
hull2.list.push(hull2.list[0]);
267+
}
260268

261269
var simplex = [getSupport(hull1, hull2, [1, 0])], // create the initial simplex
262270
direction = minus(simplex[0]); // set the direction to point towards the origin
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Should not throw when path starts with relative move and is within the view box
2+
3+
===
4+
5+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
6+
<path d="m10 5-5 5" stroke="#000"></path>
7+
</svg>
8+
9+
@@@
10+
11+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">
12+
<path d="m10 5-5 5" stroke="#000"/>
13+
</svg>

0 commit comments

Comments
 (0)