Latest updates from IceHrmPro
This commit is contained in:
354
web/node_modules/rc-animate/es/Animate.js
generated
vendored
Normal file
354
web/node_modules/rc-animate/es/Animate.js
generated
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import _defineProperty from 'babel-runtime/helpers/defineProperty';
|
||||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
||||
import _createClass from 'babel-runtime/helpers/createClass';
|
||||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
||||
import _inherits from 'babel-runtime/helpers/inherits';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import unsafeLifecyclesPolyfill from 'rc-util/es/unsafeLifecyclesPolyfill';
|
||||
import { toArrayChildren, mergeChildren, findShownChildInChildrenByKey, findChildInChildrenByKey, isSameChildren } from './ChildrenUtils';
|
||||
import AnimateChild from './AnimateChild';
|
||||
import animUtil from './util/animate';
|
||||
|
||||
var defaultKey = 'rc_animate_' + Date.now();
|
||||
|
||||
function getChildrenFromProps(props) {
|
||||
var children = props.children;
|
||||
if (React.isValidElement(children)) {
|
||||
if (!children.key) {
|
||||
return React.cloneElement(children, {
|
||||
key: defaultKey
|
||||
});
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
function noop() {}
|
||||
|
||||
var Animate = function (_React$Component) {
|
||||
_inherits(Animate, _React$Component);
|
||||
|
||||
// eslint-disable-line
|
||||
|
||||
function Animate(props) {
|
||||
_classCallCheck(this, Animate);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (Animate.__proto__ || Object.getPrototypeOf(Animate)).call(this, props));
|
||||
|
||||
_initialiseProps.call(_this);
|
||||
|
||||
_this.currentlyAnimatingKeys = {};
|
||||
_this.keysToEnter = [];
|
||||
_this.keysToLeave = [];
|
||||
|
||||
_this.state = {
|
||||
children: toArrayChildren(getChildrenFromProps(props))
|
||||
};
|
||||
|
||||
_this.childrenRefs = {};
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(Animate, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
var _this2 = this;
|
||||
|
||||
var showProp = this.props.showProp;
|
||||
var children = this.state.children;
|
||||
if (showProp) {
|
||||
children = children.filter(function (child) {
|
||||
return !!child.props[showProp];
|
||||
});
|
||||
}
|
||||
children.forEach(function (child) {
|
||||
if (child) {
|
||||
_this2.performAppear(child.key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillReceiveProps',
|
||||
value: function componentWillReceiveProps(nextProps) {
|
||||
var _this3 = this;
|
||||
|
||||
this.nextProps = nextProps;
|
||||
var nextChildren = toArrayChildren(getChildrenFromProps(nextProps));
|
||||
var props = this.props;
|
||||
// exclusive needs immediate response
|
||||
if (props.exclusive) {
|
||||
Object.keys(this.currentlyAnimatingKeys).forEach(function (key) {
|
||||
_this3.stop(key);
|
||||
});
|
||||
}
|
||||
var showProp = props.showProp;
|
||||
var currentlyAnimatingKeys = this.currentlyAnimatingKeys;
|
||||
// last props children if exclusive
|
||||
var currentChildren = props.exclusive ? toArrayChildren(getChildrenFromProps(props)) : this.state.children;
|
||||
// in case destroy in showProp mode
|
||||
var newChildren = [];
|
||||
if (showProp) {
|
||||
currentChildren.forEach(function (currentChild) {
|
||||
var nextChild = currentChild && findChildInChildrenByKey(nextChildren, currentChild.key);
|
||||
var newChild = void 0;
|
||||
if ((!nextChild || !nextChild.props[showProp]) && currentChild.props[showProp]) {
|
||||
newChild = React.cloneElement(nextChild || currentChild, _defineProperty({}, showProp, true));
|
||||
} else {
|
||||
newChild = nextChild;
|
||||
}
|
||||
if (newChild) {
|
||||
newChildren.push(newChild);
|
||||
}
|
||||
});
|
||||
nextChildren.forEach(function (nextChild) {
|
||||
if (!nextChild || !findChildInChildrenByKey(currentChildren, nextChild.key)) {
|
||||
newChildren.push(nextChild);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
newChildren = mergeChildren(currentChildren, nextChildren);
|
||||
}
|
||||
|
||||
// need render to avoid update
|
||||
this.setState({
|
||||
children: newChildren
|
||||
});
|
||||
|
||||
nextChildren.forEach(function (child) {
|
||||
var key = child && child.key;
|
||||
if (child && currentlyAnimatingKeys[key]) {
|
||||
return;
|
||||
}
|
||||
var hasPrev = child && findChildInChildrenByKey(currentChildren, key);
|
||||
if (showProp) {
|
||||
var showInNext = child.props[showProp];
|
||||
if (hasPrev) {
|
||||
var showInNow = findShownChildInChildrenByKey(currentChildren, key, showProp);
|
||||
if (!showInNow && showInNext) {
|
||||
_this3.keysToEnter.push(key);
|
||||
}
|
||||
} else if (showInNext) {
|
||||
_this3.keysToEnter.push(key);
|
||||
}
|
||||
} else if (!hasPrev) {
|
||||
_this3.keysToEnter.push(key);
|
||||
}
|
||||
});
|
||||
|
||||
currentChildren.forEach(function (child) {
|
||||
var key = child && child.key;
|
||||
if (child && currentlyAnimatingKeys[key]) {
|
||||
return;
|
||||
}
|
||||
var hasNext = child && findChildInChildrenByKey(nextChildren, key);
|
||||
if (showProp) {
|
||||
var showInNow = child.props[showProp];
|
||||
if (hasNext) {
|
||||
var showInNext = findShownChildInChildrenByKey(nextChildren, key, showProp);
|
||||
if (!showInNext && showInNow) {
|
||||
_this3.keysToLeave.push(key);
|
||||
}
|
||||
} else if (showInNow) {
|
||||
_this3.keysToLeave.push(key);
|
||||
}
|
||||
} else if (!hasNext) {
|
||||
_this3.keysToLeave.push(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate() {
|
||||
var keysToEnter = this.keysToEnter;
|
||||
this.keysToEnter = [];
|
||||
keysToEnter.forEach(this.performEnter);
|
||||
var keysToLeave = this.keysToLeave;
|
||||
this.keysToLeave = [];
|
||||
keysToLeave.forEach(this.performLeave);
|
||||
}
|
||||
}, {
|
||||
key: 'isValidChildByKey',
|
||||
value: function isValidChildByKey(currentChildren, key) {
|
||||
var showProp = this.props.showProp;
|
||||
if (showProp) {
|
||||
return findShownChildInChildrenByKey(currentChildren, key, showProp);
|
||||
}
|
||||
return findChildInChildrenByKey(currentChildren, key);
|
||||
}
|
||||
}, {
|
||||
key: 'stop',
|
||||
value: function stop(key) {
|
||||
delete this.currentlyAnimatingKeys[key];
|
||||
var component = this.childrenRefs[key];
|
||||
if (component) {
|
||||
component.stop();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _this4 = this;
|
||||
|
||||
var props = this.props;
|
||||
this.nextProps = props;
|
||||
var stateChildren = this.state.children;
|
||||
var children = null;
|
||||
if (stateChildren) {
|
||||
children = stateChildren.map(function (child) {
|
||||
if (child === null || child === undefined) {
|
||||
return child;
|
||||
}
|
||||
if (!child.key) {
|
||||
throw new Error('must set key for <rc-animate> children');
|
||||
}
|
||||
return React.createElement(
|
||||
AnimateChild,
|
||||
{
|
||||
key: child.key,
|
||||
ref: function ref(node) {
|
||||
_this4.childrenRefs[child.key] = node;
|
||||
},
|
||||
animation: props.animation,
|
||||
transitionName: props.transitionName,
|
||||
transitionEnter: props.transitionEnter,
|
||||
transitionAppear: props.transitionAppear,
|
||||
transitionLeave: props.transitionLeave
|
||||
},
|
||||
child
|
||||
);
|
||||
});
|
||||
}
|
||||
var Component = props.component;
|
||||
if (Component) {
|
||||
var passedProps = props;
|
||||
if (typeof Component === 'string') {
|
||||
passedProps = _extends({
|
||||
className: props.className,
|
||||
style: props.style
|
||||
}, props.componentProps);
|
||||
}
|
||||
return React.createElement(
|
||||
Component,
|
||||
passedProps,
|
||||
children
|
||||
);
|
||||
}
|
||||
return children[0] || null;
|
||||
}
|
||||
}]);
|
||||
|
||||
return Animate;
|
||||
}(React.Component);
|
||||
|
||||
Animate.isAnimate = true;
|
||||
Animate.propTypes = {
|
||||
className: PropTypes.string,
|
||||
style: PropTypes.object,
|
||||
component: PropTypes.any,
|
||||
componentProps: PropTypes.object,
|
||||
animation: PropTypes.object,
|
||||
transitionName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||
transitionEnter: PropTypes.bool,
|
||||
transitionAppear: PropTypes.bool,
|
||||
exclusive: PropTypes.bool,
|
||||
transitionLeave: PropTypes.bool,
|
||||
onEnd: PropTypes.func,
|
||||
onEnter: PropTypes.func,
|
||||
onLeave: PropTypes.func,
|
||||
onAppear: PropTypes.func,
|
||||
showProp: PropTypes.string,
|
||||
children: PropTypes.node
|
||||
};
|
||||
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 _this5 = this;
|
||||
|
||||
this.performEnter = function (key) {
|
||||
// may already remove by exclusive
|
||||
if (_this5.childrenRefs[key]) {
|
||||
_this5.currentlyAnimatingKeys[key] = true;
|
||||
_this5.childrenRefs[key].componentWillEnter(_this5.handleDoneAdding.bind(_this5, key, 'enter'));
|
||||
}
|
||||
};
|
||||
|
||||
this.performAppear = function (key) {
|
||||
if (_this5.childrenRefs[key]) {
|
||||
_this5.currentlyAnimatingKeys[key] = true;
|
||||
_this5.childrenRefs[key].componentWillAppear(_this5.handleDoneAdding.bind(_this5, key, 'appear'));
|
||||
}
|
||||
};
|
||||
|
||||
this.handleDoneAdding = function (key, type) {
|
||||
var props = _this5.props;
|
||||
delete _this5.currentlyAnimatingKeys[key];
|
||||
// if update on exclusive mode, skip check
|
||||
if (props.exclusive && props !== _this5.nextProps) {
|
||||
return;
|
||||
}
|
||||
var currentChildren = toArrayChildren(getChildrenFromProps(props));
|
||||
if (!_this5.isValidChildByKey(currentChildren, key)) {
|
||||
// exclusive will not need this
|
||||
_this5.performLeave(key);
|
||||
} else if (type === 'appear') {
|
||||
if (animUtil.allowAppearCallback(props)) {
|
||||
props.onAppear(key);
|
||||
props.onEnd(key, true);
|
||||
}
|
||||
} else if (animUtil.allowEnterCallback(props)) {
|
||||
props.onEnter(key);
|
||||
props.onEnd(key, true);
|
||||
}
|
||||
};
|
||||
|
||||
this.performLeave = function (key) {
|
||||
// may already remove by exclusive
|
||||
if (_this5.childrenRefs[key]) {
|
||||
_this5.currentlyAnimatingKeys[key] = true;
|
||||
_this5.childrenRefs[key].componentWillLeave(_this5.handleDoneLeaving.bind(_this5, key));
|
||||
}
|
||||
};
|
||||
|
||||
this.handleDoneLeaving = function (key) {
|
||||
var props = _this5.props;
|
||||
delete _this5.currentlyAnimatingKeys[key];
|
||||
// if update on exclusive mode, skip check
|
||||
if (props.exclusive && props !== _this5.nextProps) {
|
||||
return;
|
||||
}
|
||||
var currentChildren = toArrayChildren(getChildrenFromProps(props));
|
||||
// in case state change is too fast
|
||||
if (_this5.isValidChildByKey(currentChildren, key)) {
|
||||
_this5.performEnter(key);
|
||||
} else {
|
||||
var end = function end() {
|
||||
if (animUtil.allowLeaveCallback(props)) {
|
||||
props.onLeave(key);
|
||||
props.onEnd(key, false);
|
||||
}
|
||||
};
|
||||
if (!isSameChildren(_this5.state.children, currentChildren, props.showProp)) {
|
||||
_this5.setState({
|
||||
children: currentChildren
|
||||
}, end);
|
||||
} else {
|
||||
end();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default unsafeLifecyclesPolyfill(Animate);
|
||||
113
web/node_modules/rc-animate/es/AnimateChild.js
generated
vendored
Normal file
113
web/node_modules/rc-animate/es/AnimateChild.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
||||
import _createClass from 'babel-runtime/helpers/createClass';
|
||||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
||||
import _inherits from 'babel-runtime/helpers/inherits';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
import cssAnimate, { isCssAnimationSupported } from 'css-animation';
|
||||
import animUtil from './util/animate';
|
||||
|
||||
var transitionMap = {
|
||||
enter: 'transitionEnter',
|
||||
appear: 'transitionAppear',
|
||||
leave: 'transitionLeave'
|
||||
};
|
||||
|
||||
var AnimateChild = function (_React$Component) {
|
||||
_inherits(AnimateChild, _React$Component);
|
||||
|
||||
function AnimateChild() {
|
||||
_classCallCheck(this, AnimateChild);
|
||||
|
||||
return _possibleConstructorReturn(this, (AnimateChild.__proto__ || Object.getPrototypeOf(AnimateChild)).apply(this, arguments));
|
||||
}
|
||||
|
||||
_createClass(AnimateChild, [{
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this.stop();
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillEnter',
|
||||
value: function componentWillEnter(done) {
|
||||
if (animUtil.isEnterSupported(this.props)) {
|
||||
this.transition('enter', done);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillAppear',
|
||||
value: function componentWillAppear(done) {
|
||||
if (animUtil.isAppearSupported(this.props)) {
|
||||
this.transition('appear', done);
|
||||
} else {
|
||||
done();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillLeave',
|
||||
value: function componentWillLeave(done) {
|
||||
if (animUtil.isLeaveSupported(this.props)) {
|
||||
this.transition('leave', done);
|
||||
} else {
|
||||
// always sync, do not interupt with react component life cycle
|
||||
// update hidden -> animate hidden ->
|
||||
// didUpdate -> animate leave -> unmount (if animate is none)
|
||||
done();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'transition',
|
||||
value: function transition(animationType, finishCallback) {
|
||||
var _this2 = this;
|
||||
|
||||
var node = ReactDOM.findDOMNode(this);
|
||||
var props = this.props;
|
||||
var transitionName = props.transitionName;
|
||||
var nameIsObj = typeof transitionName === 'object';
|
||||
this.stop();
|
||||
var end = function end() {
|
||||
_this2.stopper = null;
|
||||
finishCallback();
|
||||
};
|
||||
if ((isCssAnimationSupported || !props.animation[animationType]) && transitionName && props[transitionMap[animationType]]) {
|
||||
var name = nameIsObj ? transitionName[animationType] : transitionName + '-' + animationType;
|
||||
var activeName = name + '-active';
|
||||
if (nameIsObj && transitionName[animationType + 'Active']) {
|
||||
activeName = transitionName[animationType + 'Active'];
|
||||
}
|
||||
this.stopper = cssAnimate(node, {
|
||||
name: name,
|
||||
active: activeName
|
||||
}, end);
|
||||
} else {
|
||||
this.stopper = props.animation[animationType](node, end);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'stop',
|
||||
value: function stop() {
|
||||
var stopper = this.stopper;
|
||||
if (stopper) {
|
||||
this.stopper = null;
|
||||
stopper.stop();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}]);
|
||||
|
||||
return AnimateChild;
|
||||
}(React.Component);
|
||||
|
||||
AnimateChild.propTypes = {
|
||||
children: PropTypes.any,
|
||||
animation: PropTypes.any,
|
||||
transitionName: PropTypes.any
|
||||
};
|
||||
export default AnimateChild;
|
||||
343
web/node_modules/rc-animate/es/CSSMotion.js
generated
vendored
Normal file
343
web/node_modules/rc-animate/es/CSSMotion.js
generated
vendored
Normal file
@@ -0,0 +1,343 @@
|
||||
import _defineProperty from 'babel-runtime/helpers/defineProperty';
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
||||
import _createClass from 'babel-runtime/helpers/createClass';
|
||||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
||||
import _inherits from 'babel-runtime/helpers/inherits';
|
||||
/* eslint-disable react/default-props-match-prop-types, react/no-multi-comp */
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { polyfill } from 'react-lifecycles-compat';
|
||||
import findDOMNode from 'rc-util/es/Dom/findDOMNode';
|
||||
import classNames from 'classnames';
|
||||
import raf from 'raf';
|
||||
import { getTransitionName, animationEndName, transitionEndName, supportTransition } from './util/motion';
|
||||
|
||||
var STATUS_NONE = 'none';
|
||||
var STATUS_APPEAR = 'appear';
|
||||
var STATUS_ENTER = 'enter';
|
||||
var STATUS_LEAVE = 'leave';
|
||||
|
||||
export var MotionPropTypes = {
|
||||
eventProps: PropTypes.object, // Internal usage. Only pass by CSSMotionList
|
||||
visible: PropTypes.bool,
|
||||
children: PropTypes.func,
|
||||
motionName: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||
motionAppear: PropTypes.bool,
|
||||
motionEnter: PropTypes.bool,
|
||||
motionLeave: PropTypes.bool,
|
||||
motionLeaveImmediately: PropTypes.bool, // Trigger leave motion immediately
|
||||
removeOnLeave: PropTypes.bool,
|
||||
leavedClassName: PropTypes.string,
|
||||
onAppearStart: PropTypes.func,
|
||||
onAppearActive: PropTypes.func,
|
||||
onAppearEnd: PropTypes.func,
|
||||
onEnterStart: PropTypes.func,
|
||||
onEnterActive: PropTypes.func,
|
||||
onEnterEnd: PropTypes.func,
|
||||
onLeaveStart: PropTypes.func,
|
||||
onLeaveActive: PropTypes.func,
|
||||
onLeaveEnd: PropTypes.func
|
||||
};
|
||||
|
||||
/**
|
||||
* `transitionSupport` is used for none transition test case.
|
||||
* Default we use browser transition event support check.
|
||||
*/
|
||||
export function genCSSMotion(config) {
|
||||
var transitionSupport = config;
|
||||
var forwardRef = !!React.forwardRef;
|
||||
|
||||
if (typeof config === 'object') {
|
||||
transitionSupport = config.transitionSupport;
|
||||
forwardRef = 'forwardRef' in config ? config.forwardRef : forwardRef;
|
||||
}
|
||||
|
||||
function isSupportTransition(props) {
|
||||
return !!(props.motionName && transitionSupport);
|
||||
}
|
||||
|
||||
var CSSMotion = function (_React$Component) {
|
||||
_inherits(CSSMotion, _React$Component);
|
||||
|
||||
function CSSMotion() {
|
||||
_classCallCheck(this, CSSMotion);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (CSSMotion.__proto__ || Object.getPrototypeOf(CSSMotion)).call(this));
|
||||
|
||||
_this.onDomUpdate = function () {
|
||||
var _this$state = _this.state,
|
||||
status = _this$state.status,
|
||||
newStatus = _this$state.newStatus;
|
||||
var _this$props = _this.props,
|
||||
onAppearStart = _this$props.onAppearStart,
|
||||
onEnterStart = _this$props.onEnterStart,
|
||||
onLeaveStart = _this$props.onLeaveStart,
|
||||
onAppearActive = _this$props.onAppearActive,
|
||||
onEnterActive = _this$props.onEnterActive,
|
||||
onLeaveActive = _this$props.onLeaveActive,
|
||||
motionAppear = _this$props.motionAppear,
|
||||
motionEnter = _this$props.motionEnter,
|
||||
motionLeave = _this$props.motionLeave;
|
||||
|
||||
|
||||
if (!isSupportTransition(_this.props)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Event injection
|
||||
var $ele = _this.getElement();
|
||||
if (_this.$cacheEle !== $ele) {
|
||||
_this.removeEventListener(_this.$cacheEle);
|
||||
_this.addEventListener($ele);
|
||||
_this.$cacheEle = $ele;
|
||||
}
|
||||
|
||||
// Init status
|
||||
if (newStatus && status === STATUS_APPEAR && motionAppear) {
|
||||
_this.updateStatus(onAppearStart, null, null, function () {
|
||||
_this.updateActiveStatus(onAppearActive, STATUS_APPEAR);
|
||||
});
|
||||
} else if (newStatus && status === STATUS_ENTER && motionEnter) {
|
||||
_this.updateStatus(onEnterStart, null, null, function () {
|
||||
_this.updateActiveStatus(onEnterActive, STATUS_ENTER);
|
||||
});
|
||||
} else if (newStatus && status === STATUS_LEAVE && motionLeave) {
|
||||
_this.updateStatus(onLeaveStart, null, null, function () {
|
||||
_this.updateActiveStatus(onLeaveActive, STATUS_LEAVE);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_this.onMotionEnd = function (event) {
|
||||
var _this$state2 = _this.state,
|
||||
status = _this$state2.status,
|
||||
statusActive = _this$state2.statusActive;
|
||||
var _this$props2 = _this.props,
|
||||
onAppearEnd = _this$props2.onAppearEnd,
|
||||
onEnterEnd = _this$props2.onEnterEnd,
|
||||
onLeaveEnd = _this$props2.onLeaveEnd;
|
||||
|
||||
if (status === STATUS_APPEAR && statusActive) {
|
||||
_this.updateStatus(onAppearEnd, { status: STATUS_NONE }, event);
|
||||
} else if (status === STATUS_ENTER && statusActive) {
|
||||
_this.updateStatus(onEnterEnd, { status: STATUS_NONE }, event);
|
||||
} else if (status === STATUS_LEAVE && statusActive) {
|
||||
_this.updateStatus(onLeaveEnd, { status: STATUS_NONE }, event);
|
||||
}
|
||||
};
|
||||
|
||||
_this.setNodeRef = function (node) {
|
||||
var internalRef = _this.props.internalRef;
|
||||
|
||||
_this.node = node;
|
||||
|
||||
if (typeof internalRef === 'function') {
|
||||
internalRef(node);
|
||||
} else if (internalRef && 'current' in internalRef) {
|
||||
internalRef.current = node;
|
||||
}
|
||||
};
|
||||
|
||||
_this.getElement = function () {
|
||||
return findDOMNode(_this.node || _this);
|
||||
};
|
||||
|
||||
_this.addEventListener = function ($ele) {
|
||||
if (!$ele) return;
|
||||
|
||||
$ele.addEventListener(transitionEndName, _this.onMotionEnd);
|
||||
$ele.addEventListener(animationEndName, _this.onMotionEnd);
|
||||
};
|
||||
|
||||
_this.removeEventListener = function ($ele) {
|
||||
if (!$ele) return;
|
||||
|
||||
$ele.removeEventListener(transitionEndName, _this.onMotionEnd);
|
||||
$ele.removeEventListener(animationEndName, _this.onMotionEnd);
|
||||
};
|
||||
|
||||
_this.updateStatus = function (styleFunc, additionalState, event, callback) {
|
||||
var statusStyle = styleFunc ? styleFunc(_this.getElement(), event) : null;
|
||||
|
||||
if (statusStyle === false || _this._destroyed) return;
|
||||
|
||||
var nextStep = void 0;
|
||||
if (callback) {
|
||||
nextStep = function nextStep() {
|
||||
_this.nextFrame(callback);
|
||||
};
|
||||
}
|
||||
|
||||
_this.setState(_extends({
|
||||
statusStyle: typeof statusStyle === 'object' ? statusStyle : null,
|
||||
newStatus: false
|
||||
}, additionalState), nextStep); // Trigger before next frame & after `componentDidMount`
|
||||
};
|
||||
|
||||
_this.updateActiveStatus = function (styleFunc, currentStatus) {
|
||||
// `setState` use `postMessage` to trigger at the end of frame.
|
||||
// Let's use requestAnimationFrame to update new state in next frame.
|
||||
_this.nextFrame(function () {
|
||||
var status = _this.state.status;
|
||||
|
||||
if (status !== currentStatus) return;
|
||||
|
||||
_this.updateStatus(styleFunc, { statusActive: true });
|
||||
});
|
||||
};
|
||||
|
||||
_this.nextFrame = function (func) {
|
||||
_this.cancelNextFrame();
|
||||
_this.raf = raf(func);
|
||||
};
|
||||
|
||||
_this.cancelNextFrame = function () {
|
||||
if (_this.raf) {
|
||||
raf.cancel(_this.raf);
|
||||
_this.raf = null;
|
||||
}
|
||||
};
|
||||
|
||||
_this.state = {
|
||||
status: STATUS_NONE,
|
||||
statusActive: false,
|
||||
newStatus: false,
|
||||
statusStyle: null
|
||||
};
|
||||
_this.$cacheEle = null;
|
||||
_this.node = null;
|
||||
_this.raf = null;
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(CSSMotion, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
this.onDomUpdate();
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate() {
|
||||
this.onDomUpdate();
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this._destroyed = true;
|
||||
this.removeEventListener(this.$cacheEle);
|
||||
this.cancelNextFrame();
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _classNames;
|
||||
|
||||
var _state = this.state,
|
||||
status = _state.status,
|
||||
statusActive = _state.statusActive,
|
||||
statusStyle = _state.statusStyle;
|
||||
var _props = this.props,
|
||||
children = _props.children,
|
||||
motionName = _props.motionName,
|
||||
visible = _props.visible,
|
||||
removeOnLeave = _props.removeOnLeave,
|
||||
leavedClassName = _props.leavedClassName,
|
||||
eventProps = _props.eventProps;
|
||||
|
||||
|
||||
if (!children) return null;
|
||||
|
||||
if (status === STATUS_NONE || !isSupportTransition(this.props)) {
|
||||
if (visible) {
|
||||
return children(_extends({}, eventProps), this.setNodeRef);
|
||||
} else if (!removeOnLeave) {
|
||||
return children(_extends({}, eventProps, { className: leavedClassName }), this.setNodeRef);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return children(_extends({}, eventProps, {
|
||||
className: classNames((_classNames = {}, _defineProperty(_classNames, getTransitionName(motionName, status), status !== STATUS_NONE), _defineProperty(_classNames, getTransitionName(motionName, status + '-active'), status !== STATUS_NONE && statusActive), _defineProperty(_classNames, motionName, typeof motionName === 'string'), _classNames)),
|
||||
style: statusStyle
|
||||
}), this.setNodeRef);
|
||||
}
|
||||
}], [{
|
||||
key: 'getDerivedStateFromProps',
|
||||
value: function getDerivedStateFromProps(props, _ref) {
|
||||
var prevProps = _ref.prevProps,
|
||||
prevStatus = _ref.status;
|
||||
|
||||
if (!isSupportTransition(props)) return {};
|
||||
|
||||
var visible = props.visible,
|
||||
motionAppear = props.motionAppear,
|
||||
motionEnter = props.motionEnter,
|
||||
motionLeave = props.motionLeave,
|
||||
motionLeaveImmediately = props.motionLeaveImmediately;
|
||||
|
||||
var newState = {
|
||||
prevProps: props
|
||||
};
|
||||
|
||||
// Clean up status if prop set to false
|
||||
if (prevStatus === STATUS_APPEAR && !motionAppear || prevStatus === STATUS_ENTER && !motionEnter || prevStatus === STATUS_LEAVE && !motionLeave) {
|
||||
newState.status = STATUS_NONE;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = false;
|
||||
}
|
||||
|
||||
// Appear
|
||||
if (!prevProps && visible && motionAppear) {
|
||||
newState.status = STATUS_APPEAR;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = true;
|
||||
}
|
||||
|
||||
// Enter
|
||||
if (prevProps && !prevProps.visible && visible && motionEnter) {
|
||||
newState.status = STATUS_ENTER;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = true;
|
||||
}
|
||||
|
||||
// Leave
|
||||
if (prevProps && prevProps.visible && !visible && motionLeave || !prevProps && motionLeaveImmediately && !visible && motionLeave) {
|
||||
newState.status = STATUS_LEAVE;
|
||||
newState.statusActive = false;
|
||||
newState.newStatus = true;
|
||||
}
|
||||
|
||||
return newState;
|
||||
}
|
||||
}]);
|
||||
|
||||
return CSSMotion;
|
||||
}(React.Component);
|
||||
|
||||
CSSMotion.propTypes = _extends({}, MotionPropTypes, {
|
||||
|
||||
internalRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func])
|
||||
});
|
||||
CSSMotion.defaultProps = {
|
||||
visible: true,
|
||||
motionEnter: true,
|
||||
motionAppear: true,
|
||||
motionLeave: true,
|
||||
removeOnLeave: true
|
||||
};
|
||||
|
||||
|
||||
polyfill(CSSMotion);
|
||||
|
||||
if (!forwardRef) {
|
||||
return CSSMotion;
|
||||
}
|
||||
|
||||
return React.forwardRef(function (props, ref) {
|
||||
return React.createElement(CSSMotion, _extends({ internalRef: ref }, props));
|
||||
});
|
||||
}
|
||||
|
||||
export default genCSSMotion(supportTransition);
|
||||
156
web/node_modules/rc-animate/es/CSSMotionList.js
generated
vendored
Normal file
156
web/node_modules/rc-animate/es/CSSMotionList.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
||||
import _createClass from 'babel-runtime/helpers/createClass';
|
||||
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
||||
import _inherits from 'babel-runtime/helpers/inherits';
|
||||
import React from 'react';
|
||||
import { polyfill } from 'react-lifecycles-compat';
|
||||
import PropTypes from 'prop-types';
|
||||
import OriginCSSMotion, { MotionPropTypes } from './CSSMotion';
|
||||
import { supportTransition } from './util/motion';
|
||||
import { STATUS_ADD, STATUS_KEEP, STATUS_REMOVE, STATUS_REMOVED, diffKeys, parseKeys } from './util/diff';
|
||||
|
||||
var MOTION_PROP_NAMES = Object.keys(MotionPropTypes);
|
||||
|
||||
export function genCSSMotionList(transitionSupport) {
|
||||
var CSSMotion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : OriginCSSMotion;
|
||||
|
||||
var CSSMotionList = function (_React$Component) {
|
||||
_inherits(CSSMotionList, _React$Component);
|
||||
|
||||
function CSSMotionList() {
|
||||
var _ref;
|
||||
|
||||
var _temp, _this, _ret;
|
||||
|
||||
_classCallCheck(this, CSSMotionList);
|
||||
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = CSSMotionList.__proto__ || Object.getPrototypeOf(CSSMotionList)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
||||
keyEntities: []
|
||||
}, _this.removeKey = function (removeKey) {
|
||||
_this.setState(function (_ref2) {
|
||||
var keyEntities = _ref2.keyEntities;
|
||||
return {
|
||||
keyEntities: keyEntities.map(function (entity) {
|
||||
if (entity.key !== removeKey) return entity;
|
||||
return _extends({}, entity, {
|
||||
status: STATUS_REMOVED
|
||||
});
|
||||
})
|
||||
};
|
||||
});
|
||||
}, _temp), _possibleConstructorReturn(_this, _ret);
|
||||
}
|
||||
|
||||
_createClass(CSSMotionList, [{
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var keyEntities = this.state.keyEntities;
|
||||
|
||||
var _props = this.props,
|
||||
component = _props.component,
|
||||
children = _props.children,
|
||||
restProps = _objectWithoutProperties(_props, ['component', 'children']);
|
||||
|
||||
var Component = component || React.Fragment;
|
||||
|
||||
var motionProps = {};
|
||||
MOTION_PROP_NAMES.forEach(function (prop) {
|
||||
motionProps[prop] = restProps[prop];
|
||||
delete restProps[prop];
|
||||
});
|
||||
delete restProps.keys;
|
||||
|
||||
return React.createElement(
|
||||
Component,
|
||||
restProps,
|
||||
keyEntities.map(function (_ref3) {
|
||||
var status = _ref3.status,
|
||||
eventProps = _objectWithoutProperties(_ref3, ['status']);
|
||||
|
||||
var visible = status === STATUS_ADD || status === STATUS_KEEP;
|
||||
return React.createElement(
|
||||
CSSMotion,
|
||||
_extends({}, motionProps, {
|
||||
key: eventProps.key,
|
||||
visible: visible,
|
||||
eventProps: eventProps,
|
||||
onLeaveEnd: function onLeaveEnd() {
|
||||
if (motionProps.onLeaveEnd) {
|
||||
motionProps.onLeaveEnd.apply(motionProps, arguments);
|
||||
}
|
||||
_this2.removeKey(eventProps.key);
|
||||
}
|
||||
}),
|
||||
children
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}], [{
|
||||
key: 'getDerivedStateFromProps',
|
||||
value: function getDerivedStateFromProps(_ref4, _ref5) {
|
||||
var keys = _ref4.keys;
|
||||
var keyEntities = _ref5.keyEntities;
|
||||
|
||||
var parsedKeyObjects = parseKeys(keys);
|
||||
|
||||
// Always as keep when motion not support
|
||||
if (!transitionSupport) {
|
||||
return {
|
||||
keyEntities: parsedKeyObjects.map(function (obj) {
|
||||
return _extends({}, obj, { status: STATUS_KEEP });
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
var mixedKeyEntities = diffKeys(keyEntities, parsedKeyObjects);
|
||||
|
||||
var keyEntitiesLen = keyEntities.length;
|
||||
return {
|
||||
keyEntities: mixedKeyEntities.filter(function (entity) {
|
||||
// IE 9 not support Array.prototype.find
|
||||
var prevEntity = null;
|
||||
for (var i = 0; i < keyEntitiesLen; i += 1) {
|
||||
var currentEntity = keyEntities[i];
|
||||
if (currentEntity.key === entity.key) {
|
||||
prevEntity = currentEntity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove if already mark as removed
|
||||
if (prevEntity && prevEntity.status === STATUS_REMOVED && entity.status === STATUS_REMOVE) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return CSSMotionList;
|
||||
}(React.Component);
|
||||
|
||||
CSSMotionList.propTypes = _extends({}, CSSMotion.propTypes, {
|
||||
component: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
||||
keys: PropTypes.array
|
||||
});
|
||||
CSSMotionList.defaultProps = {
|
||||
component: 'div'
|
||||
};
|
||||
|
||||
|
||||
polyfill(CSSMotionList);
|
||||
|
||||
return CSSMotionList;
|
||||
}
|
||||
|
||||
export default genCSSMotionList(supportTransition);
|
||||
101
web/node_modules/rc-animate/es/ChildrenUtils.js
generated
vendored
Normal file
101
web/node_modules/rc-animate/es/ChildrenUtils.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
import React from 'react';
|
||||
|
||||
export function toArrayChildren(children) {
|
||||
var ret = [];
|
||||
React.Children.forEach(children, function (child) {
|
||||
ret.push(child);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function findChildInChildrenByKey(children, key) {
|
||||
var ret = null;
|
||||
if (children) {
|
||||
children.forEach(function (child) {
|
||||
if (ret) {
|
||||
return;
|
||||
}
|
||||
if (child && child.key === key) {
|
||||
ret = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function findShownChildInChildrenByKey(children, key, showProp) {
|
||||
var ret = null;
|
||||
if (children) {
|
||||
children.forEach(function (child) {
|
||||
if (child && child.key === key && child.props[showProp]) {
|
||||
if (ret) {
|
||||
throw new Error('two child with same key for <rc-animate> children');
|
||||
}
|
||||
ret = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function findHiddenChildInChildrenByKey(children, key, showProp) {
|
||||
var found = 0;
|
||||
if (children) {
|
||||
children.forEach(function (child) {
|
||||
if (found) {
|
||||
return;
|
||||
}
|
||||
found = child && child.key === key && !child.props[showProp];
|
||||
});
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
export function isSameChildren(c1, c2, showProp) {
|
||||
var same = c1.length === c2.length;
|
||||
if (same) {
|
||||
c1.forEach(function (child, index) {
|
||||
var child2 = c2[index];
|
||||
if (child && child2) {
|
||||
if (child && !child2 || !child && child2) {
|
||||
same = false;
|
||||
} else if (child.key !== child2.key) {
|
||||
same = false;
|
||||
} else if (showProp && child.props[showProp] !== child2.props[showProp]) {
|
||||
same = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return same;
|
||||
}
|
||||
|
||||
export function mergeChildren(prev, next) {
|
||||
var ret = [];
|
||||
|
||||
// For each key of `next`, the list of keys to insert before that key in
|
||||
// the combined list
|
||||
var nextChildrenPending = {};
|
||||
var pendingChildren = [];
|
||||
prev.forEach(function (child) {
|
||||
if (child && findChildInChildrenByKey(next, child.key)) {
|
||||
if (pendingChildren.length) {
|
||||
nextChildrenPending[child.key] = pendingChildren;
|
||||
pendingChildren = [];
|
||||
}
|
||||
} else {
|
||||
pendingChildren.push(child);
|
||||
}
|
||||
});
|
||||
|
||||
next.forEach(function (child) {
|
||||
if (child && Object.prototype.hasOwnProperty.call(nextChildrenPending, child.key)) {
|
||||
ret = ret.concat(nextChildrenPending[child.key]);
|
||||
}
|
||||
ret.push(child);
|
||||
});
|
||||
|
||||
ret = ret.concat(pendingChildren);
|
||||
|
||||
return ret;
|
||||
}
|
||||
21
web/node_modules/rc-animate/es/util/animate.js
generated
vendored
Normal file
21
web/node_modules/rc-animate/es/util/animate.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var util = {
|
||||
isAppearSupported: function isAppearSupported(props) {
|
||||
return props.transitionName && props.transitionAppear || props.animation.appear;
|
||||
},
|
||||
isEnterSupported: function isEnterSupported(props) {
|
||||
return props.transitionName && props.transitionEnter || props.animation.enter;
|
||||
},
|
||||
isLeaveSupported: function isLeaveSupported(props) {
|
||||
return props.transitionName && props.transitionLeave || props.animation.leave;
|
||||
},
|
||||
allowAppearCallback: function allowAppearCallback(props) {
|
||||
return props.transitionAppear || props.animation.appear;
|
||||
},
|
||||
allowEnterCallback: function allowEnterCallback(props) {
|
||||
return props.transitionEnter || props.animation.enter;
|
||||
},
|
||||
allowLeaveCallback: function allowLeaveCallback(props) {
|
||||
return props.transitionLeave || props.animation.leave;
|
||||
}
|
||||
};
|
||||
export default util;
|
||||
105
web/node_modules/rc-animate/es/util/diff.js
generated
vendored
Normal file
105
web/node_modules/rc-animate/es/util/diff.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
import _extends from 'babel-runtime/helpers/extends';
|
||||
export var STATUS_ADD = 'add';
|
||||
export var STATUS_KEEP = 'keep';
|
||||
export var STATUS_REMOVE = 'remove';
|
||||
export var STATUS_REMOVED = 'removed';
|
||||
|
||||
export function wrapKeyToObject(key) {
|
||||
var keyObj = void 0;
|
||||
if (key && typeof key === 'object' && 'key' in key) {
|
||||
keyObj = key;
|
||||
} else {
|
||||
keyObj = { key: key };
|
||||
}
|
||||
return _extends({}, keyObj, {
|
||||
key: String(keyObj.key)
|
||||
});
|
||||
}
|
||||
|
||||
export function parseKeys() {
|
||||
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
|
||||
return keys.map(wrapKeyToObject);
|
||||
}
|
||||
|
||||
export function diffKeys() {
|
||||
var prevKeys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
||||
var currentKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
|
||||
var list = [];
|
||||
var currentIndex = 0;
|
||||
var currentLen = currentKeys.length;
|
||||
|
||||
var prevKeyObjects = parseKeys(prevKeys);
|
||||
var currentKeyObjects = parseKeys(currentKeys);
|
||||
|
||||
// Check prev keys to insert or keep
|
||||
prevKeyObjects.forEach(function (keyObj) {
|
||||
var hit = false;
|
||||
|
||||
for (var i = currentIndex; i < currentLen; i += 1) {
|
||||
var currentKeyObj = currentKeyObjects[i];
|
||||
if (currentKeyObj.key === keyObj.key) {
|
||||
// New added keys should add before current key
|
||||
if (currentIndex < i) {
|
||||
list = list.concat(currentKeyObjects.slice(currentIndex, i).map(function (obj) {
|
||||
return _extends({}, obj, { status: STATUS_ADD });
|
||||
}));
|
||||
currentIndex = i;
|
||||
}
|
||||
list.push(_extends({}, currentKeyObj, {
|
||||
status: STATUS_KEEP
|
||||
}));
|
||||
currentIndex += 1;
|
||||
|
||||
hit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If not hit, it means key is removed
|
||||
if (!hit) {
|
||||
list.push(_extends({}, keyObj, {
|
||||
status: STATUS_REMOVE
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
// Add rest to the list
|
||||
if (currentIndex < currentLen) {
|
||||
list = list.concat(currentKeyObjects.slice(currentIndex).map(function (obj) {
|
||||
return _extends({}, obj, { status: STATUS_ADD });
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge same key when it remove and add again:
|
||||
* [1 - add, 2 - keep, 1 - remove] -> [1 - keep, 2 - keep]
|
||||
*/
|
||||
var keys = {};
|
||||
list.forEach(function (_ref) {
|
||||
var key = _ref.key;
|
||||
|
||||
keys[key] = (keys[key] || 0) + 1;
|
||||
});
|
||||
var duplicatedKeys = Object.keys(keys).filter(function (key) {
|
||||
return keys[key] > 1;
|
||||
});
|
||||
duplicatedKeys.forEach(function (matchKey) {
|
||||
// Remove `STATUS_REMOVE` node.
|
||||
list = list.filter(function (_ref2) {
|
||||
var key = _ref2.key,
|
||||
status = _ref2.status;
|
||||
return key !== matchKey || status !== STATUS_REMOVE;
|
||||
});
|
||||
|
||||
// Update `STATUS_ADD` to `STATUS_KEEP`
|
||||
list.forEach(function (node) {
|
||||
if (node.key === matchKey) {
|
||||
node.status = STATUS_KEEP;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
83
web/node_modules/rc-animate/es/util/motion.js
generated
vendored
Normal file
83
web/node_modules/rc-animate/es/util/motion.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
||||
|
||||
// ================= Transition =================
|
||||
// Event wrapper. Copy from react source code
|
||||
function makePrefixMap(styleProp, eventName) {
|
||||
var prefixes = {};
|
||||
|
||||
prefixes[styleProp.toLowerCase()] = eventName.toLowerCase();
|
||||
prefixes['Webkit' + styleProp] = 'webkit' + eventName;
|
||||
prefixes['Moz' + styleProp] = 'moz' + eventName;
|
||||
prefixes['ms' + styleProp] = 'MS' + eventName;
|
||||
prefixes['O' + styleProp] = 'o' + eventName.toLowerCase();
|
||||
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
export function getVendorPrefixes(domSupport, win) {
|
||||
var prefixes = {
|
||||
animationend: makePrefixMap('Animation', 'AnimationEnd'),
|
||||
transitionend: makePrefixMap('Transition', 'TransitionEnd')
|
||||
};
|
||||
|
||||
if (domSupport) {
|
||||
if (!('AnimationEvent' in win)) {
|
||||
delete prefixes.animationend.animation;
|
||||
}
|
||||
|
||||
if (!('TransitionEvent' in win)) {
|
||||
delete prefixes.transitionend.transition;
|
||||
}
|
||||
}
|
||||
|
||||
return prefixes;
|
||||
}
|
||||
|
||||
var vendorPrefixes = getVendorPrefixes(canUseDOM, typeof window !== 'undefined' ? window : {});
|
||||
|
||||
var style = {};
|
||||
|
||||
if (canUseDOM) {
|
||||
style = document.createElement('div').style;
|
||||
}
|
||||
|
||||
var prefixedEventNames = {};
|
||||
|
||||
export function getVendorPrefixedEventName(eventName) {
|
||||
if (prefixedEventNames[eventName]) {
|
||||
return prefixedEventNames[eventName];
|
||||
}
|
||||
|
||||
var prefixMap = vendorPrefixes[eventName];
|
||||
|
||||
if (prefixMap) {
|
||||
var stylePropList = Object.keys(prefixMap);
|
||||
var len = stylePropList.length;
|
||||
for (var i = 0; i < len; i += 1) {
|
||||
var styleProp = stylePropList[i];
|
||||
if (Object.prototype.hasOwnProperty.call(prefixMap, styleProp) && styleProp in style) {
|
||||
prefixedEventNames[eventName] = prefixMap[styleProp];
|
||||
return prefixedEventNames[eventName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
export var animationEndName = getVendorPrefixedEventName('animationend');
|
||||
export var transitionEndName = getVendorPrefixedEventName('transitionend');
|
||||
export var supportTransition = !!(animationEndName && transitionEndName);
|
||||
|
||||
export function getTransitionName(transitionName, transitionType) {
|
||||
if (!transitionName) return null;
|
||||
|
||||
if (typeof transitionName === 'object') {
|
||||
var type = transitionType.replace(/-\w/g, function (match) {
|
||||
return match[1].toUpperCase();
|
||||
});
|
||||
return transitionName[type];
|
||||
}
|
||||
|
||||
return transitionName + '-' + transitionType;
|
||||
}
|
||||
Reference in New Issue
Block a user