Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
svg.select.js
Advanced tools
The svg.select.js npm package is a plugin for the SVG.js library that allows for easy selection and manipulation of SVG elements. It provides functionalities for selecting, resizing, and dragging SVG elements, making it useful for creating interactive graphics and diagrams.
Selection
This feature allows you to make SVG elements selectable. The code sample demonstrates how to create a rectangle and make it selectable using the `selectize` method.
const draw = SVG().addTo('body').size(300, 300);
const rect = draw.rect(100, 100).attr({ fill: '#f06' });
rect.selectize();
Resizing
This feature enables resizing of SVG elements. The code sample shows how to create a rectangle, make it selectable, and then enable resizing using the `resize` method.
const draw = SVG().addTo('body').size(300, 300);
const rect = draw.rect(100, 100).attr({ fill: '#f06' });
rect.selectize().resize();
Dragging
This feature allows for dragging of SVG elements. The code sample demonstrates how to create a rectangle, make it selectable, and then enable dragging using the `draggable` method.
const draw = SVG().addTo('body').size(300, 300);
const rect = draw.rect(100, 100).attr({ fill: '#f06' });
rect.selectize().draggable();
SVG.js is a lightweight library for manipulating and animating SVG. It provides a wide range of functionalities for creating and interacting with SVG elements. While svg.select.js is a plugin specifically for selection and manipulation, SVG.js offers a broader set of tools for SVG manipulation.
D3-selection is a module of the D3.js library that provides methods for selecting and manipulating DOM elements, including SVG elements. It offers more general selection and manipulation capabilities compared to svg.select.js, which is more focused on interactive SVG element manipulation.
Interact.js is a JavaScript library for drag-and-drop, resizing, and multi-touch gestures. It can be used with SVG elements to provide similar functionalities to svg.select.js, but it is more versatile and can be used with other types of elements as well.
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()
.
For a demo see http://svgdotjs.github.io/svg.select.js/
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()
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 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 pointstrue
)svg_select_boundingRect
)svg_select_points
)7
)true
)false
)FAQs
An extension of svg.js which allows to select elements with mouse
The npm package svg.select.js receives a total of 1,456,076 weekly downloads. As such, svg.select.js popularity was classified as popular.
We found that svg.select.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.