Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(usePointer): suppor target and isInside flag
- Loading branch information
Showing
3 changed files
with
38 additions
and
8 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,17 +1,25 @@ | ||
import { defineComponent, reactive } from 'vue-demi' | ||
import { defineComponent, reactive, ref } from 'vue-demi' | ||
import { usePointer, UsePointerOptions } from '@vueuse/core' | ||
import { defaultWindow } from '../_configurable' | ||
|
||
export const UsePointer = defineComponent<UsePointerOptions>({ | ||
export const UsePointer = defineComponent<Omit<UsePointerOptions, 'target'> & { target: 'window' | 'self' }>({ | ||
name: 'UsePointer', | ||
props: [ | ||
'pointerTypes', | ||
'initialValue', | ||
'target', | ||
] as unknown as undefined, | ||
setup(props, { slots }) { | ||
const data = reactive(usePointer(props)) | ||
const el = ref<HTMLElement | null>(null) | ||
|
||
const data = reactive(usePointer({ | ||
...props, | ||
target: props.target === 'self' ? el : defaultWindow, | ||
})) | ||
|
||
return () => { | ||
if (slots.default) | ||
return slots.default(data) | ||
return slots.default(data, { ref: el }) | ||
} | ||
}, | ||
}) |
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