Skip to content

Commit

Permalink
fix: v-motion directive variants leaking (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Feb 21, 2024
1 parent eddd121 commit 76ff6c9
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 @@ -8,7 +8,7 @@ import { resolveVariants } from '../utils/directive'
import { variantToStyle } from '../utils/transform'
import { registerVisibilityHooks } from '../features/visibilityHooks'

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 @@ -17,7 +17,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 76ff6c9

Please sign in to comment.