Show / hide scrolling div

I have a div, which is located at the bottom of the slide show, which I want to disappear when the user scrolls or uses the down arrow, and then appears when scrolling up. I assume this includes jquery scroll functions?

+8
source share
6 answers
<div> <div class="a"> A </div> </div>​ $(window).scroll(function() { if ($(this).scrollTop() > 0) { $('.a').fadeOut(); } else { $('.a').fadeIn(); } }); 

Sample

+53
source
 $(window).scroll(function () { var Bottom = $(window).height() + $(window).scrollTop() >= $(document).height(); if(Bottom ) { $('#div').hide(); } }); 
+2
source

Try this code

 $('window').scrollDown(function(){$(#div).hide()}); $('window').scrollUp(function(){ $(#div).show() }); 
+1
source

Here is my answer when you want to revive it and start to fade in a couple of seconds. I used opacity because in the first place I did not want to completely disappear, and secondly, it does not return and does not amplify after many scrolls.

 $(window).scroll(function () { var elem = $('div'); setTimeout(function() { elem.css({"opacity":"0.2","transition":"2s"}); },4000); elem.css({"opacity":"1","transition":"1s"}); }); 
+1
source

I have a good answer, try this code;)

 <div id="DivID"> </div> $("#DivID").scrollview({ direction: 'y' }); $("#DivID > .ui-scrollbar").addClass("ui-scrollbar-visible"); 
0
source
 $.fn.scrollEnd = function(callback, timeout) { $(this).scroll(function(){ var $this = $(this); if ($this.data('scrollTimeout')) { clearTimeout($this.data('scrollTimeout')); } $this.data('scrollTimeout', setTimeout(callback,timeout)); }); }; $(window).scroll(function(){ $('.main').fadeOut(); }); $(window).scrollEnd(function(){ $('.main').fadeIn(); }, 700); 

That should do the trick!

0
source

Source: https://habr.com/ru/post/1444334/


All Articles