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.
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.
精彩评论