Skip to content

Commit 0791f61

Browse files
committed
chore: update getMotionElement return type
1 parent d133b56 commit 0791f61

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

packages/motion/src/components/hooks/use-motion-elm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getCurrentInstance, onMounted } from 'vue'
66
* @param el - The HTML element to check
77
* @returns The first non-text/comment element
88
*/
9-
export function getMotionElement(el: HTMLElement | SVGElement | null): HTMLElement | SVGElement | null {
9+
export function getMotionElement(el: HTMLElement | SVGElement | null): HTMLElement | SVGElement | undefined {
1010
if (!el)
1111
return undefined
1212

packages/motion/src/value/use-scroll.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { unref, watchEffect } from 'vue'
22
import { motionValue, scroll } from 'framer-motion/dom'
33
import type { ScrollInfoOptions } from '@/types'
44
import { isSSR } from '@/utils/is'
5-
import type { MaybeComputedElementRef, MaybeRef } from '@vueuse/core'
5+
import type { MaybeComputedElementRef } from '@vueuse/core'
66
import { getElement } from '@/components/hooks/use-motion-elm'
77
import type { ToRefs } from '@/types/common'
88

@@ -19,14 +19,13 @@ function createScrollMotionValues() {
1919
scrollYProgress: motionValue(0),
2020
}
2121
}
22-
export function useScroll(scrollOptions: MaybeRef<UseScrollOptions> = {}) {
22+
export function useScroll(scrollOptions: UseScrollOptions = {}) {
2323
const values = createScrollMotionValues()
2424

2525
watchEffect((onCleanup) => {
2626
if (isSSR) {
2727
return
2828
}
29-
const options = unref(scrollOptions)
3029
const cleanup = scroll(
3130
(_progress, { x, y }) => {
3231
values.scrollX.set(x.current)
@@ -35,10 +34,10 @@ export function useScroll(scrollOptions: MaybeRef<UseScrollOptions> = {}) {
3534
values.scrollYProgress.set(y.progress)
3635
},
3736
{
38-
offset: unref(options.offset),
39-
axis: unref(options.axis),
40-
container: getElement(options.container),
41-
target: getElement(options.target),
37+
offset: unref(scrollOptions.offset),
38+
axis: unref(scrollOptions.axis),
39+
container: getElement(scrollOptions.container),
40+
target: getElement(scrollOptions.target),
4241
},
4342
)
4443
onCleanup(() => {

0 commit comments

Comments
 (0)