Permalink
Browse files

Merge remote-tracking branch 'ept/maintain-sticky'

  • Loading branch information...
2 parents c3c8393 + 570c26a commit 3cfae4440d44b71a7ceb40935db4bac3566df701 @vitch vitch committed Apr 3, 2011
Showing with 21 additions and 3 deletions.
  1. +21 −3 script/jquery.jscrollpane.js
@@ -80,7 +80,8 @@
{
var clonedElem, tempWrapper, /*firstChild, lastChild, */isMaintainingPositon, lastContentX, lastContentY,
- hasContainingSpaceChanged, originalScrollTop, originalScrollLeft;
+ hasContainingSpaceChanged, originalScrollTop, originalScrollLeft,
+ maintainAtBottom = false, maintainAtRight = false;
settings = s;
@@ -125,6 +126,9 @@
} else {
elem.css('width', '');
+ maintainAtBottom = settings.maintainBottom && isCloseToBottom();
+ maintainAtRight = settings.maintainRight && isCloseToRight();
+
hasContainingSpaceChanged = elem.innerWidth() + originalPaddingTotalWidth != paneWidth || elem.outerHeight() != paneHeight;
if (hasContainingSpaceChanged) {
@@ -193,8 +197,8 @@
resizeScrollbars();
if (isMaintainingPositon) {
- scrollToX(lastContentX, false);
- scrollToY(lastContentY, false);
+ scrollToX(maintainAtRight ? (contentWidth - paneWidth ) : lastContentX, false);
+ scrollToY(maintainAtBottom ? (contentHeight - paneHeight) : lastContentY, false);
}
initFocusHandler();
@@ -845,6 +849,18 @@
return -pane.position().top;
}
+ function isCloseToBottom()
+ {
+ var scrollableHeight = contentHeight - paneHeight;
+ return (scrollableHeight > 20) && (scrollableHeight - contentPositionY() < 10);
+ }
+
+ function isCloseToRight()
+ {
+ var scrollableWidth = contentWidth - paneWidth;
+ return (scrollableWidth > 20) && (scrollableWidth - contentPositionX() < 10);
+ }
+
function initMousewheel()
{
container.unbind(mwEvent).bind(
@@ -1338,6 +1354,8 @@
$.fn.jScrollPane.defaults = {
showArrows : false,
maintainPosition : true,
+ maintainBottom : false,
+ maintainRight : false,
clickOnTrack : true,
autoReinitialise : false,
autoReinitialiseDelay : 500,

0 comments on commit 3cfae44

Please sign in to comment.