Changing locationSpot shifts the node

Hi-

We have an option for the user to change the locationspot so that he or she can change the snap point on a node. Our problem is that when this is changed, the node shifts so that the newly selected locationSpot is where the old one was. Is there a way to suppress this behavior, as we do not want the node to shift when changing the snapping point?

thanks,
Caleb

Yes, changing the Node.locationSpot does not change the Node.location, but does change its Node.position.

I suggest that you remember its old position and then set it back afterwards. I assume you realize that it’s likely that the node is no longer snapped correctly after shifting it back.

thanks Walter.

As a follow up to this, we have a “properties” box where the user can set a custom angle on a shape by entering an integer. Is there a way to make the angle property still use the center of a node while the locationspot can be different than the center?

For example we’d like the Top center point to be the snapping point, but the center of the node to be the rotate origin.

I tried naming the entire node and then setting that name as the rotateObjectName to no avail.

When you rotate a Part (even if you just set its angle or set the angle a GraphObject inside the Part), the location must not change, so if you rotate the Node and its location is (X, Y), its location must still be (X, Y) afterwards.

I’m not sure how to reconcile both things you want, but perhaps instead of letting users change the locationSpot, you could keep that as the rotate origin and let them change some input into a dragComputation function. Part.dragComputation lets you customize snapping (well, any drag) behavior.

dragComputation examples:

http://gojs.net/latest/samples/dragUnoccupied.html
http://gojs.net/latest/samples/absolute.html
http://gojs.net/latest/samples/flowBuilder.html