Scroll horizontally with the mousewheel!
npm install --save react-scroll-horizontalFeed <HorizontalScroll> one child, or many children.
So long as they have a static width, this component will
take care of the rest. Note: the width of the children must
be greater than the width of the <HorizontalScroll>
npm i react-scroll-horizontal<HorizontalScrollpageLock={bool}reverseScroll={bool}style={object}config={{stiffness: int,damping: int}}className={string}animValues={int}>{children}</HorizontalScroll>Props
pageLock- Adds alock__class to the HTML bodyreverseScroll- Reverses the scroll directionstyle- Pass a style object through to parent divconfig- Passes a spring config object to React MotionclassName- Classnames to pass into the componentanimValues- Emulate scroll by passing a delta value
Gotchas
- Child item(s) must be px/em/vw - no percentages (yet)
- Flexbox weirdness in IE
importReact,{Component}from'react'importHorizontalScrollfrom'react-scroll-horizontal'classScrollingHorizontallyextendsComponent{render(){constchild={width: `30em`,height: `100%`}constparent={width: `60em`,height: `100%`}return(<divstyle={parent}><HorizontalScroll><divstyle={child}/><divstyle={child}/><divstyle={child}/></HorizontalScroll></div>)}}importReact,{Component}from'react'importHorizontalScrollfrom'react-scroll-horizontal'classScrollingHorizontallyextendsComponent{render(){constchild={width: `300em`,height: `100%`}return(<body><HorizontalScroll><divstyle={child}/></HorizontalScroll></body>)}}- Normalize mouse delta values (see: #1)
- Implement tests β¨
- Perf optimizations
- Ability to swap out animation engines (maybe)
Want to help out? Great!
MIT Β© hew