Skip to content

Instantly share code, notes, and snippets.

@kazzkiq
Created March 11, 2014 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazzkiq/9492350 to your computer and use it in GitHub Desktop.
Save kazzkiq/9492350 to your computer and use it in GitHub Desktop.
Find which elements are exploding your window size (creating scrollbars)
function scanForScrollers(el) {
var i = [],
t, x, y, w, h,
ww = $(window).width(),
wh = $(window).height();
el.each(function (index) {
t = $(this);
x = t[0].offsetLeft;
y = t[0].offsetTop;
w = t.outerWidth();
h = t.outerHeight();
if (w > ww || +x + w > ww || h > wh || +y + h > wh) {
i.push(t[0]);
}
});
return i;
}
//how to use:
var scrollers = scanForScrollers($('body *'));
$(scrollers).addClass('iFoundYou!');
@kazzkiq
Copy link
Author

kazzkiq commented Mar 11, 2014

Obvious tip: It needs jQuery to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment