Skip to content

Commit

Permalink
feat(useMouse): support type: screen (#2467)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoislevesque committed Apr 13, 2023
1 parent edece1a commit 39d1832
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/core/useMouse/index.ts
Expand Up @@ -7,11 +7,11 @@ import type { Position } from '../types'

export interface UseMouseOptions extends ConfigurableWindow, ConfigurableEventFilter {
/**
* Mouse position based by page, client, or relative to previous position
* Mouse position based by page, client, screen, or relative to previous position
*
* @default 'page'
*/
type?: 'page' | 'client' | 'movement'
type?: 'page' | 'client' | 'screen' | 'movement'

/**
* Listen to `touchmove` events
Expand Down Expand Up @@ -64,6 +64,10 @@ export function useMouse(options: UseMouseOptions = {}) {
x.value = event.clientX
y.value = event.clientY
}
else if (type === 'screen') {
x.value = event.screenX
y.value = event.screenY
}
else if (type === 'movement') {
x.value = event.movementX
y.value = event.movementY
Expand All @@ -85,6 +89,10 @@ export function useMouse(options: UseMouseOptions = {}) {
x.value = touch.clientX
y.value = touch.clientY
}
else if (type === 'screen') {
x.value = touch.screenX
y.value = touch.screenY
}
sourceType.value = 'touch'
}
}
Expand Down

0 comments on commit 39d1832

Please sign in to comment.