Skip to content
Snippets Groups Projects
Commit fa1a355a authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[simplescrollbar addon] Make sure bar position is clipped after update

Closes #3891
parent 1de61c6a
No related branches found
No related tags found
No related merge requests found
...@@ -59,16 +59,20 @@ ...@@ -59,16 +59,20 @@
CodeMirror.on(this.node, "DOMMouseScroll", onWheel); CodeMirror.on(this.node, "DOMMouseScroll", onWheel);
} }
Bar.prototype.moveTo = function(pos, update) { Bar.prototype.setPos = function(pos) {
if (pos < 0) pos = 0; if (pos < 0) pos = 0;
if (pos > this.total - this.screen) pos = this.total - this.screen; if (pos > this.total - this.screen) pos = this.total - this.screen;
if (pos == this.pos) return; if (pos == this.pos) return false;
this.pos = pos; this.pos = pos;
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] = this.inner.style[this.orientation == "horizontal" ? "left" : "top"] =
(pos * (this.size / this.total)) + "px"; (pos * (this.size / this.total)) + "px";
if (update !== false) this.scroll(pos, this.orientation); return true
}; };
Bar.prototype.moveTo = function(pos) {
if (this.setPos(pos)) this.scroll(pos, this.orientation);
}
var minButtonSize = 10; var minButtonSize = 10;
Bar.prototype.update = function(scrollSize, clientSize, barSize) { Bar.prototype.update = function(scrollSize, clientSize, barSize) {
...@@ -83,8 +87,7 @@ ...@@ -83,8 +87,7 @@
} }
this.inner.style[this.orientation == "horizontal" ? "width" : "height"] = this.inner.style[this.orientation == "horizontal" ? "width" : "height"] =
buttonSize + "px"; buttonSize + "px";
this.inner.style[this.orientation == "horizontal" ? "left" : "top"] = this.setPos(this.pos);
this.pos * (this.size / this.total) + "px";
}; };
function SimpleScrollbars(cls, place, scroll) { function SimpleScrollbars(cls, place, scroll) {
...@@ -111,7 +114,6 @@ ...@@ -111,7 +114,6 @@
if (needsV) { if (needsV) {
this.vert.update(measure.scrollHeight, measure.clientHeight, this.vert.update(measure.scrollHeight, measure.clientHeight,
measure.viewHeight - (needsH ? width : 0)); measure.viewHeight - (needsH ? width : 0));
this.vert.node.style.display = "block";
this.vert.node.style.bottom = needsH ? width + "px" : "0"; this.vert.node.style.bottom = needsH ? width + "px" : "0";
} }
if (needsH) { if (needsH) {
...@@ -125,11 +127,11 @@ ...@@ -125,11 +127,11 @@
}; };
SimpleScrollbars.prototype.setScrollTop = function(pos) { SimpleScrollbars.prototype.setScrollTop = function(pos) {
this.vert.moveTo(pos, false); this.vert.setPos(pos);
}; };
SimpleScrollbars.prototype.setScrollLeft = function(pos) { SimpleScrollbars.prototype.setScrollLeft = function(pos) {
this.horiz.moveTo(pos, false); this.horiz.setPos(pos);
}; };
SimpleScrollbars.prototype.clear = function() { SimpleScrollbars.prototype.clear = function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment