svg.select.js
An extension of svg.js which allows to select elements with mouse
Note: Duo to naming conflicts the exported method was renamed from select() to selectize().
Demo
For a demo see http://fuzzyma.github.io/svg.select.js/
Get Started
Install
svg.select.jsusing bower:bower install svg.select.jsInclude the script after svg.js into your page
<script src="svg.js"></script> <script src="svg.select.js"></script>Select a rectangle using this simple piece of code:
<div id="myDrawing"></div> var drawing = new SVG('myDrawing').size(500, 500); drawing.rect(50,50).selectize()
Usage
Select
var draw = SVG('drawing');
var rect = draw.rect(100,100);
rect.selectize();
// or deepSelect
rect.selectize({deepSelect:true});
Unselect
rect.selectize(false);
// or deepSelect
rect.selectize(false, {deepSelect:true});
You can style the selection with the classes
svg_select_boundingRectsvg_select_pointssvg_select_points_lt- left topsvg_select_points_rt- right topsvg_select_points_rb- right bottomsvg_select_points_lb- left bottomsvg_select_points_t- topsvg_select_points_r- rightsvg_select_points_b- bottomsvg_select_points_l- leftsvg_select_points_rot- rotation pointsvg_select_points_point- deepSelect points
Options
- points: Points should be drawn (default
true) - classRect: Classname of the rect from the bounding Box (default
svg_select_boundingRect) - classPoints: Classname/Prefix of the Points (default
svg_select_points) - radius: Radius of the points (default
7) - rotationPoint: Draws the point for doing rotation (default
true) - deepSelect: Only for polygon/polyline/line. Selects the points itself (default
false)