rc-animate
Advanced tools
Comparing version 2.3.5 to 2.3.6
@@ -13,6 +13,2 @@ 'use strict'; | ||
var _createReactClass = require('create-react-class'); | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
var _propTypes = require('prop-types'); | ||
@@ -34,4 +30,12 @@ | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
var defaultKey = 'rc_animate_' + Date.now(); | ||
@@ -54,46 +58,25 @@ | ||
var Animate = (0, _createReactClass2["default"])({ | ||
displayName: 'Animate', | ||
var Animate = function (_React$Component) { | ||
_inherits(Animate, _React$Component); | ||
propTypes: { | ||
component: _propTypes2["default"].any, | ||
componentProps: _propTypes2["default"].object, | ||
animation: _propTypes2["default"].object, | ||
transitionName: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].object]), | ||
transitionEnter: _propTypes2["default"].bool, | ||
transitionAppear: _propTypes2["default"].bool, | ||
exclusive: _propTypes2["default"].bool, | ||
transitionLeave: _propTypes2["default"].bool, | ||
onEnd: _propTypes2["default"].func, | ||
onEnter: _propTypes2["default"].func, | ||
onLeave: _propTypes2["default"].func, | ||
onAppear: _propTypes2["default"].func, | ||
showProp: _propTypes2["default"].string | ||
}, | ||
function Animate(props) { | ||
_classCallCheck(this, Animate); | ||
getDefaultProps: function getDefaultProps() { | ||
return { | ||
animation: {}, | ||
component: 'span', | ||
componentProps: {}, | ||
transitionEnter: true, | ||
transitionLeave: true, | ||
transitionAppear: false, | ||
onEnd: noop, | ||
onEnter: noop, | ||
onLeave: noop, | ||
onAppear: noop | ||
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); | ||
_initialiseProps.call(_this); | ||
_this.currentlyAnimatingKeys = {}; | ||
_this.keysToEnter = []; | ||
_this.keysToLeave = []; | ||
_this.state = { | ||
children: (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(_this.props)) | ||
}; | ||
}, | ||
getInitialState: function getInitialState() { | ||
this.currentlyAnimatingKeys = {}; | ||
this.keysToEnter = []; | ||
this.keysToLeave = []; | ||
return { | ||
children: (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(this.props)) | ||
}; | ||
}, | ||
componentDidMount: function componentDidMount() { | ||
var _this = this; | ||
return _this; | ||
} | ||
Animate.prototype.componentDidMount = function componentDidMount() { | ||
var _this2 = this; | ||
var showProp = this.props.showProp; | ||
@@ -108,9 +91,10 @@ var children = this.state.children; | ||
if (child) { | ||
_this.performAppear(child.key); | ||
_this2.performAppear(child.key); | ||
} | ||
}); | ||
}, | ||
componentWillReceiveProps: function componentWillReceiveProps(nextProps) { | ||
var _this2 = this; | ||
}; | ||
Animate.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { | ||
var _this3 = this; | ||
this.nextProps = nextProps; | ||
@@ -122,3 +106,3 @@ var nextChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(nextProps)); | ||
Object.keys(this.currentlyAnimatingKeys).forEach(function (key) { | ||
_this2.stop(key); | ||
_this3.stop(key); | ||
}); | ||
@@ -170,9 +154,9 @@ } | ||
if (!showInNow && showInNext) { | ||
_this2.keysToEnter.push(key); | ||
_this3.keysToEnter.push(key); | ||
} | ||
} else if (showInNext) { | ||
_this2.keysToEnter.push(key); | ||
_this3.keysToEnter.push(key); | ||
} | ||
} else if (!hasPrev) { | ||
_this2.keysToEnter.push(key); | ||
_this3.keysToEnter.push(key); | ||
} | ||
@@ -192,13 +176,14 @@ }); | ||
if (!showInNext && showInNow) { | ||
_this2.keysToLeave.push(key); | ||
_this3.keysToLeave.push(key); | ||
} | ||
} else if (showInNow) { | ||
_this2.keysToLeave.push(key); | ||
_this3.keysToLeave.push(key); | ||
} | ||
} else if (!hasNext) { | ||
_this2.keysToLeave.push(key); | ||
_this3.keysToLeave.push(key); | ||
} | ||
}); | ||
}, | ||
componentDidUpdate: function componentDidUpdate() { | ||
}; | ||
Animate.prototype.componentDidUpdate = function componentDidUpdate() { | ||
var keysToEnter = this.keysToEnter; | ||
@@ -210,77 +195,5 @@ this.keysToEnter = []; | ||
keysToLeave.forEach(this.performLeave); | ||
}, | ||
performEnter: function performEnter(key) { | ||
// may already remove by exclusive | ||
if (this.refs[key]) { | ||
this.currentlyAnimatingKeys[key] = true; | ||
this.refs[key].componentWillEnter(this.handleDoneAdding.bind(this, key, 'enter')); | ||
} | ||
}, | ||
performAppear: function performAppear(key) { | ||
if (this.refs[key]) { | ||
this.currentlyAnimatingKeys[key] = true; | ||
this.refs[key].componentWillAppear(this.handleDoneAdding.bind(this, key, 'appear')); | ||
} | ||
}, | ||
handleDoneAdding: function handleDoneAdding(key, type) { | ||
var props = this.props; | ||
delete this.currentlyAnimatingKeys[key]; | ||
// if update on exclusive mode, skip check | ||
if (props.exclusive && props !== this.nextProps) { | ||
return; | ||
} | ||
var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); | ||
if (!this.isValidChildByKey(currentChildren, key)) { | ||
// exclusive will not need this | ||
this.performLeave(key); | ||
} else { | ||
if (type === 'appear') { | ||
if (_util2["default"].allowAppearCallback(props)) { | ||
props.onAppear(key); | ||
props.onEnd(key, true); | ||
} | ||
} else { | ||
if (_util2["default"].allowEnterCallback(props)) { | ||
props.onEnter(key); | ||
props.onEnd(key, true); | ||
} | ||
} | ||
} | ||
}, | ||
performLeave: function performLeave(key) { | ||
// may already remove by exclusive | ||
if (this.refs[key]) { | ||
this.currentlyAnimatingKeys[key] = true; | ||
this.refs[key].componentWillLeave(this.handleDoneLeaving.bind(this, key)); | ||
} | ||
}, | ||
handleDoneLeaving: function handleDoneLeaving(key) { | ||
var props = this.props; | ||
delete this.currentlyAnimatingKeys[key]; | ||
// if update on exclusive mode, skip check | ||
if (props.exclusive && props !== this.nextProps) { | ||
return; | ||
} | ||
var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); | ||
// in case state change is too fast | ||
if (this.isValidChildByKey(currentChildren, key)) { | ||
this.performEnter(key); | ||
} else { | ||
var end = function end() { | ||
if (_util2["default"].allowLeaveCallback(props)) { | ||
props.onLeave(key); | ||
props.onEnd(key, false); | ||
} | ||
}; | ||
/* eslint react/no-is-mounted:0 */ | ||
if (this.isMounted() && !(0, _ChildrenUtils.isSameChildren)(this.state.children, currentChildren, props.showProp)) { | ||
this.setState({ | ||
children: currentChildren | ||
}, end); | ||
} else { | ||
end(); | ||
} | ||
} | ||
}, | ||
isValidChildByKey: function isValidChildByKey(currentChildren, key) { | ||
}; | ||
Animate.prototype.isValidChildByKey = function isValidChildByKey(currentChildren, key) { | ||
var showProp = this.props.showProp; | ||
@@ -291,4 +204,5 @@ if (showProp) { | ||
return (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); | ||
}, | ||
stop: function stop(key) { | ||
}; | ||
Animate.prototype.stop = function stop(key) { | ||
delete this.currentlyAnimatingKeys[key]; | ||
@@ -299,4 +213,5 @@ var component = this.refs[key]; | ||
} | ||
}, | ||
render: function render() { | ||
}; | ||
Animate.prototype.render = function render() { | ||
var props = this.props; | ||
@@ -345,6 +260,117 @@ this.nextProps = props; | ||
return children[0] || null; | ||
} | ||
}); | ||
}; | ||
return Animate; | ||
}(_react2["default"].Component); | ||
Animate.propTypes = { | ||
component: _propTypes2["default"].any, | ||
componentProps: _propTypes2["default"].object, | ||
animation: _propTypes2["default"].object, | ||
transitionName: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].object]), | ||
transitionEnter: _propTypes2["default"].bool, | ||
transitionAppear: _propTypes2["default"].bool, | ||
exclusive: _propTypes2["default"].bool, | ||
transitionLeave: _propTypes2["default"].bool, | ||
onEnd: _propTypes2["default"].func, | ||
onEnter: _propTypes2["default"].func, | ||
onLeave: _propTypes2["default"].func, | ||
onAppear: _propTypes2["default"].func, | ||
showProp: _propTypes2["default"].string | ||
}; | ||
Animate.defaultProps = { | ||
animation: {}, | ||
component: 'span', | ||
componentProps: {}, | ||
transitionEnter: true, | ||
transitionLeave: true, | ||
transitionAppear: false, | ||
onEnd: noop, | ||
onEnter: noop, | ||
onLeave: noop, | ||
onAppear: noop | ||
}; | ||
var _initialiseProps = function _initialiseProps() { | ||
var _this4 = this; | ||
this.performEnter = function (key) { | ||
// may already remove by exclusive | ||
if (_this4.refs[key]) { | ||
_this4.currentlyAnimatingKeys[key] = true; | ||
_this4.refs[key].componentWillEnter(_this4.handleDoneAdding.bind(_this4, key, 'enter')); | ||
} | ||
}; | ||
this.performAppear = function (key) { | ||
if (_this4.refs[key]) { | ||
_this4.currentlyAnimatingKeys[key] = true; | ||
_this4.refs[key].componentWillAppear(_this4.handleDoneAdding.bind(_this4, key, 'appear')); | ||
} | ||
}; | ||
this.handleDoneAdding = function (key, type) { | ||
var props = _this4.props; | ||
delete _this4.currentlyAnimatingKeys[key]; | ||
// if update on exclusive mode, skip check | ||
if (props.exclusive && props !== _this4.nextProps) { | ||
return; | ||
} | ||
var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); | ||
if (!_this4.isValidChildByKey(currentChildren, key)) { | ||
// exclusive will not need this | ||
_this4.performLeave(key); | ||
} else { | ||
if (type === 'appear') { | ||
if (_util2["default"].allowAppearCallback(props)) { | ||
props.onAppear(key); | ||
props.onEnd(key, true); | ||
} | ||
} else { | ||
if (_util2["default"].allowEnterCallback(props)) { | ||
props.onEnter(key); | ||
props.onEnd(key, true); | ||
} | ||
} | ||
} | ||
}; | ||
this.performLeave = function (key) { | ||
// may already remove by exclusive | ||
if (_this4.refs[key]) { | ||
_this4.currentlyAnimatingKeys[key] = true; | ||
_this4.refs[key].componentWillLeave(_this4.handleDoneLeaving.bind(_this4, key)); | ||
} | ||
}; | ||
this.handleDoneLeaving = function (key) { | ||
var props = _this4.props; | ||
delete _this4.currentlyAnimatingKeys[key]; | ||
// if update on exclusive mode, skip check | ||
if (props.exclusive && props !== _this4.nextProps) { | ||
return; | ||
} | ||
var currentChildren = (0, _ChildrenUtils.toArrayChildren)(getChildrenFromProps(props)); | ||
// in case state change is too fast | ||
if (_this4.isValidChildByKey(currentChildren, key)) { | ||
_this4.performEnter(key); | ||
} else { | ||
var end = function end() { | ||
if (_util2["default"].allowLeaveCallback(props)) { | ||
props.onLeave(key); | ||
props.onEnd(key, false); | ||
} | ||
}; | ||
if (!(0, _ChildrenUtils.isSameChildren)(_this4.state.children, currentChildren, props.showProp)) { | ||
_this4.setState({ | ||
children: currentChildren | ||
}, end); | ||
} else { | ||
end(); | ||
} | ||
} | ||
}; | ||
}; | ||
exports["default"] = Animate; | ||
module.exports = exports['default']; |
@@ -9,2 +9,6 @@ 'use strict'; | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _reactDom = require('react-dom'); | ||
@@ -14,6 +18,2 @@ | ||
var _createReactClass = require('create-react-class'); | ||
var _createReactClass2 = _interopRequireDefault(_createReactClass); | ||
var _propTypes = require('prop-types'); | ||
@@ -33,2 +33,10 @@ | ||
function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); } | ||
var transitionMap = { | ||
@@ -40,13 +48,16 @@ enter: 'transitionEnter', | ||
var AnimateChild = (0, _createReactClass2["default"])({ | ||
displayName: 'AnimateChild', | ||
var AnimateChild = function (_React$Component) { | ||
_inherits(AnimateChild, _React$Component); | ||
propTypes: { | ||
children: _propTypes2["default"].any | ||
}, | ||
function AnimateChild() { | ||
_classCallCheck(this, AnimateChild); | ||
componentWillUnmount: function componentWillUnmount() { | ||
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments)); | ||
} | ||
AnimateChild.prototype.componentWillUnmount = function componentWillUnmount() { | ||
this.stop(); | ||
}, | ||
componentWillEnter: function componentWillEnter(done) { | ||
}; | ||
AnimateChild.prototype.componentWillEnter = function componentWillEnter(done) { | ||
if (_util2["default"].isEnterSupported(this.props)) { | ||
@@ -57,4 +68,5 @@ this.transition('enter', done); | ||
} | ||
}, | ||
componentWillAppear: function componentWillAppear(done) { | ||
}; | ||
AnimateChild.prototype.componentWillAppear = function componentWillAppear(done) { | ||
if (_util2["default"].isAppearSupported(this.props)) { | ||
@@ -65,4 +77,5 @@ this.transition('appear', done); | ||
} | ||
}, | ||
componentWillLeave: function componentWillLeave(done) { | ||
}; | ||
AnimateChild.prototype.componentWillLeave = function componentWillLeave(done) { | ||
if (_util2["default"].isLeaveSupported(this.props)) { | ||
@@ -76,6 +89,7 @@ this.transition('leave', done); | ||
} | ||
}, | ||
transition: function transition(animationType, finishCallback) { | ||
var _this = this; | ||
}; | ||
AnimateChild.prototype.transition = function transition(animationType, finishCallback) { | ||
var _this2 = this; | ||
var node = _reactDom2["default"].findDOMNode(this); | ||
@@ -87,3 +101,3 @@ var props = this.props; | ||
var end = function end() { | ||
_this.stopper = null; | ||
_this2.stopper = null; | ||
finishCallback(); | ||
@@ -104,4 +118,5 @@ }; | ||
} | ||
}, | ||
stop: function stop() { | ||
}; | ||
AnimateChild.prototype.stop = function stop() { | ||
var stopper = this.stopper; | ||
@@ -112,9 +127,15 @@ if (stopper) { | ||
} | ||
}, | ||
render: function render() { | ||
}; | ||
AnimateChild.prototype.render = function render() { | ||
return this.props.children; | ||
} | ||
}); | ||
}; | ||
return AnimateChild; | ||
}(_react2["default"].Component); | ||
AnimateChild.propTypes = { | ||
children: _propTypes2["default"].any | ||
}; | ||
exports["default"] = AnimateChild; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-animate", | ||
"version": "2.3.5", | ||
"version": "2.3.6", | ||
"description": "css-transition ui component for react", | ||
@@ -47,4 +47,4 @@ "keywords": [ | ||
"react": "15.x", | ||
"react-addons-test-utils": "15.x", | ||
"react-dom": "15.x", | ||
"react-addons-test-utils": "15.x", | ||
"velocity-animate": "~1.2.2" | ||
@@ -56,3 +56,2 @@ }, | ||
"dependencies": { | ||
"create-react-class": "^15.5.1", | ||
"css-animation": "^1.3.0", | ||
@@ -59,0 +58,0 @@ "prop-types": "^15.5.6" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
28768
2
549
0
- Removedcreate-react-class@^15.5.1
- Removedcreate-react-class@15.7.0(transitive)