From 902006e1104211c99cb691c47697177c8f5f6218 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 24 Nov 2013 14:35:38 +0400 Subject: [PATCH] do not allow editor to scroll up automatically --- lib/ace/scrollbar.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/ace/scrollbar.js b/lib/ace/scrollbar.js index 02a96e09..81cb138c 100644 --- a/lib/ace/scrollbar.js +++ b/lib/ace/scrollbar.js @@ -64,8 +64,6 @@ var ScrollBarV = function(parent, renderer) { // make element a little bit wider to retain scrollbar when page is zoomed renderer.$scrollbarWidth = this.width = dom.scrollbarWidth(parent.ownerDocument); - renderer.$scrollbarWidth = - this.width = dom.scrollbarWidth(parent.ownerDocument); this.fullWidth = this.width; this.inner.style.width = this.element.style.width = (this.width || 15) + 5 + "px"; @@ -85,12 +83,7 @@ var ScrollBarH = function(parent, renderer) { this.element.appendChild(this.inner); parent.appendChild(this.element); - - // in OSX lion the scrollbars appear to have no width. In this case resize the - // element to show the scrollbar but still pretend that the scrollbar has a width - // of 0px - // in Firefox 6+ scrollbar is hidden if element has the same width as scrollbar - // make element a little bit wider to retain scrollbar when page is zoomed + this.height = renderer.$scrollbarWidth; this.fullHeight = this.height; this.inner.style.height = @@ -181,17 +174,18 @@ var ScrollBarH = function(parent, renderer) { // on chrome 17+ for small zoom levels after calling this function // this.element.scrollTop != scrollTop which makes page to scroll up. this.setScrollTop = function(scrollTop) { - if (this.scrollTop != scrollTop) { + if (Math.abs(this.scrollTop - scrollTop) > 1) { this.skipEvent = true; - this.scrollTop = this.element.scrollTop = scrollTop; + this.scrollTop = this.element.scrollTop = Math.round(scrollTop); } }; this.setScrollLeft = function(scrollLeft) { - if (this.scrollLeft != scrollLeft) { + if (Math.abs(this.scrollLeft - scrollLeft) > 1) { this.skipEvent = true; - this.scrollLeft = this.element.scrollLeft = scrollLeft; + this.scrollLeft = this.element.scrollLeft = Math.round(scrollLeft); } }; + this.scrollTop = this.scrollLeft = 0; }).call(ScrollBarV.prototype); ScrollBarH.prototype = ScrollBarV.prototype;