Skip to content

Commit

Permalink
fix(useElementBounding): trigger by css or style (#3664)
Browse files Browse the repository at this point in the history
  • Loading branch information
huiliangShen committed Dec 27, 2023
1 parent 361ff73 commit 70dbd65
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/useElementBounding/index.ts
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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 })
Expand Down

0 comments on commit 70dbd65

Please sign in to comment.