Skip to content

Commit

Permalink
bugfixes, test element + update
Browse files Browse the repository at this point in the history
- remove scrollbar test element
- clear viewElement{width,height} before reading them back on the
  `update` method.
  • Loading branch information
noeldelgado committed Feb 17, 2016
1 parent 9d4a1fe commit 3b5674c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* gemini-scrollbar
* @version 1.3.1
* @version 1.3.2
* @link http://noeldelgado.github.io/gemini-scrollbar/
* @license MIT
*/
Expand All @@ -19,15 +19,17 @@
};

function getScrollbarWidth() {
var e = document.createElement('div');
var e = document.createElement('div'), sw;
e.style.position = 'absolute';
e.style.top = '-9999px';
e.style.width = '100px';
e.style.height = '100px';
e.style.overflow = 'scroll';
e.style.msOverflowStyle = 'scrollbar';
document.body.appendChild(e);
return (e.offsetWidth - e.clientWidth);
sw = (e.offsetWidth - e.clientWidth);
document.body.removeChild(e);
return sw;
}

function addClass(el, classNames) {
Expand Down Expand Up @@ -143,6 +145,8 @@
}

var heightPercentage, widthPercentage;
this._viewElement.style.width = '';

This comment has been minimized.

Copy link
@richvdh

richvdh Apr 19, 2016

Contributor

@noeldelgado Could you help me understand why this is required? I could understand it if you wanted to set the inner div back to its natural size before reading this.element.offsetWidth - but given that the entire point here is that this.element is not free to resize with this._viewElement, I'm struggling to see how one could affect the other.

this._viewElement.style.height = '';

this._viewElement.style.width = ((this.element.offsetWidth + SCROLLBAR_WIDTH).toString() + 'px');
this._viewElement.style.height = ((this.element.offsetHeight + SCROLLBAR_WIDTH).toString() + 'px');
Expand Down

0 comments on commit 3b5674c

Please sign in to comment.