Skip to content

Commit

Permalink
feat: useMouse supports drag and drop (#592)
Browse files Browse the repository at this point in the history
- Adds the `dragover` event to continue to track mouse position while dragging.
  • Loading branch information
marshallswain committed Jul 5, 2021
1 parent 8232036 commit bd745c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/useMouse/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { useMouse } from '@vueuse/core'
const { x, y, source } = useMouse()
```

Touching is enabled by default. To make it only detects mouse changes, set `touch` to `false`
Touch is enabled by default. To only detect mouse changes, set `touch` to `false`.
The `dragover` event is used to track mouse position while dragging.

```js
const { x, y } = useMouse({ touch: false })
Expand Down
1 change: 1 addition & 0 deletions packages/core/useMouse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function useMouse(options: MouseOptions = {}) {

if (window) {
useEventListener(window, 'mousemove', mouseHandler, { passive: true })
useEventListener(window, 'dragover', mouseHandler, { passive: true })
if (touch) {
useEventListener(window, 'touchstart', touchHandler, { passive: true })
useEventListener(window, 'touchmove', touchHandler, { passive: true })
Expand Down

0 comments on commit bd745c8

Please sign in to comment.