From f613046043d8b98ddb1905b20d91287a9b7676c8 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 5 Sep 2022 21:27:26 +0800 Subject: [PATCH] chore: formatting --- packages/core/useElementSize/demo.vue | 10 +++++++--- packages/core/useElementSize/index.ts | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/core/useElementSize/demo.vue b/packages/core/useElementSize/demo.vue index 847df27c648..14a76688696 100644 --- a/packages/core/useElementSize/demo.vue +++ b/packages/core/useElementSize/demo.vue @@ -4,9 +4,13 @@ import { stringify } from '@vueuse/docs-utils' import { useElementSize } from '@vueuse/core' const el = ref(null) -const size = reactive(useElementSize(el, { width: 0, height: 0 }, { - box: 'border-box', -})) +const size = reactive( + useElementSize( + el, + { width: 0, height: 0 }, + { box: 'border-box' }, + ), +) const text = stringify(size) diff --git a/packages/core/useElementSize/index.ts b/packages/core/useElementSize/index.ts index 9b2915bd287..32d313dffd5 100644 --- a/packages/core/useElementSize/index.ts +++ b/packages/core/useElementSize/index.ts @@ -31,7 +31,9 @@ export function useElementSize( ([entry]) => { const boxSize = box === 'border-box' ? entry.borderBoxSize - : (box === 'content-box' ? entry.contentBoxSize : entry.devicePixelContentBoxSize) + : box === 'content-box' + ? entry.contentBoxSize + : entry.devicePixelContentBoxSize if (boxSize) { width.value = boxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0) @@ -45,10 +47,15 @@ export function useElementSize( }, options, ) - watch(() => unrefElement(target), (ele) => { - width.value = ele ? initialSize.width : 0 - height.value = ele ? initialSize.height : 0 - }) + + watch( + () => unrefElement(target), + (ele) => { + width.value = ele ? initialSize.width : 0 + height.value = ele ? initialSize.height : 0 + }, + ) + return { width, height,