1.0.3 • Published 1 year ago

@nikolajs/react-scroll-slider v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-scroll-slider

A package developed to design web application based on a vertical slider. Where each page / section is a slide. You can check my website for example http://nicolas-saikali.com/

Usage

function App(){
    const ref: Ref<ScrollSlider> = useRef(null)
    const [activeIndex, setActiveIndex] = useState(0)
    const [progress, setProgress] = useState(0)
    
    return (
        <ScrollSlider
            ref={ref}
            withProgress={true}
            onSlideChange={setActiveIndex}
            onProgress={setProgress}
            sensitivity={ScrollSliderSensitivity.HIGH}
            animationOptions={{
                easing: 'linear'
            }}
            slides={[
                {
                    children: <h1> Slide 1 </h1>
                },
                {
                    children: <h1> Slide 2 </h1>
                },
                {
                    children: <h1> Slide 3 </h1>
                },
            ]}
        >
    )
}

Properties

PropertyRequiredTypeDescription
reffalseRef | null | undefined;Ref object to use in the screen
slidestrueArray<{ children: any }>The slides to show
sensitivityfalseScrollSliderSensitivityThe sensitivity of the mouse wheel
progressComponentfalseJSX.ElementCustom progress component
withProgressfalsebooleanDefined whether to show the progress component or not
animationOptionsfalseKeyframeAnimationOptionsCustom animation options
progressStylefalseCSSPropertiesCustom styles of the default progress component
stylefalseCSSPropertiesCustom styles for the slider
preventDefaultOnfalsestring[]List of selectors to lock scrolling on (when mouse pointer is over any of them)
onSlideChangefalse(index:number)=>voidcallback to execute when active slide changes
onProgressfalse(progress: number)=>voidcallback to execute on progress (0~1)

ref

Example

<Button
    onClick={() => ref?.current?.navigateToIndex(1)}
>
//...

sensitivity

Example

<ScrollSlider
    sensitivity={ScrollSliderSensitivity.HIGH}
>
//...

animationOptions

Example

<ScrollSlider
    animationOptions={{
        easing: 'linear'
    }}>
//...