+
{overlay}
- {this.props.header}
+ className={className}
+ style={this.mergeStyles(styles.root, openRight && styles.rootWhenOpenRight, style)}>
+ {header}
{children}
@@ -260,6 +369,30 @@ const LeftNav = React.createClass({
warning(!(typeof this.props.onNavOpen === 'function'),
'onNavOpen will be removed in favor of onRequestChange');
+
+ warning(!this.props.hasOwnProperty('header'),
+ 'header will be removed in favor of composability. refer to the documentation for more information');
+
+ warning(!this.props.hasOwnProperty('menuItems'),
+ 'menuItems will be removed in favor of composability. refer to the documentation for more information');
+
+ warning(!this.props.hasOwnProperty('menuItemClassName'),
+ 'menuItemClassName will be removed with menuItems.');
+
+ warning(!this.props.hasOwnProperty('menuItemClassName'),
+ 'menuItemClassName will be removed with menuItems.');
+
+ warning(!this.props.hasOwnProperty('menuItemClassNameLink'),
+ 'menuItemClassNameLink will be removed with menuItems.');
+
+ warning(!this.props.hasOwnProperty('menuItemClassNameSubheader'),
+ 'menuItemClassNameSubheader will be removed with menuItems.');
+
+ warning(!(typeof this.props.onChange === 'function'),
+ 'onChange will be removed with menuItems.');
+
+ warning(!this.props.hasOwnProperty('selectedIndex'),
+ 'selectedIndex will be removed with menuItems.');
},
_shouldShow() {
@@ -313,7 +446,8 @@ const LeftNav = React.createClass({
},
_getMaxTranslateX() {
- return this.getTheme().width + 10;
+ const width = this.props.width || this.state.muiTheme.leftNav.width;
+ return width + 10;
},
_getTranslateMultiplier() {
@@ -340,13 +474,13 @@ const LeftNav = React.createClass({
_onBodyTouchStart(e) {
- const swipeAreaWidth = 30;
+ const swipeAreaWidth = this.props.swipeAreaWidth;
- let touchStartX = e.touches[0].pageX;
- let touchStartY = e.touches[0].pageY;
+ const touchStartX = e.touches[0].pageX;
+ const touchStartY = e.touches[0].pageY;
// Open only if swiping from far left (or right) while closed
- if (!this.state.open) {
+ if (swipeAreaWidth !== null && !this.state.open) {
if (this.props.openRight) {
// If openRight is true calculate from the far right
if (touchStartX < document.body.offsetWidth - swipeAreaWidth) return;
@@ -373,8 +507,8 @@ const LeftNav = React.createClass({
},
_setPosition(translateX) {
- let leftNav = ReactDOM.findDOMNode(this.refs.clickAwayableElement);
- let transformCSS = 'translate3d(' + (this._getTranslateMultiplier() * translateX) + 'px, 0, 0)';
+ const leftNav = ReactDOM.findDOMNode(this.refs.clickAwayableElement);
+ const transformCSS = 'translate3d(' + (this._getTranslateMultiplier() * translateX) + 'px, 0, 0)';
this.refs.overlay.setOpacity(1 - translateX / this._getMaxTranslateX());
AutoPrefix.set(leftNav.style, 'transform', transformCSS);
},
@@ -392,20 +526,20 @@ const LeftNav = React.createClass({
},
_onBodyTouchMove(e) {
- let currentX = e.touches[0].pageX;
- let currentY = e.touches[0].pageY;
+ const currentX = e.touches[0].pageX;
+ const currentY = e.touches[0].pageY;
if (this.state.swiping) {
e.preventDefault();
this._setPosition(this._getTranslateX(currentX));
}
else if (this._maybeSwiping) {
- let dXAbs = Math.abs(currentX - this._touchStartX);
- let dYAbs = Math.abs(currentY - this._touchStartY);
+ const dXAbs = Math.abs(currentX - this._touchStartX);
+ const dYAbs = Math.abs(currentY - this._touchStartY);
// If the user has moved his thumb ten pixels in either direction,
// we can safely make an assumption about whether he was intending
// to swipe or scroll.
- let threshold = 10;
+ const threshold = 10;
if (dXAbs > threshold && dYAbs <= threshold) {
this._swipeStartX = currentX;
@@ -422,11 +556,11 @@ const LeftNav = React.createClass({
_onBodyTouchEnd(e) {
if (this.state.swiping) {
- let currentX = e.changedTouches[0].pageX;
- let translateRatio = this._getTranslateX(currentX) / this._getMaxTranslateX();
+ const currentX = e.changedTouches[0].pageX;
+ const translateRatio = this._getTranslateX(currentX) / this._getMaxTranslateX();
this._maybeSwiping = false;
- let swiping = this.state.swiping;
+ const swiping = this.state.swiping;
this.setState({
swiping: null,
});