Installations
npm install @tellery/viselect-vanilla
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.20.1
NPM Version
6.14.10
Score
73.6
Supply Chain
98.9
Quality
77.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (80.84%)
CSS (9.88%)
Vue (4.71%)
HTML (2.51%)
JavaScript (2.06%)
Developer
Download Statistics
Total Downloads
1,903
Last Day
1
Last Week
4
Last Month
14
Last Year
128
GitHub Statistics
2,723 Stars
510 Commits
150 Forks
25 Watching
5 Branches
26 Contributors
Bundle Size
9.16 kB
Minified
3.72 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.0.0-beta.3
Package Id
@tellery/viselect-vanilla@3.0.0-beta.3
Unpacked Size
168.88 kB
Size
49.21 kB
File Count
19
NPM Version
6.14.10
Node Version
12.20.1
Total Downloads
Cumulative downloads
Total Downloads
1,903
Last day
0%
1
Compared to previous day
Last week
33.3%
4
Compared to previous week
Last month
40%
14
Compared to previous month
Last year
-42.1%
128
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Viselect - Vanilla
Installation
Via package manager
$ npm install @viselect/vanilla
# or
$ yarn add @viselect/vanilla
Via script tags
1 2<script src="https://cdn.jsdelivr.net/npm/@viselect/vanilla/lib/viselect.min.js"></script>
Via ES6 import
1import SelectionArea from "https://cdn.jsdelivr.net/npm/@viselect/vanilla/lib/viselect.min.mjs"
Getting started
Last but not least you'll need to add some basic styles to make your selection-area visible:
1.selection-area { 2 background: rgba(46, 115, 252, 0.11); 3 border: 2px solid rgba(98, 155, 255, 0.81); 4 border-radius: 0.1em; 5}
Additionally, to not interfere with text-selection, selection-js won't prevent any default events anymore (as of v2.0.3
). This however can cause problems with the actual
selection ("introduced" by #99, reported in #103). If you don't care about
text-selection, add the following to the container where all your selectables are located:
1.container { 2 user-select: none; 3}
Usage
1const selection = new SelectionArea({ 2 3 // Class for the selection-area itself (the element). 4 selectionAreaClass: 'selection-area', 5 6 // Class for the selection-area container. 7 selectionContainerClass: 'selection-area-container', 8 9 // Query selector or dom-node to set up container for the selection-area element. 10 container: 'body', 11 12 // document object - if you want to use it within an embed document (or iframe). 13 document: window.document, 14 15 // Query selectors for elements which can be selected. 16 selectables: [], 17 18 // Query selectors for elements from where a selection can be started from. 19 startareas: ['html'], 20 21 // Query selectors for elements which will be used as boundaries for the selection. 22 boundaries: ['html'], 23 24 // Behaviour related options. 25 behaviour: { 26 27 // Specifies what should be done if already selected elements get selected again. 28 // invert: Invert selection for elements which were already selected 29 // keep: Keep selected elements (use clearSelection() to remove those) 30 // drop: Remove stored elements after they have been touched 31 overlap: 'invert', 32 33 // On which point an element should be selected. 34 // Available modes are cover (cover the entire element), center (touch the center) or 35 // the default mode is touch (just touching it). 36 intersect: 'touch', 37 38 // px, how many pixels the point should move before starting the selection (combined distance). 39 // Or specifiy the threshold for each axis by passing an object like {x: <number>, y: <number>}. 40 startThreshold: 10, 41 42 // Scroll configuration. 43 scrolling: { 44 45 // On scrollable areas the number on px per frame is devided by this amount. 46 // Default is 10 to provide a enjoyable scroll experience. 47 speedDivider: 10, 48 49 // Browsers handle mouse-wheel events differently, this number will be used as 50 // numerator to calculate the mount of px while scrolling manually: manualScrollSpeed / scrollSpeedDivider. 51 manualSpeed: 750 52 } 53 }, 54 55 // Features. 56 features: { 57 58 // Enable / disable touch support. 59 touch: true, 60 61 // Range selection. 62 range: true, 63 64 // Configuration in case a selectable gets just clicked. 65 singleTap: { 66 67 // Enable single-click selection (Also disables range-selection via shift + ctrl). 68 allow: true, 69 70 // 'native' (element was mouse-event target) or 'touch' (element visually touched). 71 intersect: 'native' 72 } 73 } 74}); 75
Events
Use the on(event, cb)
and off(event, cb)
functions to bind / unbind event-listener.
Event | Description |
---|---|
beforestart | The user tapped one of the areas within the specified boundaries. Return false to cancel selection immediatly. |
start | Selection started, here you can decide if you want to keep your previously selected elements. |
move | Selection is active, user is moving the pointer around. |
stop | Selection has stopped. |
Example
1selection.on('beforestart', evt => { 2 3 // Use this event to decide whether a selection should take place or not. 4 // For example if the user should be able to normally interact with input-elements you 5 // may want to prevent a selection if the user clicks such a element: 6 // selection.on('beforestart', ({event}) => { 7 // return event.target.tagName !== 'INPUT'; // Returning false prevents a selection 8 // }); 9 10 console.log('beforestart', evt); 11}).on('start', evt => { 12 13 // A selection got initiated, you could now clear the previous selection or 14 // keep it if in case of multi-selection. 15 console.log('start', evt); 16}).on('move', evt => { 17 18 // Here you can update elements based on their state. 19 console.log('move', evt); 20}).on('stop', evt => { 21 22 // Do something with the selected elements. 23 console.log('stop', evt); 24});
Common recipes can be found under recipes.
No vulnerabilities found.
Reason
11 commit(s) and 3 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-8hc4-vh64-cxmj
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
Reason
Found 4/27 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/simonwep/selection/main.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/simonwep/selection/main.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/simonwep/selection/main.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/simonwep/selection/main.yml/master?enable=pin
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
4.3
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More