ant-design/components/common/openAnimation.js

46 lines
870 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
2016-01-07 18:04:05 +08:00
/*eslint-disable */
2015-08-25 11:11:21 +08:00
node.style.display = show ? 'block' : 'none';
2016-01-07 18:04:05 +08:00
/*eslint-enable */
2015-08-25 11:11:21 +08:00
velocity(node, transitionName, {
duration: 240,
2016-01-05 14:42:06 +08:00
complete,
2015-08-25 11:11:21 +08:00
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;