2.0.0 • Published 6 years ago

react-sb3 v2.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

React SB3

Usage:

Install Using:

// With NPM
npm add react-sb3

// With Yarn
yarn add react-sb3

Component PropTypes

Styling Properties

PropertyDescriptionKindDefault
autoHideEnables the autoHiding function for the scrollbarsboolFalse
showXEnables the Horizontal scrollbarbooltrue
showYEnables the Vertical scrollbarbooltrue
flashTimeIndicates the time ( in microseconds ) the scrollbars will be visible after a scroll movement, before auto hiding. Needs autohide enablednumber500
InitialFlashTimeThe time ( in microseconds ) the scrollbars will be visible after mount, to indicate the existence of scrollbarsnumber0
initialFlashDelayIndicates the time ( in microseconds ) before the autoFlash startsnumber0
thumbMinSizeThe minimum size ( in pixels ) of both thumbsnumber30
elementClassesThe css classes to be passed to internal elements See element Classes for detailsobject{}

Events

EventNameDescription
onScrollStartWhen scrolling process starts
onScrollEndWhen scrolling process ends
onScrollWhen scrolling
onScrollFrameWhen scrolling inside animation frame process
onTopReachedWhen top position is reached, won't trigger initially
onLeftReachedWhen left position is reached, won't trigger initially
onBottomReachedWhen bottom position is reached
onRightReachedWhen right position is reached

References

PropNameElement
refRootReturns the root element
refViewReturns the root element
refXBarReturns the horizontal bar element
refYBarReturns the vertical bar element
refXThumbReturns the horizontal thumb element
refYThumbReturns the vertical thumb element
refAllReturns an object with all the elements;

Using the references:

    
    import React from 'react';
    import Scrollbars3 from 'react-sb3';
    
    class component extends React.Component
        
        constructor(props){
            super(props);
            this.scrollbarRoot = null;
        }
        
        render(){
            return (
                <Scrollbars3 refRoot={ el => { this.scrollbarRoot = el }}>
                    {/* All content here */}
                </Scrollbars3>
            );
        }
        
    };
    
    export default component;
    

Internal Elements of the Component

Root

Its the component wrapper.

View

Its the scrolling view

xBar

Its the horizontal scrollbar

yBar

Its the vertical scrollbar

xThumb

Its the horizontal thumb

yThumb

Its the vertical thumb

Styling Internal Elements

Example: 2 Files, 1 Component, 1 Less Style Sheet

componentFile.jsx

    import React from 'react';
    import Scrollbars3 from 'react-sb3';
    import './someFile.less';
    
    const component = ( ) => {
        
        const elementClasses = {
            root  : "myRootClass",
            view  : "myViewClass",
            xBar  : "myXBarClass",
            yBar  : "myYBarClass",
            xThumb: "myXThumbClass",
            xThumb: "myYThumbClass",
        }
        
        return (
            <Scrollbars3 elementClasses={elementClasses}>
                {/* All content here */}
            </Scrollbars3>
        );
        
    };
    
    export default component;
    

someFile.less

    
    .myRootClass{
        border: 1px solid red;
    }
    
    .myViewClass{
        border: 1px solid red;
    }
    
    .myXBarClass{
        //red horizontal bar
        backgroundColor: red;
        
        &.autoShowing:{
            opacity: 1
        },
        &.autoHiding:{
            opacity:0
        }
    }
    
    .myYBarClass{
        //blue horizontal bar
        backgroundColor: blue;
        
        &.autoShowing:{
            opacity: 1
        },
        &.autoHiding:{
            opacity:0
        }
    }
    
    .myXThumbClass{
        //green x thumb
        backgroundColor: green;
    }
    
    .myYThumbClass{
        //purple x thumb
        backgroundColor: purple;
    }
2.0.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago