|
10 | 10 |
|
11 | 11 | <script lang="ts"> |
12 | 12 | import Vue, {PropType} from 'vue'; |
13 | | - import {TransitionOptions} from '@/lib/types'; |
| 13 | + import {AnimationOptions, TransitionOptions} from '@/lib/types'; |
14 | 14 |
|
15 | 15 | interface TransitionType extends Partial<TransitionOptions> { |
16 | | - name: 'fade'|string|null, |
| 16 | + name: 'fade'|'blur'|'scale'|'slide'|'fly'|string|null, |
17 | 17 | hooks?: any, |
18 | 18 | options: { |
19 | 19 | appear?: boolean, |
|
30 | 30 | default: null, |
31 | 31 | }, |
32 | 32 |
|
33 | | - options: Object as PropType<TransitionOptions>, |
| 33 | + /** |
| 34 | + * Following properties are well-explained in the official Vue documentation: |
| 35 | + * https://vuejs.org/v2/guide/transitions.html#Transition-Modes |
| 36 | + * |
| 37 | + * Shortly: |
| 38 | + * * Appear – show transition on initial Transition mount |
| 39 | + * * Mode – how to switch between if-else_if-else components. Supported: in-out, out-in |
| 40 | + */ |
| 41 | + appear: { |
| 42 | + type: Boolean, |
| 43 | + default: false, |
| 44 | + }, |
| 45 | + mode: { |
| 46 | + type: String as PropType<'in-out'|'out-in'|null>, |
| 47 | + default: null, |
| 48 | + }, |
| 49 | +
|
| 50 | + /** |
| 51 | + * Animation object to configure such properties as: |
| 52 | + * delay, duration, type (only in or only out), easing etc. |
| 53 | + */ |
| 54 | + animation: { |
| 55 | + type: Object as PropType<AnimationOptions>, |
| 56 | + default: null, |
| 57 | + }, |
34 | 58 | }, |
35 | 59 | computed: { |
36 | 60 | transition (): TransitionType { |
|
47 | 71 | } else { |
48 | 72 | return { |
49 | 73 | ...transition, |
50 | | - animation: this.options?.animation || transition.animation, |
| 74 | + animation: {...transition.animation, ...this.animation}, |
51 | 75 | options: { |
52 | | - appear: !!this.options?.appear, |
53 | | - mode: this.options?.mode || null, |
54 | | - css: !this.options?.animation, |
| 76 | + appear: this.appear, |
| 77 | + mode: this.mode || null, |
| 78 | + css: !this.animation, |
55 | 79 | }, |
56 | 80 | }; |
57 | 81 | } |
58 | 82 | }, |
| 83 | +
|
| 84 | + /** |
| 85 | + * Transition hooks are JS-functions that are mapped as events. They draw the animation |
| 86 | + */ |
59 | 87 | hooks () { |
60 | 88 | const hooks = this.transition?.hooks; |
61 | 89 | const newHooks: any = {}; |
|
0 commit comments