AliasIO / Raphael.FreeTransform

Free transform tool for Raphaël elements.
http://elbertf.com
362 stars 107 forks source link

Meaning of snapDist #130

Open arunkjn opened 10 years ago

arunkjn commented 10 years ago

I cannot understand the use of snapDist setting and how it differs from snap setting. Please elaborate.

arunkjn commented 10 years ago

I am getting this weird behaviour on snap drag settings. Demonstrated here - http://jsfiddle.net/arunkjn/ddeBW/ Try dragging the rectangle. If I rotate the rectangle first and then drag it, the drag behaviour is fone and snaps properly. What might I be doing wrong here?

AliasIO commented 10 years ago

snap is where it snaps to (grid size, green) and snapDist is when it snaps (how far the object needs to be away from a grid line, red).

2014-06-17-091637_1920x1080_scrot

If you make the values the same the objects will always snap. If you make snapDist smaller they can move freely between grid lines, to an extent.

Both sides of the object snap. In your case it's trying to snap both the left and right size simultaneously. A larger snap value or smaller snapDist value should fix that.

You can play around with some of the presets on the demo:

http://alias.io/raphael/free_transform/

arunkjn commented 10 years ago

Hi @ElbertF

thanks for the clarification. I tried your suggestion and tweaked around with snap and snapDist settings to no avail. I also tried changing the rectangle proportions and (x,y) co-ordinates. But it did not help.

I noticed that after initial scaling by dragging one of the bBoxCorners or initial rotation through x-y axis handles makes the behaviour perfect.

Is there anything else I could be missing here? Can you please try tweaking the values and tell me the one that works? (I tried 80 and 20 from your example page, but that didn't work).

Also, if there a way of overriding the snap behaviour and snap only top and left edges? Or better the 'leading' edge to the direction of drag.

arunkjn commented 10 years ago

I tried to disable snapping for bottom and right edges. Here is the code I used https://github.com/arunkjn/Raphael.FreeTransform/commit/96d7ac42934182c6731c843e30ae2e4ed168e0db I have an updated example here http://jsfiddle.net/arunkjn/G9Lqv/3/ the same behaviour persists. If i scale or rotate first then it works fine.

An example where I programmatically apply scale transform before setting options works fine http://jsfiddle.net/arunkjn/8Fdwg/1/

arunkjn commented 10 years ago

Hi @ElbertF . Just wondering if you had a chance to look at it.

arunkjn commented 10 years ago

Hey @ElbertF sorry for poking you again, but I am kind of stuck here. Do you have any suggestions?