Adrian
Adrian

Reputation: 784

Raphael path centering

I have a canvas of size 480x480, with a grid of 8 rects by 8, each 60x60 (a chess board basically).

I managed to succesfully import a svg (say a rook). I know how to scale and translate it to different places. I know how to drag'n'drop.

The only thing I could not do is to force the path of the rook on the center of each square. When I drag the piece to a certain rect it should be automatically positioned to the center of the square it is dragged above.

I tried snapTo, but although some timid snapping tries are visible, the path still moves around easily.

Upvotes: 2

Views: 358

Answers (1)

Adrian
Adrian

Reputation: 784

I think I've solved it. It's all about the up function that ends a drag. Simply extract the drop coordinates and substract them from the desired position.

Upvotes: 1

Related Questions