You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-scroll-to-bottom

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll-to-bottom

React container that will auto scroll to bottom

1.1.0
Source
npmnpm
Version published
Weekly downloads
65K
8.36%
Maintainers
1
Weekly downloads
 
Created
Source

react-scroll-to-bottom

npm version Build Status

React container that will auto scroll to bottom or top if new content is added and viewport is at the bottom, similar to tail -f. Otherwise, a "jump to bottom" button will be shown to allow user to quickly jump to bottom.

This project scaffolding is from react-component-template.

Demo

Try out the demo at https://compulim.github.io/react-scroll-to-bottom/.

Sample code

import { css } from 'glamor';
import ScrollToBottom from 'react-scroll-to-bottom';

const ROOT_CSS = css({
  height: 600,
  width: 400
});

export default props =>
  <ScrollToBottom className={ ROOT_CSS }>
    <p>Nostrud nisi duis veniam ex esse laboris consectetur officia et. Velit cillum est veniam culpa magna sit exercitation excepteur consectetur ea proident. Minim pariatur nisi dolore Lorem ipsum adipisicing do. Ea cupidatat Lorem sunt fugiat. Irure est sunt nostrud commodo sint.</p>
    <p>Duis consectetur ad in fugiat et aliquip esse adipisicing occaecat et sunt ea occaecat ad. Tempor anim consequat commodo veniam nostrud sunt deserunt adipisicing Lorem Lorem magna irure. Eu ut ipsum magna nulla sunt duis Lorem officia pariatur. Nostrud nisi anim nostrud ea est do nostrud cupidatat occaecat dolor labore do anim. Laborum quis veniam ipsum ullamco voluptate sit ea qui adipisicing aliqua sunt dolor nulla. Nulla consequat sunt qui amet. Pariatur esse pariatur veniam non fugiat laboris eu nulla incididunt.</p>
    <p>Laboris duis do consectetur aliquip non aliquip ad ad quis minim. Aute magna tempor occaecat magna fugiat culpa. Commodo id eiusmod ea pariatur consequat fugiat minim est anim. Ipsum amet ipsum eu nisi. Exercitation minim amet incididunt tempor do ut id in officia eu sit est. Dolor qui laboris laboris tempor sunt velit eiusmod non ipsum exercitation ut sint ipsum officia.</p>
  </ScrollToBottom>

We use glamor for component styles. It is not required, but we don't support style props for performance reason.

Props

NameDefaultDescription
classNameSet the class name for the root element
followButtonClassNameSet the class name for the follow button
mode"bottom"Set it to "bottom" for scroll-to-bottom, "top" for scroll-to-top
scrollViewClassNameSet the class name for the container element that house all props.children

Context

NameTypeDescription
atBottombooleantrue if the panel is currently near bottom (see threshold)
atEndbooleantrue if the panel is currently near the end (see mode and threshold
atTopbooleantrue if the panel is currently near top (see threshold)
modestring"bottom" for scroll-to-bottom, "top" for scroll-to-top
scrollTo(scrollTop: number) => voidScroll panel to specified position
scrollToBottom() => voidScroll panel to bottom
scrollToEnd() => voidScroll panel to end
scrollToTop() => voidScroll panel to top
thresholdnumberThreshold in pixels to consider the panel is near top/bottom, read-only and only set thru props

Road map

  • Easier customization for "scroll to bottom" button

Contributions

Like us? Star us.

Want to make it better? File us an issue.

Don't like something you see? Submit a pull request.

Keywords

react

FAQs

Package last updated on 22 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts