Search code examples
paperjs

paperjs: drag two items in one go without changing their relative position


Which functionality of paperjs should I use so that two items can be dragged in one go without changing their relative position i.e. both the items should move irrespective of which item I am dragging. I have tried doing it with group but it doesn't work. I don't want to make it a compound path either because I want to join/combine two or more items dynamically for dragging purpose.

sketch link

In the given sketch, one end of line coincides with the center of circle. Now whether I drag Circle or Line, both the items should move without changing their relative position.


Solution

  • Groups are designed for this purpose, here is a working example.