1.0.0 • Published 5 years ago

@nuagedelait/react-scrollspy v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

react-scrollspy

React scrollspy component

This component is under development

Roadmap :

Export dist

install

npm install @nuagedelait/react-scrollspy --save

use

You should compose the element you want to spy with the ScrollSpy. It renders and Fragment so it will not mess with your dom structure. If you compose several items, the first one will be the reference and will receive classes and data

Roadmap :

add data and classes to all child elements.

import ScrollSpy from '@nuagedelait/react-scrollspy';

const Component = (props) => {

  return(
    <ScrollSpy>

    ... Content to animate

    </scrollspy>

  )
}

result

The component add class inview to his reference if the element top/left corner enter the view.

The reference receive also a progress status from -1 to 1 (right to left or bottom to top) and associated classes :

bottomcentertop
inviewY_b_100, inviewY_b_90, inviewY_b_80,...,inviewY_b_10inviewY_0inviewY_t_10,inviewY_t_20,...,inviewY_t_100
rightcenterleft
inviewX_r_100, inviewY_r_90, inviewX_r_80,...,inviewX_r_10inviewX_0inviewX_l_10,inviewX_l_20,...,inviewX_l_100

Roadmap :

Handle only top/left corner or full object.

<img class="inview inviewY_b_20" delta={deltaX:0,deltaY:0.2}/>

Options

ex : <ScrollSpy offsetX={100} delayIn={200}/>
optiontypeuniteffectdefault
offsetXnumberpxhorizontal offset on trigger in / out (left and right)0
offsetYnumberpxvertical offset on trigger in / out (left and right)100
delayInnumbermsdelay on trigger in view0
delayOutnumbermsdelay on trigger out view0
animateOncebooleantrue/falseonce in is trigger, never trigger in or out anymorefalse
ignoreXbooleantrue/falseignore horizontal scrolltrue
ignoreYbooleantrue/falseignore vertical scrollfalse
targetmixed"parent" or dom elementset another dom lement or the parent of the spy as referencenull (use the first child))
1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago