react-use/stories/useScrolling.story.tsx
Anton Zinovyev 2832b7a37e
chore: move all stories from src directory. (#715)
chore: clean tsconfig.json;

feat: updated webpack config to export a function to achieve full-control mode, instead of deprecated Extend Mode;
2019-12-09 23:36:40 +03:00

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 />);