From e1c4efb0ff031ad6cb677acee260d572ee75e922 Mon Sep 17 00:00:00 2001 From: Marshall Thompson Date: Tue, 19 Dec 2023 19:42:46 -0700 Subject: [PATCH] feat: allow useAutoAnimate with Vue component ref This adds support for using `useAutoAnimate` with a component as the parent. When you add `ref="parent"` to a component, the element is found at `parent.value.$el`. This update checks for component elements or a plain HTML element ref. --- src/vue/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vue/index.ts b/src/vue/index.ts index 1471a01..8cd215d 100644 --- a/src/vue/index.ts +++ b/src/vue/index.ts @@ -36,8 +36,9 @@ export function useAutoAnimate( } onMounted(() => { watchEffect(() => { - if (element.value instanceof HTMLElement) - controller = autoAnimate(element.value, options || {}) + const el = element.value?.$el || element.value + if (el instanceof HTMLElement) + controller = autoAnimate(el, options || {}) }) })