-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I need to check with jQuery if a DIV element is not falling off-screen. The elements is visible and displayed according CSS attributes but could be intentionally placed off-screen by:
position: absolute;
left: -1000px;
top: -1000px;
I could not use the jQuery :visible selector as element has non-zero height and width.
I am not doing anything fancy, this absolute position placement is the way my AJAX framework implements the hide/show of some widgets.
write a check to see if it's offscreen :
jQuery.expr.filters.offscreen = function(el) {
return (
(el.offsetLeft + el.offsetWidth) < 0
|| (el.offsetTop + el.offsetHeight) < 0
|| (el.offsetLeft > window.innerWidth || el.offsetTop > window.innerHeight)
);
};
Also use that in several ways:
// returns all elements that are offscreen
$(':offscreen');
// boolean returned if element is offscreen
$('div').is(':offscreen');
Asked: 2013-11-05 12:50:45 +0800
Seen: 18 times
Last updated: Jan 19 '14
ZK studio and eclipse outline problem
ZK Package configuration problem
Eclipse Autocomplete not working in ZUL files...
Syntax Error mark ... help me!
Manual Installation of ZK Studio
Can't see button text whilst running simple demo
Adding Vbox to Center layout in Java