Skip to content

Commit

Permalink
Zero-length arrow fix
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Nov 13, 2023
1 parent 427e1cc commit 95256d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ To see every change with descriptions aimed at developers, see
As a continuously updated web app, Cocreate uses dates
instead of version numbers.

## 2023-11-13

* Fix zero-length arrows, in particular fixing crash on Firefox

## 2023-11-03

* Fix arrowheads getting clipped when downloading SVG/PDF,
Expand Down
8 changes: 7 additions & 1 deletion client/lib/dom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ export svgArrowCoords = (pEnd, pAdj, width) ->
else
dx = pAdj.x - x
dy = pAdj.y - y
scale = width / Math.sqrt dx*dx + dy*dy
len = Math.sqrt dx*dx + dy*dy
## Zero-length arrows are oriented rightward in Chrome and Firefox.
if len < 0.0001
dx = -1
dy = 0
len = 1
scale = width / len
dx *= scale
dy *= scale
px = -dy
Expand Down

0 comments on commit 95256d5

Please sign in to comment.