Giter Club home page Giter Club logo

back2top's Introduction

BACK2TOP.JS

Back2Top Js is a small library to create a back to top button using Vanilla JavaScript.

HTML

<!-- Place the button on your page -->
<button id="back2top">BACK2TOP</button>

CSS

button#back2top{
    /*Button will appear on bottom-right corner of the page */
    position: fixed;
    right: 2%;
    bottom: 2%;
    opacity: 0;
    visibility: hidden;
    
    /*For better looking button*/
    font-family: sans-serif;
    font-size: 14px;
    color: #fff;
    line-height: 1.3;
    background-color: #123;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 10px 18px;
    margin: 0;
}

JavaScript

//Add BACK2TOP.JS or BACK2TOP.MIN.JS file
//<script src="back2top.js"></script>
<script src="back2top.min.js"></script>
<script>
    const button = document.querySelector("#back2top");

    // Call the BACK2TOP Function
    // BACK2TOP(element, offsetToValue)
    // offsetValue = When the button will appear on the screen
    BACK2TOP(button, 200);
</script>

How To Control Animation

/*
* BACK2TOP(htmlElement, offsetValue, transition-property, transition-duration, transition-timing-function, transition-delay);

* Transition Property will be Visibility, Opacity and Transform

* Default value is set for - 
    transition-property = all,
    transition-duration = 300,
    transition-timing-function = ease,
    transition-delay = 0.

* You can avoid those above parameters if you want.

* Please give a โ˜… if you find this useful.
*/

back2top's People

Contributors

chiranjit2020 avatar amartadey avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.