Handles
This plugin will enable any jCanvas rectangle or image to be resized using draggable handles on its four corners.
Once you download and include the plugin on your page, you can add these drag handles to a rectangle by specifying the handle
property with the properties of your handle.
It’s important to note that each drag handle is an actual jCanvas layer.
Rectangles
The following example will draw a resizable rectangle.
Resizing from a corner
By default, plugin resizes the rectangle from its center. However, you can easily change this behavior by setting the resizeFromCenter
property to false
.
Constraining proportions
You can also constrain the original proportions of the shape using the constrainProportions
property.
Of course, this constraining also works when resizing from a corner (that is, when resizeFromCenter
is false
).
The aspect ratio to which the image is constrained is determined by the layer’s initial width
and height
attributes. However, you can also define an explicit aspect ratio for the layer using the aspectRatio
property.
Note that the layer’s aspectRatio
is disregarded when constrainProportions
is false
.
Handle placement
The plugin allows for handles to be placed on either the corners of the layer, or on its sides. This can be especially useful for shapes such as ellipses, which have no actual corners but whose sides extend to the ellipse’s defined width and height.
To specify where handles are placed, specify the handlePlacement
property with any of the following values: 'corners'
, 'sides'
, or 'both'
. The default value is 'corners'
.
Ellipses
You can also add handles to ellipse layers in the same manner, though this is more practical using the handlePlacement
property.
Images
You can also add handles to image layers in the same manner. However, note that in order for this to work properly, you must specify the width
and height
properties.
Lines
You can also add handles to line layers in the same manner.
Curves
You can also add handles to quadratic or Bézier curve layers. It is recommended that you also set guides on your curve layers (via the guide
property) so that the control points and anchor points are visually connected.
Events
The plugin also adds the following custom events: handlestart
, handlemove
, handlestop