Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useElementBounding): trigger by css or style #3664

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Alfred-Skyblue marked this conversation as resolved.
Show resolved Hide resolved
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