Light library to handle the clicks over DOM element with javascript easily.
If you want you can use other npm manager such as yarn, pnpm...
npm install clickometer
<script async src="https://unpkg.com/clickometer@3.0.0/dist/clickometer.browser.min.js">
import clickometer from "clickometer"
clickometer({
DOMElement: document,
maxClicks: 5,
timeInterval: 1000,
onChange: ({ percentatge }) => {
document.body.style.backgroundColor = "initial";
document.body.innerHTML = percentatge + "%";
},
onExceeded: ({ percentatge }) => {
document.body.style.backgroundColor = "red";
document.body.innerHTML = `¡Cuidado!, ${percentatge}% completado`;
},
});
Type: HTMLElement
Default: document.body
Type: number
Default: 5
Type: number
Default: 1000
Type: Function
Default: () => {}
Type: Function
Default: () => {}
Type: Array
Default: []