Completely updated React, fixed #11, (hopefully)
This commit is contained in:
250
goTorrentWebUI/node_modules/material-ui/transitions/Slide.js
generated
vendored
250
goTorrentWebUI/node_modules/material-ui/transitions/Slide.js
generated
vendored
@@ -38,6 +38,10 @@ var _react = require('react');
|
||||
|
||||
var _react2 = _interopRequireDefault(_react);
|
||||
|
||||
var _propTypes = require('prop-types');
|
||||
|
||||
var _propTypes2 = _interopRequireDefault(_propTypes);
|
||||
|
||||
var _reactDom = require('react-dom');
|
||||
|
||||
var _reactEventListener = require('react-event-listener');
|
||||
@@ -52,21 +56,22 @@ var _Transition = require('react-transition-group/Transition');
|
||||
|
||||
var _Transition2 = _interopRequireDefault(_Transition);
|
||||
|
||||
var _ownerWindow = require('dom-helpers/ownerWindow');
|
||||
|
||||
var _ownerWindow2 = _interopRequireDefault(_ownerWindow);
|
||||
|
||||
var _withTheme = require('../styles/withTheme');
|
||||
|
||||
var _withTheme2 = _interopRequireDefault(_withTheme);
|
||||
|
||||
var _transitions = require('../styles/transitions');
|
||||
|
||||
var _utils = require('./utils');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_Element = require('react').babelPluginFlowReactPropTypes_proptype_Element || require('prop-types').any;
|
||||
// @inheritedComponent Transition
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_TransitionCallback = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionCallback || require('prop-types').any;
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_TransitionDuration = require('../internal/transition').babelPluginFlowReactPropTypes_proptype_TransitionDuration || require('prop-types').any;
|
||||
|
||||
var GUTTER = 24;
|
||||
|
||||
// Translate the node so he can't be seen on the screen.
|
||||
@@ -82,7 +87,7 @@ function getTranslateValue(props, node) {
|
||||
if (node.fakeTransform) {
|
||||
transform = node.fakeTransform;
|
||||
} else {
|
||||
var computedStyle = window.getComputedStyle(node);
|
||||
var computedStyle = (0, _ownerWindow2.default)(node).getComputedStyle(node);
|
||||
transform = computedStyle.getPropertyValue('-webkit-transform') || computedStyle.getPropertyValue('transform');
|
||||
}
|
||||
|
||||
@@ -103,7 +108,7 @@ function getTranslateValue(props, node) {
|
||||
return 'translateY(100vh) translateY(-' + (rect.top - offsetY) + 'px)';
|
||||
}
|
||||
|
||||
// direction === 'down
|
||||
// direction === 'down'
|
||||
return 'translate3d(0, ' + (0 - (rect.top + rect.height)) + 'px, 0)';
|
||||
}
|
||||
|
||||
@@ -116,75 +121,10 @@ function setTranslateValue(props, node) {
|
||||
}
|
||||
}
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_Direction = require('prop-types').oneOf(['left', 'right', 'up', 'down']);
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_Props = {
|
||||
/**
|
||||
* A single child content element.
|
||||
*/
|
||||
children: typeof babelPluginFlowReactPropTypes_proptype_Element === 'function' ? babelPluginFlowReactPropTypes_proptype_Element.isRequired ? babelPluginFlowReactPropTypes_proptype_Element.isRequired : babelPluginFlowReactPropTypes_proptype_Element : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Element).isRequired,
|
||||
|
||||
/**
|
||||
* Direction the child node will enter from.
|
||||
*/
|
||||
direction: require('prop-types').oneOf(['left', 'right', 'up', 'down']),
|
||||
|
||||
/**
|
||||
* If `true`, show the component; triggers the enter or exit animation.
|
||||
*/
|
||||
in: require('prop-types').bool.isRequired,
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEnter: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntering: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntered: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExit: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExiting: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExited: typeof babelPluginFlowReactPropTypes_proptype_TransitionCallback === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionCallback : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionCallback),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: require('prop-types').object,
|
||||
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
*/
|
||||
timeout: typeof babelPluginFlowReactPropTypes_proptype_TransitionDuration === 'function' ? babelPluginFlowReactPropTypes_proptype_TransitionDuration : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_TransitionDuration),
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
theme: require('prop-types').object
|
||||
};
|
||||
|
||||
|
||||
var reflow = function reflow(node) {
|
||||
return node.scrollTop;
|
||||
};
|
||||
/**
|
||||
* The Slide transition is used by the [Snackbar](/demos/snackbars) component.
|
||||
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
||||
*/
|
||||
|
||||
var Slide = function (_React$Component) {
|
||||
(0, _inherits3.default)(Slide, _React$Component);
|
||||
@@ -201,8 +141,7 @@ var Slide = function (_React$Component) {
|
||||
}
|
||||
|
||||
return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref = Slide.__proto__ || (0, _getPrototypeOf2.default)(Slide)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
|
||||
// We use this state to handle the server-side rendering.
|
||||
firstMount: true
|
||||
mounted: false
|
||||
}, _this.transition = null, _this.handleResize = (0, _debounce2.default)(function () {
|
||||
// Skip configuration where the position is screen size invariant.
|
||||
if (_this.props.in || _this.props.direction === 'down' || _this.props.direction === 'right') {
|
||||
@@ -210,29 +149,34 @@ var Slide = function (_React$Component) {
|
||||
}
|
||||
|
||||
var node = (0, _reactDom.findDOMNode)(_this.transition);
|
||||
if (node instanceof HTMLElement) {
|
||||
if (node) {
|
||||
setTranslateValue(_this.props, node);
|
||||
}
|
||||
}, 166), _this.handleEnter = function (node) {
|
||||
setTranslateValue(_this.props, node);
|
||||
reflow(node);
|
||||
(0, _utils.reflow)(node);
|
||||
|
||||
if (_this.props.onEnter) {
|
||||
_this.props.onEnter(node);
|
||||
}
|
||||
}, _this.handleEntering = function (node) {
|
||||
var _this$props = _this.props,
|
||||
theme = _this$props.theme,
|
||||
timeout = _this$props.timeout;
|
||||
var theme = _this.props.theme;
|
||||
|
||||
var _getTransitionProps = (0, _utils.getTransitionProps)(_this.props, {
|
||||
mode: 'enter'
|
||||
}),
|
||||
transitionDuration = _getTransitionProps.duration,
|
||||
delay = _getTransitionProps.delay;
|
||||
|
||||
node.style.transition = theme.transitions.create('transform', {
|
||||
duration: typeof timeout === 'number' ? timeout : timeout.enter,
|
||||
easing: theme.transitions.easing.easeOut
|
||||
duration: transitionDuration,
|
||||
easing: theme.transitions.easing.easeOut,
|
||||
delay: delay
|
||||
});
|
||||
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
|
||||
node.style.webkitTransition = theme.transitions.create('-webkit-transform', {
|
||||
duration: typeof timeout === 'number' ? timeout : timeout.enter,
|
||||
easing: theme.transitions.easing.easeOut
|
||||
duration: transitionDuration,
|
||||
easing: theme.transitions.easing.easeOut,
|
||||
delay: delay
|
||||
});
|
||||
node.style.transform = 'translate3d(0, 0, 0)';
|
||||
node.style.webkitTransform = 'translate3d(0, 0, 0)';
|
||||
@@ -240,54 +184,81 @@ var Slide = function (_React$Component) {
|
||||
_this.props.onEntering(node);
|
||||
}
|
||||
}, _this.handleExit = function (node) {
|
||||
var _this$props2 = _this.props,
|
||||
theme = _this$props2.theme,
|
||||
timeout = _this$props2.timeout;
|
||||
var theme = _this.props.theme;
|
||||
|
||||
var _getTransitionProps2 = (0, _utils.getTransitionProps)(_this.props, {
|
||||
mode: 'exit'
|
||||
}),
|
||||
transitionDuration = _getTransitionProps2.duration,
|
||||
delay = _getTransitionProps2.delay;
|
||||
|
||||
node.style.transition = theme.transitions.create('transform', {
|
||||
duration: typeof timeout === 'number' ? timeout : timeout.exit,
|
||||
easing: theme.transitions.easing.sharp
|
||||
duration: transitionDuration,
|
||||
easing: theme.transitions.easing.sharp,
|
||||
delay: delay
|
||||
});
|
||||
// $FlowFixMe - https://github.com/facebook/flow/pull/5161
|
||||
node.style.webkitTransition = theme.transitions.create('-webkit-transform', {
|
||||
duration: typeof timeout === 'number' ? timeout : timeout.exit,
|
||||
easing: theme.transitions.easing.sharp
|
||||
duration: transitionDuration,
|
||||
easing: theme.transitions.easing.sharp,
|
||||
delay: delay
|
||||
});
|
||||
setTranslateValue(_this.props, node);
|
||||
|
||||
if (_this.props.onExit) {
|
||||
_this.props.onExit(node);
|
||||
}
|
||||
}, _this.handleExited = function (node) {
|
||||
// No need for transitions when the component is hidden
|
||||
node.style.transition = '';
|
||||
node.style.webkitTransition = '';
|
||||
|
||||
if (_this.props.onExited) {
|
||||
_this.props.onExited(node);
|
||||
}
|
||||
}, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret);
|
||||
}
|
||||
|
||||
(0, _createClass3.default)(Slide, [{
|
||||
key: 'componentDidMount',
|
||||
value: function componentDidMount() {
|
||||
// state.firstMount handle SSR, once the component is mounted, we need
|
||||
// to propery hide it.
|
||||
// state.mounted handle SSR, once the component is mounted, we need
|
||||
// to properly hide it.
|
||||
if (!this.props.in) {
|
||||
// We need to set initial translate values of transition element
|
||||
// otherwise component will be shown when in=false.
|
||||
var element = (0, _reactDom.findDOMNode)(this.transition);
|
||||
if (element instanceof HTMLElement) {
|
||||
element.style.visibility = 'inherit';
|
||||
setTranslateValue(this.props, element);
|
||||
}
|
||||
this.updatePosition();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillReceiveProps',
|
||||
value: function componentWillReceiveProps() {
|
||||
this.setState({
|
||||
firstMount: false
|
||||
mounted: true
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'componentDidUpdate',
|
||||
value: function componentDidUpdate(prevProps) {
|
||||
if (prevProps.direction !== this.props.direction && !this.props.in) {
|
||||
// We need to update the position of the drawer when the direction change and
|
||||
// when it's hidden.
|
||||
this.updatePosition();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'componentWillUnmount',
|
||||
value: function componentWillUnmount() {
|
||||
this.handleResize.cancel();
|
||||
}
|
||||
}, {
|
||||
key: 'updatePosition',
|
||||
value: function updatePosition() {
|
||||
var node = (0, _reactDom.findDOMNode)(this.transition);
|
||||
if (node) {
|
||||
node.style.visibility = 'inherit';
|
||||
setTranslateValue(this.props, node);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
@@ -298,17 +269,23 @@ var Slide = function (_React$Component) {
|
||||
onEnter = _props.onEnter,
|
||||
onEntering = _props.onEntering,
|
||||
onExit = _props.onExit,
|
||||
onExited = _props.onExited,
|
||||
styleProp = _props.style,
|
||||
theme = _props.theme,
|
||||
other = (0, _objectWithoutProperties3.default)(_props, ['children', 'onEnter', 'onEntering', 'onExit', 'style', 'theme']);
|
||||
other = (0, _objectWithoutProperties3.default)(_props, ['children', 'onEnter', 'onEntering', 'onExit', 'onExited', 'style', 'theme']);
|
||||
|
||||
|
||||
var style = (0, _extends3.default)({}, styleProp);
|
||||
var style = {};
|
||||
|
||||
if (!this.props.in && this.state.firstMount) {
|
||||
// We use this state to handle the server-side rendering.
|
||||
// We don't know the width of the children ahead of time.
|
||||
// We need to render it.
|
||||
if (!this.props.in && !this.state.mounted) {
|
||||
style.visibility = 'hidden';
|
||||
}
|
||||
|
||||
style = (0, _extends3.default)({}, style, styleProp, _react2.default.isValidElement(children) ? children.props.style : {});
|
||||
|
||||
return _react2.default.createElement(
|
||||
_reactEventListener2.default,
|
||||
{ target: 'window', onResize: this.handleResize },
|
||||
@@ -318,13 +295,13 @@ var Slide = function (_React$Component) {
|
||||
onEnter: this.handleEnter,
|
||||
onEntering: this.handleEntering,
|
||||
onExit: this.handleExit,
|
||||
onExited: this.handleExited,
|
||||
appear: true,
|
||||
style: style
|
||||
}, other, {
|
||||
style: style,
|
||||
ref: function ref(node) {
|
||||
_this2.transition = node;
|
||||
}
|
||||
}),
|
||||
}, other),
|
||||
children
|
||||
)
|
||||
);
|
||||
@@ -333,6 +310,58 @@ var Slide = function (_React$Component) {
|
||||
return Slide;
|
||||
}(_react2.default.Component);
|
||||
|
||||
Slide.propTypes = process.env.NODE_ENV !== "production" ? {
|
||||
/**
|
||||
* A single child content element.
|
||||
*/
|
||||
children: _propTypes2.default.oneOfType([_propTypes2.default.element, _propTypes2.default.func]),
|
||||
/**
|
||||
* Direction the child node will enter from.
|
||||
*/
|
||||
direction: _propTypes2.default.oneOf(['left', 'right', 'up', 'down']),
|
||||
/**
|
||||
* If `true`, show the component; triggers the enter or exit animation.
|
||||
*/
|
||||
in: _propTypes2.default.bool,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEnter: _propTypes2.default.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntered: _propTypes2.default.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onEntering: _propTypes2.default.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExit: _propTypes2.default.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExited: _propTypes2.default.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
onExiting: _propTypes2.default.func,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
style: _propTypes2.default.object,
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
theme: _propTypes2.default.object.isRequired,
|
||||
/**
|
||||
* The duration for the transition, in milliseconds.
|
||||
* You may specify a single timeout for all transitions, or individually with an object.
|
||||
*/
|
||||
timeout: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.shape({ enter: _propTypes2.default.number, exit: _propTypes2.default.number })])
|
||||
} : {};
|
||||
|
||||
Slide.defaultProps = {
|
||||
direction: 'down',
|
||||
timeout: {
|
||||
@@ -340,4 +369,5 @@ Slide.defaultProps = {
|
||||
exit: _transitions.duration.leavingScreen
|
||||
}
|
||||
};
|
||||
|
||||
exports.default = (0, _withTheme2.default)()(Slide);
|
Reference in New Issue
Block a user