Merge pull request #252 from tkhyn/master
Detects margins around the rails
This commit is contained in:
commit
20576ac717
@ -112,6 +112,8 @@
|
|||||||
var isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom; // !isNaN
|
var isScrollbarXUsingBottom = scrollbarXBottom === scrollbarXBottom; // !isNaN
|
||||||
var scrollbarXTop = isScrollbarXUsingBottom ? null : getInt($scrollbarXRail.css('top'));
|
var scrollbarXTop = isScrollbarXUsingBottom ? null : getInt($scrollbarXRail.css('top'));
|
||||||
var railBorderXWidth = getInt($scrollbarXRail.css('borderLeftWidth')) + getInt($scrollbarXRail.css('borderRightWidth'));
|
var railBorderXWidth = getInt($scrollbarXRail.css('borderLeftWidth')) + getInt($scrollbarXRail.css('borderRightWidth'));
|
||||||
|
var railXMarginWidth = getInt($scrollbarXRail.css('marginLeft')) + getInt($scrollbarXRail.css('marginRight'));
|
||||||
|
var railXWidth;
|
||||||
|
|
||||||
var $scrollbarYRail = $("<div class='ps-scrollbar-y-rail'>").appendTo($this);
|
var $scrollbarYRail = $("<div class='ps-scrollbar-y-rail'>").appendTo($this);
|
||||||
var $scrollbarY = $("<div class='ps-scrollbar-y'>").appendTo($scrollbarYRail);
|
var $scrollbarY = $("<div class='ps-scrollbar-y'>").appendTo($scrollbarYRail);
|
||||||
@ -122,6 +124,8 @@
|
|||||||
var isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight; // !isNaN
|
var isScrollbarYUsingRight = scrollbarYRight === scrollbarYRight; // !isNaN
|
||||||
var scrollbarYLeft = isScrollbarYUsingRight ? null : getInt($scrollbarYRail.css('left'));
|
var scrollbarYLeft = isScrollbarYUsingRight ? null : getInt($scrollbarYRail.css('left'));
|
||||||
var railBorderYWidth = getInt($scrollbarYRail.css('borderTopWidth')) + getInt($scrollbarYRail.css('borderBottomWidth'));
|
var railBorderYWidth = getInt($scrollbarYRail.css('borderTopWidth')) + getInt($scrollbarYRail.css('borderBottomWidth'));
|
||||||
|
var railYMarginHeight = getInt($scrollbarYRail.css('marginTop')) + getInt($scrollbarYRail.css('marginBottom'));
|
||||||
|
var railYHeight;
|
||||||
|
|
||||||
function updateScrollTop(currentTop, deltaY) {
|
function updateScrollTop(currentTop, deltaY) {
|
||||||
var newTop = currentTop + deltaY;
|
var newTop = currentTop + deltaY;
|
||||||
@ -166,7 +170,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateCss() {
|
function updateCss() {
|
||||||
var xRailOffset = {width: containerWidth};
|
var xRailOffset = {width: railXWidth};
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
xRailOffset.left = $this.scrollLeft() + containerWidth - contentWidth;
|
xRailOffset.left = $this.scrollLeft() + containerWidth - contentWidth;
|
||||||
} else {
|
} else {
|
||||||
@ -179,7 +183,7 @@
|
|||||||
}
|
}
|
||||||
$scrollbarXRail.css(xRailOffset);
|
$scrollbarXRail.css(xRailOffset);
|
||||||
|
|
||||||
var railYOffset = {top: $this.scrollTop(), height: containerHeight};
|
var railYOffset = {top: $this.scrollTop(), height: railYHeight};
|
||||||
|
|
||||||
if (isScrollbarYUsingRight) {
|
if (isScrollbarYUsingRight) {
|
||||||
if (isRtl) {
|
if (isRtl) {
|
||||||
@ -212,8 +216,9 @@
|
|||||||
|
|
||||||
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
|
if (!settings.suppressScrollX && containerWidth + settings.scrollXMarginOffset < contentWidth) {
|
||||||
scrollbarXActive = true;
|
scrollbarXActive = true;
|
||||||
scrollbarXWidth = getThumbSize(getInt(containerWidth * containerWidth / contentWidth));
|
railXWidth = containerWidth - railXMarginWidth;
|
||||||
scrollbarXLeft = getInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth));
|
scrollbarXWidth = getThumbSize(getInt(railXWidth * containerWidth / contentWidth));
|
||||||
|
scrollbarXLeft = getInt($this.scrollLeft() * (railXWidth - scrollbarXWidth) / (contentWidth - containerWidth));
|
||||||
} else {
|
} else {
|
||||||
scrollbarXActive = false;
|
scrollbarXActive = false;
|
||||||
scrollbarXWidth = 0;
|
scrollbarXWidth = 0;
|
||||||
@ -223,8 +228,9 @@
|
|||||||
|
|
||||||
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
|
if (!settings.suppressScrollY && containerHeight + settings.scrollYMarginOffset < contentHeight) {
|
||||||
scrollbarYActive = true;
|
scrollbarYActive = true;
|
||||||
scrollbarYHeight = getThumbSize(getInt(containerHeight * containerHeight / contentHeight));
|
railYHeight = containerHeight - railYMarginHeight;
|
||||||
scrollbarYTop = getInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight));
|
scrollbarYHeight = getThumbSize(getInt(railYHeight * containerHeight / contentHeight));
|
||||||
|
scrollbarYTop = getInt($this.scrollTop() * (railYHeight - scrollbarYHeight) / (contentHeight - containerHeight));
|
||||||
} else {
|
} else {
|
||||||
scrollbarYActive = false;
|
scrollbarYActive = false;
|
||||||
scrollbarYHeight = 0;
|
scrollbarYHeight = 0;
|
||||||
@ -232,11 +238,11 @@
|
|||||||
$this.scrollTop(0);
|
$this.scrollTop(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollbarXLeft >= containerWidth - scrollbarXWidth) {
|
if (scrollbarXLeft >= railXWidth - scrollbarXWidth) {
|
||||||
scrollbarXLeft = containerWidth - scrollbarXWidth;
|
scrollbarXLeft = railXWidth - scrollbarXWidth;
|
||||||
}
|
}
|
||||||
if (scrollbarYTop >= containerHeight - scrollbarYHeight) {
|
if (scrollbarYTop >= railYHeight - scrollbarYHeight) {
|
||||||
scrollbarYTop = containerHeight - scrollbarYHeight;
|
scrollbarYTop = railYHeight - scrollbarYHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCss();
|
updateCss();
|
||||||
|
Loading…
Reference in New Issue
Block a user