8000 feat(useElementSize): stop function (#3367) · vueuse/vueuse@5f545be · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 8000 5f545be

Browse files
chaii3antfu
andauthored
feat(useElementSize): stop function (#3367)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
1 parent dc6f2e8 commit 5f545be

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/core/useElementSize/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function useElementSize(
2525
const width = ref(initialSize.width)
2626
const height = ref(initialSize.height)
2727

28-
useResizeObserver(
28+
const { stop: stop1 } = useResizeObserver(
2929
target,
3030
([entry]) => {
3131
const boxSize = box === 'border-box'
@@ -58,17 +58,23 @@ export function useElementSize(
5858
options,
5959
)
6060

61-
watch(
61+
const stop2 = watch(
6262
() => unrefElement(target),
6363
(ele) => {
6464
width.value = ele ? initialSize.width : 0
6565
height.value = ele ? initialSize.height : 0
6666
},
6767
)
6868

69+
function stop() {
70+
stop1()
71+
stop2()
72+
}
73+
6974
return {
7075
width,
7176
height,
77+
stop,
7278
}
7379
}
7480

0 commit comments

Comments
 (0)
0