react-use/stories/useScroll.story.tsx
xobotyi b6993a6f95
feat(prettier): make prettier a part of eslint.
Also reduce max line width to 100. And remove `lint:types` step for
commit sequence, it bothers when committing incomplete (wip) changes.
2021-02-01 18:58:55 +03:00

31 lines
760 B
TypeScript

import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { useScroll } from '../src';
import ShowDocs from './util/ShowDocs';
const Demo = () => {
const scrollRef = React.useRef(null);
const { x, y } = useScroll(scrollRef);
return (
<>
<div>x: {x}</div>
<div>y: {y}</div>
<div
ref={scrollRef}
style={{
width: '400px',
height: '400px',
backgroundColor: 'whitesmoke',
overflow: 'scroll',
}}>
<div style={{ width: '2000px', height: '2000px' }}>Scroll me</div>
</div>
</>
);
};
storiesOf('Sensors/useScroll', module)
.add('Docs', () => <ShowDocs md={require('../docs/useScroll.md')} />)
.add('Demo', () => <Demo />);