2

I followed the guide on making snapping rulers, but I have additional functionality. The issue is that after dragging stage, the rules appear in the wrong location.

I have tried looking, but can't find anything to use for e.g. something like an offset. Here's a JSfiddle. It is 100% identical to the example, except stage has draggable: true (and moved CSS/JS out of HTML).

https://jsfiddle.net/jyupeqx9/

ifh
  • 171
  • 2
  • 10

1 Answers1

5

Since you are moving a stage and all positions of inner shapes (like rectangles and guid lines) are relative to the stage, you have to adjust position calculations.

To do that you can just update getClientRect function usage:

node.getClientRect({ relativeTo: stage});

DEMO: https://jsfiddle.net/rbahewmu/

lavrton
  • 18,973
  • 4
  • 30
  • 63