Fix the formula between scroll position and scrollbar position.
With @Mordhak's suggestion, fixed the formula to calculate the values. This patch will resolve the scroll position problem when the minScrollbarLength setting is applied.
This commit is contained in:
parent
68032d168b
commit
123b1d724b
@ -56,13 +56,13 @@
|
|||||||
scrollbarYRight = parseInt($scrollbarY.css('right'), 10);
|
scrollbarYRight = parseInt($scrollbarY.css('right'), 10);
|
||||||
|
|
||||||
var updateContentScrollTop = function () {
|
var updateContentScrollTop = function () {
|
||||||
var scrollTop = parseInt(scrollbarYTop * contentHeight / containerHeight, 10);
|
var scrollTop = parseInt(scrollbarYTop * (contentHeight - containerHeight) / (containerHeight - scrollbarYHeight), 10);
|
||||||
$this.scrollTop(scrollTop);
|
$this.scrollTop(scrollTop);
|
||||||
$scrollbarX.css({bottom: scrollbarXBottom - scrollTop});
|
$scrollbarX.css({bottom: scrollbarXBottom - scrollTop});
|
||||||
};
|
};
|
||||||
|
|
||||||
var updateContentScrollLeft = function () {
|
var updateContentScrollLeft = function () {
|
||||||
var scrollLeft = parseInt(scrollbarXLeft * contentWidth / containerWidth, 10);
|
var scrollLeft = parseInt(scrollbarXLeft * (contentWidth - containerWidth) / (containerWidth - scrollbarXWidth), 10);
|
||||||
$this.scrollLeft(scrollLeft);
|
$this.scrollLeft(scrollLeft);
|
||||||
$scrollbarY.css({right: scrollbarYRight - scrollLeft});
|
$scrollbarY.css({right: scrollbarYRight - scrollLeft});
|
||||||
};
|
};
|
||||||
@ -86,7 +86,7 @@
|
|||||||
contentHeight = $this.prop('scrollHeight');
|
contentHeight = $this.prop('scrollHeight');
|
||||||
if (containerWidth < contentWidth) {
|
if (containerWidth < contentWidth) {
|
||||||
scrollbarXWidth = getSettingsAdjustedThumbSize(parseInt(containerWidth * containerWidth / contentWidth, 10));
|
scrollbarXWidth = getSettingsAdjustedThumbSize(parseInt(containerWidth * containerWidth / contentWidth, 10));
|
||||||
scrollbarXLeft = parseInt($this.scrollLeft() * containerWidth / contentWidth, 10);
|
scrollbarXLeft = parseInt($this.scrollLeft() * (containerWidth - scrollbarXWidth) / (contentWidth - containerWidth), 10);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scrollbarXWidth = 0;
|
scrollbarXWidth = 0;
|
||||||
@ -95,7 +95,7 @@
|
|||||||
}
|
}
|
||||||
if (containerHeight < contentHeight) {
|
if (containerHeight < contentHeight) {
|
||||||
scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(containerHeight * containerHeight / contentHeight, 10));
|
scrollbarYHeight = getSettingsAdjustedThumbSize(parseInt(containerHeight * containerHeight / contentHeight, 10));
|
||||||
scrollbarYTop = parseInt($this.scrollTop() * containerHeight / contentHeight, 10);
|
scrollbarYTop = parseInt($this.scrollTop() * (containerHeight - scrollbarYHeight) / (contentHeight - containerHeight), 10);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scrollbarYHeight = 0;
|
scrollbarYHeight = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user