Skip to content

Commit 2441dde

Browse files
committed
Add effectReference transition option for the ease of customization
1 parent 468a0fe commit 2441dde

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/docs/config.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@ import {PartialConfig} from '@/lib/types/config';
22

33
const config: PartialConfig = {
44
globalClass: '',
5+
6+
transitions: {
7+
flyFade: {
8+
name: 'flyFade',
9+
effectReference: 'fly',
10+
animation: {
11+
x: 5,
12+
y: 5,
13+
duration: 200,
14+
},
15+
},
16+
},
17+
518
components: {
619
button: {
720
class: 'font-bold py-2 px-4 rounded outline-none',
@@ -12,7 +25,7 @@ const config: PartialConfig = {
1225
},
1326

1427
dropdown: {
15-
transition: null,
28+
transition: 'flyFade',
1629
isProperties: {
1730
multiselect: 'rounded border-solid border border-gray-300 py-2 px-4',
1831
search: 'rounded border-solid border border-gray-300',

src/lib/components/Transition.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,22 @@
6868
if (!this.name) return {name: '', animation: {}, options: {}};
6969
7070
const {transitions} = this.$iui;
71-
const transition = transitions[this.name];
71+
let transition = transitions[this.name];
7272
7373
if (!transition) {
7474
throw new Error(
7575
`Transition ${this.name} is not configured.\n
7676
Expected one of the names: ${Object.keys(transitions).join(', ')}`
7777
);
7878
} else {
79+
if (transition.effectReference) {
80+
const reference = transitions[transition.effectReference];
81+
transition = {
82+
...reference,
83+
...transition,
84+
animation: {...reference?.animation, ...transition?.animation},
85+
};
86+
}
7987
return {
8088
...transition,
8189
animation: {...transition.animation, ...this.animation},

src/lib/types/transitions.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export interface AnimationOptions {
2626
}
2727

2828
export interface TransitionOptions {
29+
// Reference this effect and give it another animation properties, but leave hooks untouched
30+
effectReference: string,
31+
2932
animation: Partial<AnimationOptions>,
3033

3134
appear?: boolean,

0 commit comments

Comments
 (0)