ant-design/components/common/openAnimation.js

44 lines
837 B
JavaScript
Raw Normal View History

2015-10-13 12:52:41 +08:00
let velocity;
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
velocity = require('velocity-animate');
}
2015-08-25 11:11:21 +08:00
function animate(node, show, transitionName, done) {
let ok;
function complete() {
if (!ok) {
ok = true;
done();
}
}
// Fix safari flash bug
node.style.display = show ? 'block' : 'none';
velocity(node, transitionName, {
duration: 240,
complete: complete,
easing: 'easeInOutQuad'
});
return {
stop() {
velocity(node, 'finish');
complete();
}
};
}
const animation = {
enter(node, done) {
2015-08-31 12:10:54 +08:00
return animate(node, false, 'slideDown', done);
2015-08-25 11:11:21 +08:00
},
leave(node, done) {
2015-08-31 12:10:54 +08:00
return animate(node, true, 'slideUp', done);
2015-08-25 11:11:21 +08:00
},
appear(node, done) {
2015-08-31 12:10:54 +08:00
return animate(node, false, 'slideDown', done);
2015-08-25 11:11:21 +08:00
},
};
2015-10-13 12:52:41 +08:00
module.exports = animation;