From 8f24c1a0d783486eba2da6578e32e5450ef1b5b1 Mon Sep 17 00:00:00 2001 From: Reimund Trost Date: Fri, 10 Aug 2012 16:41:23 +0200 Subject: [PATCH 1/4] Update handle container on repaint as well. --- jquery.scroll.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jquery.scroll.js b/jquery.scroll.js index fd80020..e6190ea 100644 --- a/jquery.scroll.js +++ b/jquery.scroll.js @@ -458,10 +458,24 @@ Changelog: // repaint scrollbar height and position // repaint: function(){ + this.setHandleContainerSize(); this.setHandle(); this.setHandlePosition(); }, + // + // update the height of the handleContainer + // + setHandleContainerSize: function() { + this.props.containerHeight = this.container.height(); + + this.handleContainer.css({ + 'position': 'absolute', + 'top': this.handleArrowUp.outerHeight(true), + 'height': (this.props.containerHeight - this.handleArrowUp.outerHeight(true) - this.handleArrowDown.outerHeight(true)) + 'px' + }); + }, + // // scroll to a specific distance from the top From b41e4e0b751f64d5472a72726cb0fb7ca4091bf7 Mon Sep 17 00:00:00 2001 From: Reimund Trost Date: Mon, 13 Aug 2012 11:13:45 +0200 Subject: [PATCH 2/4] Hide scroller when container is resized to be bigger than the content. --- jquery.scroll.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/jquery.scroll.js b/jquery.scroll.js index e6190ea..ccc2dce 100644 --- a/jquery.scroll.js +++ b/jquery.scroll.js @@ -458,23 +458,35 @@ Changelog: // repaint scrollbar height and position // repaint: function(){ - this.setHandleContainerSize(); + this.setHandleContainerSize(); this.setHandle(); this.setHandlePosition(); }, - // - // update the height of the handleContainer - // + // + // update the height of the handleContainer + // setHandleContainerSize: function() { this.props.containerHeight = this.container.height(); + // hide the scroller if the content height is lower than the + // container height + if(this.props.contentHeight <= this.props.containerHeight) { + this.handleContainer.hide(); + this.handleArrowDown.hide(); + this.handleArrowUp.hide(); + } else { + this.handleContainer.show(); + this.handleArrowDown.show(); + this.handleArrowUp.show(); + } + this.handleContainer.css({ 'position': 'absolute', 'top': this.handleArrowUp.outerHeight(true), 'height': (this.props.containerHeight - this.handleArrowUp.outerHeight(true) - this.handleArrowDown.outerHeight(true)) + 'px' }); - }, + }, // From 5681e75340215cc664940e4a6b8a623355c9663b Mon Sep 17 00:00:00 2001 From: Reimund Trost Date: Mon, 13 Aug 2012 14:19:35 +0200 Subject: [PATCH 3/4] Scroll up as content gets bigger. --- jquery.scroll.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jquery.scroll.js b/jquery.scroll.js index ccc2dce..f5f632e 100644 --- a/jquery.scroll.js +++ b/jquery.scroll.js @@ -125,9 +125,9 @@ Changelog: props.contentHeight = $.fn.scrollbar.contentHeight(container); // if the content height is lower than the container height, do nothing and return. - if(props.contentHeight <= props.containerHeight){ - return true; - } + //if(props.contentHeight <= props.containerHeight){ + //return true; + //} // create a new scrollbar object and append to DOM node for later use this.scrollbar = new $.fn.scrollbar.Scrollbar(container, props, options); @@ -139,11 +139,13 @@ Changelog: if(typeof fn === "function"){ fn(container.find(".scrollbar-pane"), this.scrollbar); } + + this.scrollbar.repaint(); }); }, - // repaint the height and position of the scroll handle + // repaint the height and position of the scroll handle // // this method must be called in case content is added or reoved from the container. // @@ -467,6 +469,8 @@ Changelog: // update the height of the handleContainer // setHandleContainerSize: function() { + var deltaY = this.props.containerHeight - this.container.height(); + this.props.containerHeight = this.container.height(); // hide the scroller if the content height is lower than the @@ -486,6 +490,11 @@ Changelog: 'top': this.handleArrowUp.outerHeight(true), 'height': (this.props.containerHeight - this.handleArrowUp.outerHeight(true) - this.handleArrowDown.outerHeight(true)) + 'px' }); + + // Scroll up content as container gets bigger. + this.handle.top -= deltaY; + this.setHandlePosition(); + this.setContentPosition(); }, From e5b39148547995a8b9c4356534a58181a10eb18e Mon Sep 17 00:00:00 2001 From: Reimund Trost Date: Mon, 13 Aug 2012 14:26:39 +0200 Subject: [PATCH 4/4] Removed code that was commented out (should had gone with the previous commit). --- jquery.scroll.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/jquery.scroll.js b/jquery.scroll.js index f5f632e..231e347 100644 --- a/jquery.scroll.js +++ b/jquery.scroll.js @@ -124,11 +124,6 @@ Changelog: // save content height in properties props.contentHeight = $.fn.scrollbar.contentHeight(container); - // if the content height is lower than the container height, do nothing and return. - //if(props.contentHeight <= props.containerHeight){ - //return true; - //} - // create a new scrollbar object and append to DOM node for later use this.scrollbar = new $.fn.scrollbar.Scrollbar(container, props, options);