Skip to content

Commit

Permalink
Fix dragging multiple anchors of a polyline object
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Nov 1, 2023
1 parent 705a591 commit 1fbb9f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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-01

* Fix dragging multiple anchors of a polyline object
[[#226](https://github.com/edemaine/cocreate/issues/226)]

## 2023-08-09

* New polygonal line tool!
Expand Down
3 changes: 3 additions & 0 deletions client/Anchor.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export anchorsOf = (obj) ->
y: y + ty

pointMove = (obj, moved, index, coords) ->
old = moved[index] ? obj.pts[index]
if old?
console.log old.x, old.y, 'vs', coords.x, coords.y
if (old = moved[index] ? obj.pts[index])? and
old.x == coords.x and old.y == coords.y
false
Expand Down
8 changes: 5 additions & 3 deletions client/tools/modes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,11 @@ defineTool
h.moved[id] ?= {}
moved = false
for index in anchorSelection.indicesForId id
x = obj.anchors[index].x + motion.x
y = obj.anchors[index].y + motion.y
moved or= anchorMove obj, h.moved[id], index, {x, y}
# Can't write `moved or=` because we don't want to short-circuit
if anchorMove obj, h.moved[id], index,
x: obj.anchors[index].x + motion.x
y: obj.anchors[index].y + motion.y
then moved = true
continue unless moved
diffs[id] = {id, pts: h.moved[id]}
h.edit diffs if (id for id of diffs).length
Expand Down

0 comments on commit 1fbb9f2

Please sign in to comment.