From afdbe4544c7e5854717ff95ff82b434c477c9ed0 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Wed, 30 Mar 2016 16:27:14 +0800 Subject: [PATCH] remove velocity-anim --- components/common/openAnimation.js | 51 ++++++++++++------------------ package.json | 5 ++- style/components/collapse.less | 9 ++++-- style/core/motion.less | 7 ++++ 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/components/common/openAnimation.js b/components/common/openAnimation.js index d96a549e1f..f2a33ba216 100644 --- a/components/common/openAnimation.js +++ b/components/common/openAnimation.js @@ -1,44 +1,35 @@ -let velocity; -if (typeof document !== 'undefined' && typeof window !== 'undefined') { - velocity = require('velocity-animate'); -} - -function animate(node, show, transitionName, done) { - let ok; +import cssAnimation from 'css-animation'; - function complete() { - if (!ok) { - ok = true; +function animate(node, show, done) { + let height; + return cssAnimation(node, 'ant-motion-collapse', { + start() { + if (!show) { + node.style.height = `${node.offsetHeight}px`; + } else { + height = node.offsetHeight; + node.style.height = 0; + } + }, + active() { + node.style.height = `${show ? height : 0}px`; + }, + end() { + node.style.height = ''; done(); - } - } - - // Fix safari flash bug - /*eslint-disable */ - node.style.display = show ? 'block' : 'none'; - /*eslint-enable */ - velocity(node, transitionName, { - duration: 240, - complete, - easing: 'easeInOutQuad' + }, }); - return { - stop() { - velocity(node, 'finish'); - complete(); - } - }; } const animation = { enter(node, done) { - return animate(node, false, 'slideDown', done); + return animate(node, true, done); }, leave(node, done) { - return animate(node, true, 'slideUp', done); + return animate(node, false, done); }, appear(node, done) { - return animate(node, false, 'slideDown', done); + return animate(node, true, done); }, }; diff --git a/package.json b/package.json index acb13c4c89..10845bff75 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ "dependencies": { "array-tree-filter": "~1.0.0", "classnames": "~2.2.0", - "css-animation": "~1.1.0", + "css-animation": "~1.2.0", "gregorian-calendar": "~4.1.0", "gregorian-calendar-format": "~4.1.0", "rc-animate": "~2.0.2", "rc-calendar": "~5.4.0", "rc-cascader": "~0.9.0", "rc-checkbox": "~1.3.0", - "rc-collapse": "~1.4.4", + "rc-collapse": "~1.5.0", "rc-dialog": "~5.4.0", "rc-dropdown": "~1.4.3", "rc-form": "~0.14.0", @@ -67,7 +67,6 @@ "rc-upload": "~1.9.0", "rc-util": "~3.1.2", "react-slick": "~0.11.0", - "velocity-animate": "~1.2.2", "warning": "~2.1.0" }, "devDependencies": { diff --git a/style/components/collapse.less b/style/components/collapse.less index bc8a6b6483..59df485d4b 100644 --- a/style/components/collapse.less +++ b/style/components/collapse.less @@ -12,6 +12,10 @@ border-radius: 3px; border: 1px solid @border-color-base; + &-anim-active { + transition: height .2s ease-out; + } + & > &-item { border-top: 1px solid @border-color-base; &:first-child { @@ -49,7 +53,6 @@ } &-content { - display: none; overflow: hidden; color: @text-color; padding: 0 16px; @@ -60,8 +63,8 @@ padding-bottom: 16px; } - &-active { - display: block; + &-inactive { + display: none; } } diff --git a/style/core/motion.less b/style/core/motion.less index c509e9fc9e..f720bb7d64 100644 --- a/style/core/motion.less +++ b/style/core/motion.less @@ -29,6 +29,13 @@ } } +.ant-motion-collapse { + overflow: hidden; + &-active { + transition: height .2s ease-out; + } +} + @import "motion/fade"; @import "motion/move"; @import "motion/other"; -- GitLab