Skip to content

Commit

Permalink
refactor(animation-factory): improve type infer
Browse files Browse the repository at this point in the history
  • Loading branch information
victorcg88 committed Aug 5, 2024
1 parent 5dbaeec commit 77f4320
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineComponent, h, Transition } from 'vue';
import { DefineComponent, defineComponent, h, Transition } from 'vue';

export type AnimationOrigin =
| 'top'
Expand All @@ -21,18 +21,16 @@ export type AnimationOrigin =
*/
export function createDirectionalAnimationFactory(
animationName: string
): ReturnType<typeof defineComponent> {
return (animationOrigin: AnimationOrigin = 'top') =>
): (animationOrigin?: AnimationOrigin) => DefineComponent {
return (animationOrigin = 'top') =>
defineComponent({
name: `transition-${animationName}-${animationOrigin}`,
inheritAttrs: false,
setup(_, { attrs, slots }) {
setup(_, { slots }) {
return () =>
h(
Transition,
{
name: `x-${animationName}--${animationOrigin} x-${animationName}-`,
...attrs
name: `x-${animationName}--${animationOrigin} x-${animationName}-`
},
// Vue recommends using function for better performance.
() => slots.default?.() ?? ''
Expand Down

0 comments on commit 77f4320

Please sign in to comment.