Skip to content

Commit

Permalink
fix: only take directionThreshold into account when actually snapping
Browse files Browse the repository at this point in the history
  • Loading branch information
guidobouman committed May 8, 2018
1 parent 21bcbe9 commit 079f390
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/panelSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,17 @@ export default class PanelSnap {
const delta = this.scrollContainer.scrollTop - this.currentScrollOffset;
this.currentScrollOffset = this.scrollContainer.scrollTop;

if (Math.abs(delta) < this.options.directionThreshold && this.activePanel) {
this.snapToPanel(this.activePanel);
return;
}

const panelsInViewport = getElementsInContainerViewport(this.container, this.panelList);
if (panelsInViewport.length === 0) {
throw new Error('PanelSnap could not find a snappable panel, aborting.');
}

if (panelsInViewport.length > 1) {
if (Math.abs(delta) < this.options.directionThreshold && this.activePanel) {
this.snapToPanel(this.activePanel);
return;
}

const targetIndex = delta > 0 ? 1 : panelsInViewport.length - 2;
this.snapToPanel(panelsInViewport[targetIndex], delta < 0);
return;
Expand Down

0 comments on commit 079f390

Please sign in to comment.