1.2.0 • Published 5 years ago

react-scroll-lock-component v1.2.0

Weekly downloads
9,673
License
MIT
Repository
github
Last release
5 years ago

react-scroll-lock-component

npm version Build Status

A React component wrapper that restricts scrolling capabilities of everything except for its children.

Wheel events, touchmove events, and key press events that affect page location (e.g. directional arrows, pageup/pagedown/spacebar) are all locked.

Demo

Check out the demo here!

Installation

npm install react-scroll-lock-component

or

yarn add react-scroll-lock-component

Usage

import React from 'react';
import ScrollLock from 'react-scroll-lock-component';

export default () => (
    <div>
        <ScrollLock>
            <div> 
                {/*
                    unlike normal scroll functionality, when the user scrolls this
                    div and reaches the beginning or end nothing else on the page will scroll
                */}
            </div>
        </ScrollLock>
        <div>
            {/* scrolling outside of the scroll lock will remain normal */}
        </div>
    </div>
);

optional props

Propdescriptiondefault value
enabledprogramatically enable or disable the scroll locktrue
classNameapply custom styles to the scroll lock component''

Credits

Adapted from this old mixin

License

MIT

1.2.0

5 years ago

1.1.2-test.1

5 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.3

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago