-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(useMouse): add
target
option and type
enhancement
fix
- Loading branch information
Showing
3 changed files
with
96 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
<script setup lang="ts"> | ||
import { reactive } from 'vue' | ||
import { stringify } from '@vueuse/docs-utils' | ||
import { useMouse } from '@vueuse/core' | ||
import { type UseMouseExtractFn, useMouse, useParentElement } from '@vueuse/core' | ||
const mouse = reactive(useMouse()) | ||
const text = stringify(mouse) | ||
const parentEl = useParentElement() | ||
const mouseDefault = reactive(useMouse()) | ||
const textDefault = stringify(mouseDefault) | ||
const extractor: UseMouseExtractFn = event => ( | ||
event instanceof Touch | ||
? null | ||
: { x: event.offsetX, y: event.offsetY } | ||
) | ||
const mouseWithExtractor = reactive(useMouse({ target: parentEl, type: extractor })) | ||
const textWithExtractor = stringify(mouseWithExtractor) | ||
</script> | ||
|
||
<template> | ||
<pre lang="yaml">{{ text }}</pre> | ||
<p>Basic Usage</p> | ||
<pre lang="yaml">{{ textDefault }}</pre> | ||
<p>Extractor Usage</p> | ||
<pre lang="yaml">{{ textWithExtractor }}</pre> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters