Animated Scroll to Top Control In Vanilla JS – scroll2Top

Category: Animation , Javascript | October 12, 2014
Author:sunaiwen
Views Total:3,845 views
Official Page:Go to website
Last Update:October 12, 2014
License:MIT

Preview:

Animated Scroll to Top Control In Vanilla JS – scroll2Top

Description:

scroll2Top is a tiny JS library used to scroll the page to a target position with smooth scrolling effects. Perfect for creating a scroll to top button on your website to improve the user experiences.

How to use it:

Include the scroll2top.js script in your document.

<script src="scroll2Top.js"></script>

Create a button to scroll to the top of your web page.

<button class="globalBtn">scroll body</button>

Active the scroll to top button.

var gBtn = document.getElementsByClassName('globalBtn')[0];
    var scroll2Top = scroll2Top;
    gBtn.addEventListener('click', function(){
        scroll2Top(window, 700); // animation speed = 700ms
    });

You Might Be Interested In:


One thought on “Animated Scroll to Top Control In Vanilla JS – scroll2Top

Leave a Reply