Security News
Supply Chain Attack Detected in @solana/web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
mobius1-selectable
Advanced tools
Inspired by the jQuery UI Selectable plugin. Functionality and options are identical to the jQuery UI version with some additions and performance enhancements.
Selectable mimics the Windows file / directory behaviour, i.e. click and / or drag to select items, hold CTRL to select multiple or hold SHIFT to select consecutive groups of items.
bower install mobius1-selectable --save
npm install mobius1-selectable --save
Grab the files from one of the CDNs and include them in your page:
https://unpkg.com/mobius1-selectable@latest/selectable.min.js
//or
https://cdn.jsdelivr.net/npm/mobius1-selectable@latest/selectable.min.js
You can replace latest
with the required release number if needed.
Initialise the plugin:
const selectable = new Selectable(options);
Option | Type | Default | Required | Effect |
---|---|---|---|---|
filter | string or array | "*" | ✔ | The elements that can be selected. You can pass either a CSS3 selector string or a collection of nodes. |
appendTo | string or object | document.body | ✖ | The container element to append the lasso to. |
tolerance | string | touch | ✖ | How far the lasso overlaps an element before it's highlighted. "fit" (lasso overlaps the item entirely) or "touch" (lasso overlaps the item by any amount). |
autoRefresh | boolean | true | ✖ | Recalculate the coords of the items. Set to false if you know the selectable items won't move or change size. |
lasso | object | ✖ | Style the lasso. Must be an object of valid CSS declarations. Demo |
Destroy the instance. This will return the DOM to it's initial state before initialsing.
Initialise the instance after destroying.
Disable the instance. Removes all event listeners to prevent further selection / deselection.
Enable the instance.
Updates the instance.
Can be used if new items are added or old ones removed. All item coords are updated as well.
Recalculates the coords for all valid items.
If the dimensions of the item / items change then call this method otherwise the lasso will not select items correctly.
Select an item.
Deselect an item.
Select all valid items.
Deselects all valid items.
// Intitialise Selectable
const selectable = new Selectable(options);
// Listen for the 'selectable.XXXX' event
selectable.on('selectable.XXXX', function() {
// Do something when 'selectable.XXXX' fires
});
selectable.down
fires on mousedown (within container)selectable.drag
fires when dragging the lassoselectable.up
fires on mouse up (within container)selectable.selected
fires on each element selected/**
* @param item - the first item selected
* @return {object}
*/
selectable.on('selectable.down', function(item) {
// Do something when selectable.down fires
});
/**
* @param coords - lasso coords (x1, x2, y1, y2)
* @return {object}
*/
selectable.on('selectable.drag', function(coords) {
// Do something when selectable.drag fires
});
/**
* @param selectedItems - returns an array of selected items (objects)
* @return {array}
*/
selectable.on('selectable.up', function(selectedItems) {
// Do something when selectable.up fires
});
/**
* @param item - the selected item (fires for each item that is selected)
* @return {object}
*/
selectable.on('selectable.selected', function(item) {
// Do something when selectable.selected fires
});
Note that items returned by these events are objects of the following format:
{
element: HTMLElement, // the element
index: Number, // the position of the item in the list
rect: DOMRect Object, // the element's bounding rects
startselected: Boolean,
selected: Boolean, // is the item currently selected
selecting: Boolean, // is the item currently being selected
unselecting: Boolean // is the item currently being deselected
}
Copyright © 2017 Karl Saunders | BSD & MIT license
FAQs
UI Selectable plugin without the bloat of jQuery and jQuery UI.
We found that mobius1-selectable 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.