Skip to content

Commit

Permalink
feat: possibility to disable active state
Browse files Browse the repository at this point in the history
  • Loading branch information
Drafteed committed May 17, 2022
1 parent 0ba61df commit 36d99b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const cursor = new MouseFollower({
| `hiddenState` | `string` | Hidden class name state. |
| `textState` | `string` | Text class name state. |
| `iconState` | `string` | Icon class name state. |
| `activeState` | `string` | Active (mousedown) class name state. |
| `activeState` | `string` | `null` | Active (mousedown) class name state. Set `false` to disable. |
| `mediaState` | `string` | Media (image/video) class name state. |
| `visible` | `boolean` | Is cursor visible by default. |
| `visibleOnState` | `boolean` | Automatically show/hide cursor when state added. Can be useful when implementing a hidden cursor follower. |
Expand Down
8 changes: 5 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class MouseFollower {
* @param {string} options.hiddenState Hidden state name.
* @param {string} options.textState Text state name.
* @param {string} options.iconState Icon state name.
* @param {string} options.activeState Active (mousedown) state name.
* @param {string|null} options.activeState Active (mousedown) state name. Set false to disable.
* @param {string} options.mediaState Media (image/video) state name.
* @param {object} options.stateDetection State detection rules.
* @param {boolean} options.visible Is cursor visible by default.
Expand Down Expand Up @@ -232,8 +232,10 @@ export default class MouseFollower {
if (this.options.visible) {
this.container.addEventListener('mouseenter', this.event.mouseenter, {passive: true});
}
this.container.addEventListener('mousedown', this.event.mousedown, {passive: true});
this.container.addEventListener('mouseup', this.event.mouseup, {passive: true});
if (this.options.activeState) {
this.container.addEventListener('mousedown', this.event.mousedown, {passive: true});
this.container.addEventListener('mouseup', this.event.mouseup, {passive: true});
}
this.container.addEventListener('mousemove', this.event.mousemove, {passive: true});
if (this.options.visible) {
this.container.addEventListener('mousemove', this.event.mousemoveOnce, {
Expand Down

0 comments on commit 36d99b4

Please sign in to comment.