{"_id":"sv-hover-intent","_rev":"1-59625f9b22a43935084cfdd6e03d99f3","name":"sv-hover-intent","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"sv-hover-intent","version":"1.0.0","description":"A JavaScript library for handling mouse hovers on a delay, when the user intends to hover the element.","main":"src/sv-hover-intent.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/svivian/sv-hover-intent-js.git"},"keywords":["javascript","hover","hoverintent","usability"],"author":{"name":"Scott Vivian"},"license":"MIT","bugs":{"url":"https://github.com/svivian/sv-hover-intent-js/issues"},"homepage":"https://github.com/svivian/sv-hover-intent-js#readme","_id":"sv-hover-intent@1.0.0","gitHead":"c1e95da1dd1b42194b0200978e9ace63036531f7","_nodeVersion":"21.7.1","_npmVersion":"10.5.0","dist":{"integrity":"sha512-OPgFXrKcoecuMHSVwOB0t4fB+TV8gHZZOr3P36/rSHZquwaesU5AMKfutPymgTXQSCYDU5MCgRF2AAWWZhm4Rw==","shasum":"d60b27dfb3cbd54d083cdca0762cce6176596bbb","tarball":"https://registry.npmjs.org/sv-hover-intent/-/sv-hover-intent-1.0.0.tgz","fileCount":6,"unpackedSize":10090,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD73IcRPOfhHJHXlhAxiNQpBlXbyyGtQERpyhS5bZSE/AIhAI0XJSbYVtbB7jgCrcZ+uKjRbWFKr7yVLbKi2jE9nlew"}]},"_npmUser":{"name":"svivian","email":"scott.vivian@gmail.com"},"directories":{},"maintainers":[{"name":"svivian","email":"scott.vivian@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sv-hover-intent_1.0.0_1714777043608_0.5926234645329227"},"_hasShrinkwrap":false},"1.0.1":{"name":"sv-hover-intent","version":"1.0.1","description":"A JavaScript library for handling mouse hovers on a delay, when the user intends to hover the element.","main":"src/sv-hover-intent.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/svivian/sv-hover-intent-js.git"},"keywords":["javascript","hover","hoverintent","usability"],"author":{"name":"Scott Vivian"},"license":"MIT","bugs":{"url":"https://github.com/svivian/sv-hover-intent-js/issues"},"homepage":"https://github.com/svivian/sv-hover-intent-js#readme","_id":"sv-hover-intent@1.0.1","gitHead":"e1824ee6b37cfcb30d687ec55764b610d150862d","_nodeVersion":"21.7.1","_npmVersion":"10.5.0","dist":{"integrity":"sha512-9sl/wFj5fI+DQUTrNjfTP6eEH7U/lodZ1fwQQlOxL7tFDZq0chXoO3G3kl87qGHnWXtSzaFjpuIpZFo0EWm6SA==","shasum":"6e3e23fc1967b042553b06c42e1e0eea051815ad","tarball":"https://registry.npmjs.org/sv-hover-intent/-/sv-hover-intent-1.0.1.tgz","fileCount":6,"unpackedSize":11427,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCELxPLwR6HDnYeTq+gKAGvXzeTnGYUKBtVCH00Pb1e7gIhAMk0yNv9Kxs2ffHFLuITfRX8I5SgLmNgm08H4WRf3xI2"}]},"_npmUser":{"name":"svivian","email":"scott.vivian@gmail.com"},"directories":{},"maintainers":[{"name":"svivian","email":"scott.vivian@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sv-hover-intent_1.0.1_1715016744996_0.7953695487282451"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-03T22:57:23.607Z","1.0.0":"2024-05-03T22:57:23.753Z","modified":"2024-05-06T17:32:25.325Z","1.0.1":"2024-05-06T17:32:25.152Z"},"maintainers":[{"name":"svivian","email":"scott.vivian@gmail.com"}],"description":"A JavaScript library for handling mouse hovers on a delay, when the user intends to hover the element.","homepage":"https://github.com/svivian/sv-hover-intent-js#readme","keywords":["javascript","hover","hoverintent","usability"],"repository":{"type":"git","url":"git+https://github.com/svivian/sv-hover-intent-js.git"},"author":{"name":"Scott Vivian"},"bugs":{"url":"https://github.com/svivian/sv-hover-intent-js/issues"},"license":"MIT","readme":"SV-HoverIntent\n=================================================\n\n**sv-hover-intent-js** is a JavaScript plugin for handling mouse hovers on a delay. It tracks when the mouse movement has slowed enough that it's likely the user *intended* to activate that element.\n\nIt's useful for things like dropdown menus, to avoid them popping out if you happen to move past them (for example, when closing the browser tab). See `demo/example.html` for an example. This is essentially a vanilla JavaScript port of the excellent [jQuery-hoverIntent](https://github.com/briancherne/jquery-hoverIntent) plugin by Brian Cherne, though it has been rewritten from the ground up.\n\n\n## Installation\n\nSV-HoverIntent can be installed via npm:\n\n```sh\nnpm install sv-hover-intent\n```\n\nThen use the file `node_modules/sv-hover-intent/src/sv-hover-intent.js` in your project - either directly in a `<script>` tag, or passing into your bundler/task runner.\n\nAlternatively, you can download or link to a minified version via [jsDelivr](https://www.jsdelivr.com/package/npm/sv-hover-intent).\n\n\n## Usage\n\nAfter adding the library script, call `new SV.HoverIntent` with an array or NodeList of the items you wish to apply it to (such as those returned by `document.querySelectorAll`), and an object containing the options. They are:\n\n- `onEnter` - (required) a callback to execute when hover is activated\n- `onExit` - (required) a callback to exexute when the mouse moves off the element\n- `exitDelay` - (optional) time in milliseconds to delay the exit function; useful for a dropdown menu if the user overshoots slightly\n- `interval` - (optional) polling interval for mouse tracking; only change this if you know what you're doing!\n- `sensitivity` - (optional) distance in pixels per `interval`, below which the hover will activate; only change this if you know what you're doing!\n\nHere's a simple example, which adds and removes a \"visible\" class to a menu:\n\n```js\n// get top-level items from a dropdown menu\nconst menuItems = document.querySelectorAll('.menu-item');\n\n// set actions for mouse over and mouse leave\nnew SV.HoverIntent(menuItems, {\n\t// required parameters\n\tonEnter: function(targetItem) {\n\t\ttargetItem.classList.add('visible');\n\t},\n\tonExit: function(targetItem) {\n\t\ttargetItem.classList.remove('visible');\n\t},\n\n\t// default options\n\texitDelay: 400,\n\tinterval: 100,\n\tsensitivity: 7,\n});\n```\n","readmeFilename":"README.md"}