1.2.1 • Published 6 years ago

react-simple-scroll-container v1.2.1

Weekly downloads
4
License
ISC
Repository
github
Last release
6 years ago

react-simple-scroll-container

A simple scrolling container for react.

npm package v David Dependancy Status npm package dm

Table of Contents

  • API
    • ScrollSection
    • ScrollTo
    • ScrollContainer
  • Examples

Api

ScrollContainer

PropTypeWhat does it do
ContainerIdStringThe id of the container to use for navigation.
ExtraStyleObjectInline css object to be added to the container div.
ExtraClassStringExtra classname(s) to be added to the container div.
TopScrollBoolShould container detect the currently active top element.
TopScrollCallbackFuncCallback which provides the new active element.
TopScrollOffsetNumberThis is a small offset for the active scrolling detection, default is 10 pixels.

ScrollTo

PropTypeWhat does it do
SectionIdStringThe id of the section to navigate to.
ContainerIdStringThe id of the container the element is in.
DurationIntegerThe time it will take the scroll to complete the distance in ms.
OffsetIntegerThe amount to offset the scrolling to ( 10 means it will scroll 10 pixels higher.)

ScrollSection

PropTypeWhat does it do
ChildrenReact component(s)The children you want to be scrollable.
SectionIdStringThe section id you will use to scroll to.

Examples

Basic usage of the container and sections

Using the containerId ensures you call a unique element in that specific container.

<ScrollContainer id="newContainer">
     <ScrollSection id="section1">
        <somecomponent />
     </ScrollSection>
     ....
</ScrollContainer>

Scroll to a section

<div onClick={() => ScrollTo('targetId','newContainer', 10, 500)}>
	Click me to navigate to section #1
</div>
1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago