Skip to content

Commit

Permalink
Merge pull request shipshapecode#209 from HubSpot/cache-scrollbar-size
Browse files Browse the repository at this point in the history
Permanently cache scrollbar size
  • Loading branch information
TrevorBurnham authored Sep 2, 2016
2 parents 315e9ce + 5693ced commit 9977a41
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 9977a41

Please sign in to comment.