back-top
Simple disappearing back-to-top button.
No external dependencies, optional ES2015 module support, no CSS imports needed.
Comes with almost no styling, allowing you to style it yourself.
Note: This library does not include smooth scrolling.
You can use scroll-behavior
, but this does not yet have wide browser support. http://caniuse.com/#feat=css-scroll-behavior
Alternately, you can use something like https://github.com/tsuyoshiwada/sweet-scroll.
Installation
npm install back-top
ES2015:
;
CommonJS:
var backTop = ;
Browser Globals:
Usage
backTop
must be manually initialized.
// Basic Usage:; // Can pass options:;
Options
innerHTML
(String) Set theinnerHTML
of the button. Default isBack to Top
.id
(String) Set the id of the button. By default, noid
is set.className
(String) Set the class name (or space-separated list of class names) to apply to the button. By default, none are set.offset
(String) Distance from bottom-right to absolutely position the button. Default is1rem
.transition
(Object) Settings related to the CSS transition of moving the button on and off the screen.duration
(Number) Time, in milliseconds, that the transition should take. Default is800
.timingFunction
(String) A valid CSS<single-transition-timing-function>
string. Default islinear
.
Browser Support
Should support IE10+ and all modern browsers.