mirror of
https://github.com/streamich/react-use.git
synced 2026-02-01 14:37:31 +00:00
Also reduce max line width to 100. And remove `lint:types` step for commit sequence, it bothers when committing incomplete (wip) changes.
31 lines
760 B
TypeScript
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 />);
|