Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset option to support dispatching onOut event when removing #33

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v10.24.0
Copy link
Author

@seriouslysean seriouslysean Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows switching to the correct node version with something like nvm use or n auto.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ has slowed down enough.

// Remove hoverintent listeners
hoverListener.remove();

// Remove hoverintent and fire the out handler
hoverListener.remove(true);
Comment on lines +53 to +54
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure this was the right place for it, but wanted to show a real world usage. If this is intended as a snippet that can be copy/pasted, might be worth moving this to a different location.

</script>
```

Expand Down
2 changes: 1 addition & 1 deletion dist/hoverintent.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ module.exports = function(el, onOver, onOut) {
el.removeEventListener('blur', dispatchBlur, false);
}

h.remove = function() {
h.remove = function(reset) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New param; if this is true the mouse out event will fire before removing the event listeners.

if (!el) return;
if (reset === true) {
state = 1;
dispatchOut();
}
el.removeEventListener('mouseover', dispatchOver, false);
el.removeEventListener('mouseout', dispatchOut, false);
removeFocus();
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "2.2.1",
"repository": "[email protected]:tristen/hoverintent.git",
"description": "Fire mouse events when the user intends it",
"engine-strict": true,
"engines": {
"node": "^10.0.0"
},
Comment on lines +6 to +9
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will require the correct node version so that the build script runs properly.

"main": "index.js",
"scripts": {
"build": "babel index.js | uglifyjs -mc > dist/hoverintent.min.js"
Expand Down