Skip to content

Commit

Permalink
Permanently cache scrollbar size
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Burnham committed Sep 1, 2016
1 parent 315e9ce commit 5693ced
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion dist/js/tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ function getOffsetParent(el) {
return el.offsetParent || document.documentElement;
}

var _scrollBarSize = null;
function getScrollBarSize() {
if (_scrollBarSize) {
return _scrollBarSize;
}
var inner = document.createElement('div');
inner.style.width = '100%';
inner.style.height = '200px';
Expand Down Expand Up @@ -212,7 +216,8 @@ function getScrollBarSize() {

var width = widthContained - widthScroll;

return { width: width, height: width };
_scrollBarSize = { width: width, height: width };
return _scrollBarSize;
}

function extend() {
Expand Down
Loading

0 comments on commit 5693ced

Please sign in to comment.