1.0.0 • Published 3 years ago

@shunki-npm/react-indiana-drag-scroll v1.0.0

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

React Indiana Drag Scroll

Implements scroll on drag

Examples / Sandbox

NPM JavaScript Style Guide

Welcome to journey!

npm.io

Try it yourself! Go to demo website.

Install

npm install --save react-indiana-drag-scroll
yarn add react-indiana-drag-scroll

Usage

import React, { Component } from 'react'

import ScrollContainer from 'react-indiana-drag-scroll'

class Example extends Component {
  render () {
    return (
      <ScrollContainer className="scroll-container">
        { ... }
      </ScrollContainer>
    )
  }
}

Component properties

PropTypeDescriptionDefault
verticalBoolAllow vertical drag scrollingtrue
horizontalBoolAllow horizontal drag scrollingtrue
hideScrollbarsBoolHide the scrollbarstrue
activationDistanceNumberThe distance that distinguish click and drag start10
childrenNodeThe content of scrolling container
onScrollFunctionInvoked when user scrolling container
onEndScrollFunctionInvoked when user ends scrolling container
onStartScrollFunctionInvoked when user starts scrolling container
onClickFunctionInvoked when user clicks the scrolling container without dragging
classNameStringThe custom classname for container
styleNumberThe custom styles for container
ignoreElementsStringSelector for elements that should not trigger the scrolling behaviour (for example, ".modal, dialog" or "*[prevent-drag-scroll]")
nativeMobileScrollBoolUse native mobile drag scroll for mobile devicestrue

Static functions

NameReturnsDescription
getElementHTMLElementReturns the HTML element

FAQ

How to set the initial scroll?

To set initial scroll you need get the ref to the main DOM element of the ScrollContainer. It can be implement by using ReactDOM.findDOMNode or by using the static function getElement (this approach is available in the strict mode by the way).

License

The source code is licensed under MIT, all images (except hieroglyphs) are copyrighted to their respective owner © Norserium