jQuery animate scroll

后端 未结 5 989
名媛妹妹
名媛妹妹 2020-12-02 10:21

I\'m not sure how to call the effect, but can someone point me into a library that would help me do the same effect as this website?

http://www.makr.com

Basi

相关标签:
5条回答
  • 2020-12-02 10:44
    var page_url = windws.location.href;
    var page_id = page_url.substring(page_url.lastIndexOf("#") + 1);
    if (page_id == "") {
        $("html, body").animate({
            scrollTop: $("#scroll-" + page_id).offset().top
        }, 2000)
    } else if (page_id == "") {
        $("html, body").animate({
            scrollTop: $("#scroll-" + page_id).offset().top
        }, 2000)
    }
    

    });

    0 讨论(0)
  • 2020-12-02 10:44

    There is a jquery plugin for this. It scrolls document to a specific element, so that it would be perfectly in the middle of viewport. It also supports animation easings so that the scroll effect would look super smooth. Check out AnimatedScroll.js.

    0 讨论(0)
  • 2020-12-02 10:50

    You can give this simple jQuery plugin (AnimateScroll) a whirl. It is quite easy to use.

    1. Scroll to the top of the page:

    $('body').animatescroll();
    

    2. Scroll to an element with ID section-1:

    $('#section-1').animatescroll({easing:'easeInOutBack'});
    

    Disclaimer: I am the author of this plugin.

    0 讨论(0)
  • 2020-12-02 10:57

    You can animate the scrolltop of the page with jQuery.

    $('html, body').animate({
        scrollTop: $(".middle").offset().top
     }, 2000);
    

    See this site: http://papermashup.com/jquery-page-scrolling/

    0 讨论(0)
  • 2020-12-02 11:00

    I just use:

    $('body').animate({ 'scrollTop': '-=-'+<yourValueScroll>+'px' }, 2000);

    0 讨论(0)
提交回复
热议问题