Git Product home page Git Product logo

svg.select.js's Introduction

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://svgdotjs.github.io/svg.select.js/

Get Started

  • Install svg.select.js using bower:

      bower install svg.select.js
    
  • Include 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_boundingRect
  • svg_select_points
  • svg_select_points_lt - left top
  • svg_select_points_rt - right top
  • svg_select_points_rb - right bottom
  • svg_select_points_lb - left bottom
  • svg_select_points_t - top
  • svg_select_points_r - right
  • svg_select_points_b - bottom
  • svg_select_points_l - left
  • svg_select_points_rot - rotation point
  • svg_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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.