hi guys i m working on a sticky subscribe box like below site
i used following js
$.fn.is_on_screen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
bounds.right = bounds.left + this.outerWidth();
bounds.bottom = bounds.top + this.outerHeight();
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
};
$(window).scroll(function(){ // bind window scroll event
if( $('#foot').length > 0 ) { // if target element exists in DOM
if( $('#foot').is_on_screen() ) { // if target element is visible on screen after DOM loaded
$('.subscribeBox').fadeOut(1000);
} else {
$('.subscribeBox').fadeIn(1000);
}
}
});
but the problem is i have to add one more functionality that when scroll amount is >200 the subscribe box is get visible other vise hidden plz make me some suggestion how to do it.
After lots of try i find its solution... from just a silly mistake...
HTML is
here is pure js code..