Free transform tool for Snap.svg elements and sets with many options. Supports snap-to-grid dragging, scaling and rotating with a specified interval and range.
Example can be found at http://svg.dabbles.info/Snap.svg.FreeTransform/
Raphael version that this was based from can be found at https://github.com/AliasIO/Raphael.FreeTransform
Forked from https://github.com/danny-toi/Snap.svg.FreeTransform (will try and feed back updates)
Animate transformations. Works best in combination with apply()
(see the functions section below).
Default: { delay: 700, easing: 'linear' }
Sets the attributes of the handles.
Default: { fill: '#fff', stroke: '#000' }
`customCorners: { size: num, distance: num, corners: [ { action: string: image: string }, ... ] } | false
Specify custom images and events for corner handles.
The corners array should contain 4 objects, one for each corner starting top left going clockwise.
Valid actions: drag
, rotate
, scale
or a custom string. Actions are emitted as events in the callback.
Default: false
Limits the drag area of the handles.
Default: dimensions of the paper
Sets the distance of the handles from the center of the element (num
times radius).
Default: 1.3
Enables/disables dragging.
Default: [ 'center', 'self' ]
Additional elements to draw.
Default: false
Scale axes together or individually.
Default: false
Limit the range of transformation.
Default: { rotate: [ -180, 180 ], scale: [ 0, 99999 ] }
Enables/disables rotating.
Default: [ 'axisX', 'axisY' ]
Enables/disables scaling.
Default: [ 'axisX', 'axisY', 'bboxCorners', 'bboxSides' ]
Snap transformations to num degrees (rotate) or pixels (scale, drag).
Default: { rotate: 0, scale: 0, drag: 0 }
Snap distance in degrees (rotate) or pixels (scale, drag).
Default: { rotate: 0, scale: 0, drag: 7 }
Sets the radius of the handles in pixels.
Default: 5
A callback function can be specified to capture changes and events.
Programmatically apply transformations (see the example above).
Removes handles but keeps values set by the plugin in memory. By
default removes all drag events from the elements. If you'd like to
keep then while the handles are hidden, pass {undrag: false}
to
hideHandles().
Shows handles hidden with hideHandles()
.
Update options and callback.
Removes handles and deletes all values set by the plugin.
Updates handles to reflect the element's transformations.
Licensed under the MIT license.