UNPKG

react-cqtoolbox

Version:

[![Travis][build-badge]][build] [![npm package][npm-badge]][npm] [![Coveralls][coveralls-badge]][coveralls]

45 lines (38 loc) 1.09 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _cssAnimation = require('css-animation'); var _cssAnimation2 = _interopRequireDefault(_cssAnimation); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function animate(node, show, transitionName, done) { var height = void 0; return (0, _cssAnimation2.default)(node, transitionName, { start: function start() { if (!show) { node.style.height = node.offsetHeight + 'px'; } else { height = node.offsetHeight; node.style.height = 0; } }, active: function active() { node.style.height = (show ? height : 0) + 'px'; }, end: function end() { node.style.height = ''; done(); } }); } function animation(transitionName) { return { enter: function enter(node, done) { return animate(node, true, transitionName, done); }, leave: function leave(node, done) { return animate(node, false, transitionName, done); } }; } exports.default = animation;