-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from mnogueron/feature/storybook-demo
Add story for Instagram like pinch to zoom and release
- Loading branch information
Showing
2 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useRef } from 'react' | ||
|
||
import { storiesOf } from '@storybook/react' | ||
import { withKnobs } from '@storybook/addon-knobs'; | ||
import PanZoom from '../src/PanZoom' | ||
import Picture from './john-westrock-638048-unsplash.jpg' | ||
|
||
const InstagramDemo = () => { | ||
const ref = useRef(null) | ||
|
||
function onPanEnd() { | ||
ref.current.reset() | ||
} | ||
|
||
return ( | ||
<PanZoom | ||
ref={ref} | ||
style={{ border: 'solid 1px green', height: 300, width: 300 }} | ||
minZoom={1} | ||
maxZoom={2} | ||
autoCenterZoomLevel={1} | ||
realPinch | ||
onPanEnd={onPanEnd} | ||
> | ||
<div | ||
style={{ | ||
width: 300, | ||
height: 300, | ||
backgroundImage: `url('${Picture}')`, | ||
backgroundPosition: 'center', | ||
backgroundSize: 'cover', | ||
}} | ||
/> | ||
</PanZoom> | ||
) | ||
} | ||
|
||
storiesOf('Demo', module) | ||
.addDecorator(withKnobs) | ||
.add('Instagram pinch to zoom', () => <InstagramDemo />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters