diff --git a/README.MD b/README.MD index 7bf9c47..a02501e 100644 --- a/README.MD +++ b/README.MD @@ -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. | diff --git a/src/index.js b/src/index.js index c65293f..43e4a42 100644 --- a/src/index.js +++ b/src/index.js @@ -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. @@ -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, {