-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upgrades to storybook v6 and react v17 (#187)
* upgrades to storybook v6 and react v17 * fixes build script * code clean * upgrade storybook and react * adds StandardViewer story * removes deprecated knobs * refactors examples to stateless functions, leveraging on hooks * updates docs * fixes constant import * upgrades transformation-matrix
- Loading branch information
Showing
44 changed files
with
8,746 additions
and
9,973 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 |
---|---|---|
|
@@ -11,3 +11,4 @@ examples/*/yarn.lock | |
build-* | ||
.cache | ||
coverage | ||
.eslintcache |
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 |
---|---|---|
@@ -1,27 +1,41 @@ | ||
# React SVG Pan Zoom - Autosizer viewer | ||
|
||
**React SVG Pan Zoom** requires the properties `width` and `height` to be set in order to work properly. | ||
If you need to automatically adapt the viewer size on the parent size you can use the component [AutoSizer](https://github.com/bvaughn/react-virtualized/blob/master/docs/AutoSizer.md). | ||
This component is able to extract `width` and `height` from the parent box and pass them to a children component. | ||
**React SVG Pan Zoom** requires the properties `width` and `height` to be set in order to work properly. | ||
If you need to automatically adapt the viewer size on the parent size you can use the hook [useWindowSize](https://www.npmjs.com/package/@react-hook/window-size). | ||
This component is able to extract `width` and `height` from the parent box and pass them to a children component. | ||
|
||
## Example | ||
```jsx harmony | ||
import {AutoSizer} from 'react-virtualized'; | ||
import {useWindowSize} from '@react-hook/window-size' | ||
|
||
<div style={{width: "100%", height: "100%"}}> | ||
<AutoSizer> | ||
{(({width, height}) => width === 0 || height === 0 ? null : ( | ||
<ReactSVGPanZoom width={width} height={height}> | ||
<svg width={1440} height={1440}> | ||
<g> | ||
<rect x="400" y="40" width="100" height="200" fill="#4286f4" stroke="#f4f142"/> | ||
<circle cx="108" cy="108.5" r="100" fill="#0ff" stroke="#0ff"/> | ||
<circle cx="180" cy="209.5" r="100" fill="#ff0" stroke="#ff0"/> | ||
<circle cx="220" cy="109.5" r="100" fill="#f0f" stroke="#f0f"/> | ||
</g> | ||
</svg> | ||
</ReactSVGPanZoom> | ||
))} | ||
</AutoSizer> | ||
</div> | ||
export const Resizable = (args) => { | ||
const Viewer = useRef(null); | ||
const [tool, onChangeTool] = useState(TOOL_NONE) | ||
const [value, onChangeValue] = useState(INITIAL_VALUE) | ||
const [width, height] = useWindowSize({initialWidth: 400, initialHeight: 400}) | ||
|
||
useLayoutEffect(() => { | ||
Viewer.current.fitToViewer(); | ||
}, []); | ||
|
||
return ( | ||
<div style={{width: "100%", height: "100%"}}> | ||
<ReactSVGPanZoom | ||
width={width} height={height} | ||
ref={Viewer} | ||
value={value} onChangeValue={onChangeValue} | ||
tool={tool} onChangeTool={onChangeTool} | ||
> | ||
<svg width={500} height={500}> | ||
<g> | ||
<rect x="400" y="40" width="100" height="200" fill="#4286f4" stroke="#f4f142"/> | ||
<circle cx="108" cy="108.5" r="100" fill="#0ff" stroke="#0ff"/> | ||
<circle cx="180" cy="209.5" r="100" fill="#ff0" stroke="#ff0"/> | ||
<circle cx="220" cy="109.5" r="100" fill="#f0f" stroke="#f0f"/> | ||
</g> | ||
</svg> | ||
</ReactSVGPanZoom> | ||
</div> | ||
) | ||
} | ||
``` |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
examples/controlled-component-advanced-usage/public/index.html
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.