Skip to content

Commit

Permalink
feat(snapping): Snap to bottom when scrolling up into large panel.
Browse files Browse the repository at this point in the history
Fixes #96
  • Loading branch information
guidobouman committed Jan 21, 2018
1 parent 0d4f488 commit 278f114
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions jquery.panelSnap.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ if (typeof Object.create !== 'function') {

scrollTarget -= self.options.offset;

var isScrollingUp = self.scrollOffset > scrollTarget;
var isLargeTarget = $target.outerHeight() > self.$snapContainer.outerHeight();
if (isScrollingUp && isLargeTarget) {
// Snap to bottom of target
scrollTarget += $target.outerHeight();
scrollTarget -= self.$snapContainer.outerHeight();
}

self.$snapContainer.stop(true).delay(self.options.delay).animate({
scrollTop: scrollTarget
}, self.options.slideSpeed, self.options.easing, function () {
Expand Down

0 comments on commit 278f114

Please sign in to comment.