Skip to content
This repository was archived by the owner on Jun 3, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/sidebar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';

const CANCEL_DISTANCE_ON_SCROLL = 20;

Expand Down Expand Up @@ -75,6 +74,7 @@ class Sidebar extends React.Component {
this.onTouchMove = this.onTouchMove.bind(this);
this.onTouchEnd = this.onTouchEnd.bind(this);
this.onScroll = this.onScroll.bind(this);
this.saveSidebarRef = this.saveSidebarRef.bind(this);
}

componentDidMount() {
Expand Down Expand Up @@ -180,13 +180,17 @@ class Sidebar extends React.Component {
}

saveSidebarWidth() {
const width = ReactDOM.findDOMNode(this.refs.sidebar).offsetWidth;
const width = this.sidebar.offsetWidth;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).


if (width !== this.state.sidebarWidth) {
this.setState({sidebarWidth: width});
}
}

saveSidebarRef(node) {
this.sidebar = node;
}

// calculate the sidebarWidth based on current touch info
touchSidebarWidth() {
// if the sidebar is open and start point of drag is inside the sidebar
Expand Down Expand Up @@ -312,7 +316,7 @@ class Sidebar extends React.Component {

return (
<div {...rootProps}>
<div className={this.props.sidebarClassName} style={sidebarStyle} ref="sidebar">
<div className={this.props.sidebarClassName} style={sidebarStyle} ref={this.saveSidebarRef}>
{this.props.sidebar}
</div>
<div className={this.props.overlayClassName}
Expand Down