Gathering detailed insights and metrics for clickout-event
Gathering detailed insights and metrics for clickout-event
Gathering detailed insights and metrics for clickout-event
Gathering detailed insights and metrics for clickout-event
Provides universal support for clickout and other similar events to webpages.
npm install clickout-event
Typescript
Module System
Node Version
NPM Version
91.1
Supply Chain
93.4
Quality
76.4
Maintenance
100
Vulnerability
100
License
TypeScript (44.12%)
JavaScript (31.62%)
HTML (24.26%)
Total Downloads
135,978
Last Day
523
Last Week
3,937
Last Month
14,701
Last Year
47,799
MIT License
18 Stars
18 Commits
2 Forks
1 Watchers
1 Branches
2 Contributors
Updated on Apr 11, 2025
Minified
Minified + Gzipped
Latest Version
1.1.3
Package Id
clickout-event@1.1.3
Unpacked Size
8.66 kB
Size
4.22 kB
File Count
4
NPM Version
10.8.2
Node Version
20.18.2
Published on
Feb 16, 2025
Cumulative downloads
Total Downloads
Last Day
-42%
523
Compared to previous day
Last Week
-23.4%
3,937
Compared to previous week
Last Month
101.3%
14,701
Compared to previous month
Last Year
27.6%
47,799
Compared to previous year
5
Provides universal support for
clickout
and other similar events to any front-end frameworks.
There are many packages that are designed to capture and handle the "click outside" event of an element. Some of them target vanilla JavaScript, while some others target specific front-end framework, possibly specific version. Front-end designers in the past had to look for the right package that works for their particular scenario.
Look no further! Introducing Clickout-Event,
a package that provides universal support for clickout
and other similar events.
It works in all scenarios: plain HTML onclickout
attributes,
.addEventListener('clickout')
of vanilla JavaScript,
.on('clickout')
of jQuery, v-on:clickout
directives of Vue.js, you name it.
As long as a front-end framework internally uses addEventListener
to handle events,
Clickout-Event works for it.
MIT License
In order to fully implement all native event behaviors, Clickout-Event uses the mutation observer API, so it will not work directly for legacy browsers. You may try using polyfills to make it work, but I haven't tested those yet.
You can get Clickout-Event as an NPM package by running:
1npm install clickout-event --save
Then add one of the following lines to your entry script:
1require('clickout-event'); 2// or 3import 'clickout-event';
And watch the magic happen.
Simply download clickout-event.js
.
Then all you need to do is add the script tag anywhere (as long as it is before any calling of the addEventListener
method, such as the beginning of the <head>
section) in your HTML file:
1<script src="clickout-event.js"></script>
Clickout-Event provides the corresponding "out-events" for the following events: click
, dblclick
, mousedown
, mouseup
, touchstart
, touchend
, pointerdown
and pointerup
. The corresponding events are then called clickout
, dblclickout
etc. You can then use them the same way you use any other events; see examples below.
Note that pointer events is not supported in Safari.
With each out-event, you can use event.relatedTarget
to find out exactly which element fires the original event (that is, the element being clicked etc.).
1<div onclickout="console.log('clickout detected')">...</div>
1document.getElementById('myId').addEventListener('clickout', myListener);
1$('#myId').on('clickout', myListener);
1<div v-on:clickout="open=false">...</div>
1<div (clickout)="close()">...</div>
Some frameworks (such as React and Blazor)
have a fixed list of events that are supported by their event attribute syntax,
so you cannot directly use their event attributes with out-events
(or with any custom events for that matter) in their templates.
Still, you can create custom components in these frameworks and use the vanilla
addEventListener()
method to register event listener.
You can have nested elements using the out-events. In that case,
unlike regular events, out-events fire in the top-down ordering;
that is, the parent element will fire the event first,
and then will the child elements.
Similarly, when calling event.stopPropagation()
(or, for example, using v-on:clickout.stop
in Vue.js) on the out-events,
it will be the parent element stopping the child element from firing the event.
By design, even if the propagation of the original event is stopped, the corresponding out-event will still fire regardlessly.
Feel free to add or remove elements dynamically! Clickout-Event monitors changes to the document, and will ensure the out-events work no matter which dynamic front-end framework you're using.
When using inline event attributes,
Clickout-Event is subject to the same CSP restriction as any other events;
that is, 'unsafe-inline'
must be allowed. Now Clickout-Event uses
native mechanisms instead of eval-like methods to parse the attribute,
so you don't need to allow 'unsafe-eval'
.
Since out-events are synthetic events,
they are untrusted (that is, event.isTrusted == false
) by nature,
and your event listener is not supposed to reject the event because of this.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/17 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
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