diff --git a/CHANGELOG.md b/CHANGELOG.md index 6575875..1cd7688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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, diff --git a/client/lib/dom.coffee b/client/lib/dom.coffee index 0bd64a3..125eb43 100644 --- a/client/lib/dom.coffee +++ b/client/lib/dom.coffee @@ -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