jquery scroll event - to record their common

1, h5 slide to end the page top button only appeared on screen and after 3

 $(document).scroll(function() {
            var scroH = $ (document) .scrollTop (); // Roll Height
            var viewH = $ (window) .height (); // visible height
            if(scroH > 3*viewH){
                _appCache.$goToTop.show();
            }else{
                _appCache.$goToTop.hide();
            }
        })

2, when scrolling, top button is hidden, stop the scrolling 3s, scroll buttons appear

$(document).scroll(function() {
            _appCache.$goToTop.addClass('hide');
            clearTimeout($.data(this, 'scrollTimer'));
            $.data(this, 'scrollTimer', setTimeout(function() {
                _appCache.$goToTop.removeClass('hide');
            }, 3000));
        })

3, slide to the top

 _appCache.$goToTop.click(function(){
            $('html,body').animate({
                scrollTop: 0
            }, 1000);
        });

  

Guess you like

Origin www.cnblogs.com/ilovexiaoming/p/11694953.html