npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svg.select.js

v3.0.1

Published

An extension of svg.js which allows to select elements with mouse

Downloads

5,745,939

Readme

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 specify which points to be drawn (default all will be drawn)

The list can be an array of strings or a comma separated list / string, representing each position, in correspondence with the classes:

  • lt - left top
  • rt - right top
  • rb - right bottom
  • lb - left bottom
  • t - top
  • r - right
  • b - bottom
  • l - left

Example of drawing only top and right points:

rect.selectize({
  points: ['t', 'r'] // or 't, r'
})

There is also an extra option called pointsExclude which can be a list of points to be excluded from the points list.

So let's say that you need all the points except top and right:

rect.selectize({
  pointsExclude: ['t', 'r'] // or 't, r'
})

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 ['lt', 'rt', 'rb', 'lb', 't', 'r', 'b', 'l'])
  • pointsExclude: Same as points option, only thing that this excludes listed points, you can use (default [])
  • classRect: Classname of the rect from the bounding Box (default svg_select_boundingRect)
  • classPoints: Classname/Prefix of the Points (default svg_select_points)
  • pointSize: Size of the point. Radius for the pointType: 'circle' or size of a rect for pointType: 'rect' (default 7)
  • rotationPoint: Draws the point for doing rotation (default true)
  • deepSelect: Only for polygon/polyline/line. Selects the points itself (default false)
  • pointType: Type of a point, circle or rect or function (see functions for drawing circle or rect points) (default circle)