项目作者: makotot

项目描述 :
:six_pointed_star: react scrollspy component
高级语言: JavaScript
项目地址: git://github.com/makotot/react-scrollspy.git
创建时间: 2015-07-27T14:39:20Z
项目社区:https://github.com/makotot/react-scrollspy

开源协议:MIT License

下载


DEPRECATED - no longer actively maintained.

Please use GhostUI instead.

react-scrollspy

npm version
travis
dependencies
DevDependencies
License
downloads

Scrollspy component

Demo

Install

  1. $ npm i react-scrollspy

Usage

  1. import Scrollspy from 'react-scrollspy'
  2. ...
  3. <div>
  4. <div>
  5. <section id="section-1">section 1</section>
  6. <section id="section-2">section 2</section>
  7. <section id="section-3">section 3</section>
  8. </div>
  9. <Scrollspy items={ ['section-1', 'section-2', 'section-3'] } currentClassName="is-current">
  10. <li><a href="#section-1">section 1</a></li>
  11. <li><a href="#section-2">section 2</a></li>
  12. <li><a href="#section-3">section 3</a></li>
  13. </Scrollspy>
  14. </div>

Props

items={ Array }

Id list of target contents.

currentClassName={ String }

Class name that apply to the navigation element paired with the content element in viewport.

scrolledPastClassName={ String }

Class name that apply to the navigation elements that have been scrolled past [optional].

componentTag={ String | React element type }

HTML tag or React Component type for Scrollspy component if you want to use something other than ul [optional].

style={ Object }

Style attribute to be passed to the generated

    element [optional].

    offset={ Number }

    Offset value that adjusts to determine the elements are in the viewport [optional].

    rootEl={ String }

    Name of the element of scrollable container that can be used with querySelector [optional].

    onUpdate={ Function }

    Function to be executed when the active item has been updated [optional].

    Methods

    offEvent

    Remove event listener of scrollspy.

    onEvent

    Add event listener of scrollspy.

    Development

    1. $ git clone https://github.com/makotot/react-scrollspy.git
    2. $ cd react-scrollspy
    3. $ npm i
    4. $ npm run start

    Contributing

    Pull requests and reporting an issue are always welcome :)

    License

    MIT