From 70dbd65d811a9970b08299cddaeb0f1a3b223ff6 Mon Sep 17 00:00:00 2001 From: huiliangShen Date: Wed, 27 Dec 2023 22:09:58 +0800 Subject: [PATCH] fix(useElementBounding): trigger by css or style (#3664) --- packages/core/useElementBounding/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/core/useElementBounding/index.ts b/packages/core/useElementBounding/index.ts index 18c6c30dbdc..d336255d232 100644 --- a/packages/core/useElementBounding/index.ts +++ b/packages/core/useElementBounding/index.ts @@ -4,6 +4,7 @@ import { useEventListener } from '../useEventListener' import type { MaybeComputedElementRef } from '../unrefElement' import { unrefElement } from '../unrefElement' import { useResizeObserver } from '../useResizeObserver' +import { useMutationObserver } from '../useMutationObserver' export interface UseElementBoundingOptions { /** @@ -91,6 +92,10 @@ export function useElementBounding( useResizeObserver(target, update) watch(() => unrefElement(target), ele => !ele && update()) + // trigger by css or style + useMutationObserver(target, update, { + attributeFilter: ['style', 'class'], + }) if (windowScroll) useEventListener('scroll', update, { capture: true, passive: true })