I have a jQuery script that triggers a click based on scroll position. I want to be able to click this element again if the user returns to the top of the page so the contact form will hide itself. Problem is that it creates a loop.
jQuery(window).scroll(function (event) {
var y = $(this).scrollTop();
if (y > 400) {
$("#contactable-inner").click();
$("#contactable-inner").unbind('click');}
});
You can go here to see what I am working on: http://algk.me
UPDATE:
$(window).scroll(function(){
var y = $("body").scrollTop();
var hidden = $('.hidden');
if (y >= 1000 && (hidden.hasClass('visible'))){
hidden.animate({"left":"-1000px"}, "slow").removeClass('visible');
} else {
hidden.animate({"left":"0px"}, "slow").addClass('visible');
}
});
Any idea how I could get this to work on scroll?