choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
51 lines (48 loc) • 1.4 kB
JavaScript
import cssAnimation from 'css-animation';
import raf from 'raf';
export function animate(node, show, done, className) {
var height;
var requestAnimationFrameId;
return cssAnimation(node, className, {
start: function start() {
if (!show) {
node.style.height = "".concat(node.offsetHeight, "px");
node.style.opacity = '1';
} else {
height = node.offsetHeight;
node.style.height = '0px';
node.style.opacity = '0';
}
},
active: function active() {
if (requestAnimationFrameId) {
raf.cancel(requestAnimationFrameId);
}
requestAnimationFrameId = raf(function () {
node.style.height = "".concat(show ? height : 0, "px");
node.style.opacity = show ? '1' : '0';
});
},
end: function end() {
if (requestAnimationFrameId) {
raf.cancel(requestAnimationFrameId);
}
node.style.height = '';
node.style.opacity = '';
done();
}
});
}
var animation = {
enter: function enter(node, done) {
return animate(node, true, done, 'c7n-motion-collapse');
},
leave: function leave(node, done) {
return animate(node, false, done, 'c7n-motion-collapse');
},
appear: function appear(node, done) {
return animate(node, true, done, 'c7n-motion-collapse');
}
};
export default animation;
//# sourceMappingURL=openAnimation.js.map