FesterCluck / jquery.scrollParams

Does tests to determine if scrollbars are currently visible and determines their widths. Useful in auto-sizing situations to prevent horizontal scrollbar simple because vertical scrollbar appears.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jquery.scrollParams

$().scrollParams tests for scrollbar visibility and widths. Useful when auto sizing container DOM elements without causing window scrolling.

//Element to size var container = $("container");

//Current Stylesheet var cStyle = window.getComputedStyle(document.body);

//Dog Food var params = $("

").scrollParams();

//Which (Window or Element) is bigger? var maxHeight = Math.max(parseInt(cStyle.height, 10), window.innerHeight - container[0].offsetTop);

//Is the presence of the vertical scrollbar causing the horizontal one to appear? var isVertWhyHorz = ((window.innerWidth + scrollParams.vertical.width) > parseInt(cStyle.minWidth, 10));

//Reduce max height if scrollbars are present maxHeight -= (isVertWhyHorz * scrollParams.horizontal.width);

//Set Height container.height(maxHeight);

About

Does tests to determine if scrollbars are currently visible and determines their widths. Useful in auto-sizing situations to prevent horizontal scrollbar simple because vertical scrollbar appears.

License:Other


Languages

Language:JavaScript 100.0%