Coder Social home page Coder Social logo

react-scroll-up's Introduction

react-scroll-up

npm version License Dependency Status peerDependency Status Build status Downloads

React component to add custom button (it can be something what you want) for scroll to top of page.

Library uses requestAnimationFrame, if you want better browser compatibility (IE9 and older), you can use something like [https://gist.github.com/paulirish/1579671].

Install

npm install react-scroll-up

How to use it

Live demo

You have to define children element, for example <span>UP</span>

<ScrollToTop showUnder={160}>
  <span>UP</span>
</ScrollToTop>

Parameters

showUnder:number in px (required)

What position (and below) the button will be displayed.

topPosition:number in px (optional)

default: 0

The position to which the scrollbar be moved after clicked.

easing:string (optional)

default: easeOutCubic

Type of scrolling easing. You can specify some of this type of easing: https://github.com/chenglou/tween-functions

In graphical representation: http://sole.github.io/tween.js/examples/03_graphs.html

duration:number in miliseconds (optional)

default: 250

Time to reach the topPosition

onShow:function (optional)

Callback function to be called when the button is being displayed.

onHide:function (optional)

Callback function to be called when the button is being hidden.

style:object (optional)

default:

{
  position: 'fixed',
  bottom: 50,
  right: 30,
  cursor: 'pointer',
  transitionDuration: '0.2s',
  transitionTimingFunction: 'linear',
  transitionDelay: '0s'
}

You can specify you own style and position of the button.

Hide/show button is based on opacity, so this styles opacity and transitionProperty will be all time overwrite.

If you can positioned button to left site, you have to reset css property right: 'auto', and similar.

react-scroll-up's People

Contributors

milosjanda avatar klathmon avatar pavelvanecek avatar satazor avatar eligolding avatar esot3ria avatar nadav42 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.