Skip to content

Commit

Permalink
Merge pull request #2263 from subjectix/left-nav-limit-swipe-area
Browse files Browse the repository at this point in the history
[LeftNav] swipeable only from the far left (or right) area of the page
  • Loading branch information
oliviertassinari committed Nov 26, 2015
2 parents 078a7e5 + 8447fa8 commit 414fc5a
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/left-nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,17 +331,31 @@ const LeftNav = React.createClass({
}
},

_onBodyTouchStart(e) {
_onBodyTouchStart(e) {

const swipeAreaWidth = 30;

let touchStartX = e.touches[0].pageX;
let touchStartY = e.touches[0].pageY;

// Open only if swiping from far left (or right) while closed
if (!this.state.open) {
if (this.props.openRight) {
// If openRight is true calculate from the far right
if (touchStartX < document.body.offsetWidth - swipeAreaWidth) return;
} else {
// If openRight is false calculate from the far left
if (touchStartX > swipeAreaWidth) return;
}
}

if (!this.state.open &&
(openNavEventHandler !== this._onBodyTouchStart ||
this.props.disableSwipeToOpen)
) {
return;
}

let touchStartX = e.touches[0].pageX;
let touchStartY = e.touches[0].pageY;

this._maybeSwiping = true;
this._touchStartX = touchStartX;
this._touchStartY = touchStartY;
Expand Down

0 comments on commit 414fc5a

Please sign in to comment.