feat: update transition util

pull/2415/head
tanjinzhou 2020-06-11 18:27:27 +08:00
parent f2af8d248e
commit e2ce58fa7a
1 changed files with 7 additions and 24 deletions

View File

@ -1,33 +1,16 @@
import animate from './css-animation';
const noop = () => {};
const getTransitionProps = (transitionName, opt = {}) => {
const { beforeEnter, enter, afterEnter, leave, afterLeave, appear = true, tag, nativeOn } = opt;
const transitionProps = {
props: {
appear,
css: false,
appear: true,
css: false,
onEnter: (el, done) => {
animate(el, `${transitionName}-enter`, done);
},
on: {
beforeEnter: beforeEnter || noop,
enter:
enter ||
((el, done) => {
animate(el, `${transitionName}-enter`, done);
}),
afterEnter: afterEnter || noop,
leave:
leave ||
((el, done) => {
animate(el, `${transitionName}-leave`, done);
}),
afterLeave: afterLeave || noop,
onLeave: (el, done) => {
animate(el, `${transitionName}-leave`, done);
},
nativeOn,
...opt,
};
// transition-group
if (tag) {
transitionProps.tag = tag;
}
return transitionProps;
};