I am currently exploring the most effective method to determine the visibility state of a div container with the CSS property position: absolute
.
On the left side of my viewport, I have a sidebar. By clicking the "sidebar-button," the sidebar smoothly transitions out of view.
Utilizing jQuery:
$('#sideBarButton').click(function(){
sidebar = $("#sideBar").outerWidth();
if(!$("#sideBar").hasClass('outof'))
{
$("#sideBar").animate({left: screenW},100).addClass('outof');
$("#boardContent").animate({width: screenW},200);
$("#sideBarButton").animate({left: "+=" + (sidebar -3)},100);
}
else
{
$("#boardContent").animate({width: bcW}, 50);
setTimeout(function(){
$("#sideBar").animate({left: screenW - sidebar}, 200).removeClass('outof');
$("#sideBarButton").animate({left: "-=" + (sidebar -3)},200);
}, 120);
}
$(this).find('img').toggle();
});
As the sideBar is now completely hidden from view and the left position exceeds the document's width, my query is whether I can determine the visibility state of the sideBar like this:
if($("#sideBar").is(":visible"))...
Alternatively, is there a more efficient approach? How exactly does jQuery ascertain whether an element is visible or not?