1.0.3 • Published 3 years ago

react-dragscroll-ts v1.0.3

Weekly downloads
13
License
MIT
Repository
github
Last release
3 years ago

🎉 React DragScroll library

React Drag Scroll library - smooth content scroll via mouse/touch dragging.

Alt text

Usage

import DragScroll from 'react-dragscroll-ts'

interface IDragScrollOptions {
    axis?: string
    allowInputFocus?: boolean
    allowSelectText?: boolean
    scrollTo?: TCoordinate | null
}

const options: IDragScrollOptions = {}
<DragScroll options={options}>
</DragScroll>

Config options prop

OptionTypeDescription
axisstringDefault is 'x'. There are 3 values: 'x', 'y','xy'
'x' is horizontal direction
'y' is vertical direction
'xy' is both direction
allowInputFocusbooleanAllow input fields can be focused
allowSelectTextbooleanAllow text content can be selected
scrollToTCoordinateScroll to specifed position

Examples API

// scroll to specifed position: only update options
const [options, setOptions] = React.useState(defaultOptions)
function scrollTo(): void {
    setOptions({
        ...options,
        scrollTo: {
            x: -300,
            y: 0,
        },
    })
}

License

MIT License (c) 2020 XuanVinh