0.0.2 • Published 3 years ago

react-overflowed v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Lil' Component that acts as a draggable container while filtering tap (click/touch) so that user can interact with 'children' elements. It's build upon the shoulder of giants with react-use-gesture and react-spring. Typescript, Rollup.

Codesandbox example

Use it

const overflowAt = 600;
// ...
return (
    <Overflowed overflowedWidth={overflowAt}>
        <h1>HELLO DARKNESS MY OLD FRIEND </h1>
    </Overflowed>
);

Tips:

If children are/contain interactive elements (button, link...) you may want to add some extra padding at the bottom of the component with className so that user can drag easier without maybe triggering unwanted interactions.

Props

Prop nameAcceptsDefault
childrenanyundefined
classNamestringundefined
maskClassNamestringundefined
progressBarbooleanfalse
overflowedWidthnumberundefined
controls* see* below

overflowedWidth is the only prop required (along children ofc), you must specify an estimation of the width of the 'overflowed container'. If in doubt, add some more px to the initial width you had in mind.

controls prop is a Render Prop that gives you access to a couple of methdos (getProgress, setProgress) so that you can manipulate overflowed from the 'outside'.

className adds it to the 'overflowed' container, the immediate parent of children. MaskClassName props adds it to the outer wrapper, a 'div' with 'overflow-x:hidden'.

progressBar is experimental, it shows 'overflowed' current position.

Install

npm i react-overflowed