Skip to content

Commit

Permalink
fix: v-motion directive variants leaking
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Feb 21, 2024
1 parent 641dca9 commit 352333d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/directive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useMotion } from '../useMotion'
import { resolveVariants } from '../utils/directive'
import { variantToStyle } from '../utils/transform'

export function directive<T extends string>(variants: MotionVariants<T> = {}): Directive<HTMLElement | SVGElement> {
export function directive<T extends string>(variants?: MotionVariants<T>): Directive<HTMLElement | SVGElement> {
const register = (el: HTMLElement | SVGElement, binding: DirectiveBinding, node: VNode<any, HTMLElement | SVGElement, Record<string, any>>) => {
// Get instance key if possible (binding value or element key in case of v-for's)
const key = (binding.value && typeof binding.value === 'string' ? binding.value : node.key) as string
Expand All @@ -16,7 +16,7 @@ export function directive<T extends string>(variants: MotionVariants<T> = {}): D
if (key && motionState[key]) motionState[key].stop()

// Initialize variants with argument
const variantsRef = ref(variants) as Ref<MotionVariants<T>>
const variantsRef = ref(variants || {}) as Ref<MotionVariants<T>>

// Set variants from v-motion binding
if (typeof binding.value === 'object') variantsRef.value = binding.value
Expand Down

0 comments on commit 352333d

Please sign in to comment.