mirror of
https://github.com/streamich/react-use.git
synced 2026-02-01 14:37:31 +00:00
chore: clean tsconfig.json; feat: updated webpack config to export a function to achieve full-control mode, instead of deprecated Extend Mode;
32 lines
808 B
TypeScript
32 lines
808 B
TypeScript
import { storiesOf } from '@storybook/react';
|
|
import * as React from 'react';
|
|
import { useScrolling } from '../src';
|
|
import ShowDocs from './util/ShowDocs';
|
|
|
|
const Demo = () => {
|
|
const scrollRef = React.useRef(null);
|
|
const scrolling = useScrolling(scrollRef);
|
|
|
|
return (
|
|
<>
|
|
{<div>{scrolling ? 'Scrolling' : 'Not scrolling'}</div>}
|
|
<br />
|
|
<div
|
|
ref={scrollRef}
|
|
style={{
|
|
width: '400px',
|
|
height: '400px',
|
|
backgroundColor: 'whitesmoke',
|
|
overflow: 'scroll',
|
|
}}
|
|
>
|
|
<div style={{ width: '2000px', height: '2000px' }}>Scroll me</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
storiesOf('Sensors/useScrolling', module)
|
|
.add('Docs', () => <ShowDocs md={require('../docs/useScrolling.md')} />)
|
|
.add('Demo', () => <Demo />);
|