-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove React component & refactor main code
- Loading branch information
1 parent
f79a7a1
commit 1ae6173
Showing
10 changed files
with
211 additions
and
385 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 |
---|---|---|
@@ -1,30 +1,50 @@ | ||
# pinch-zoom-pan | ||
|
||
A React component lets you add pinch-zoom and pan sub components. | ||
A simple module that add pinch-zoom and pan to your HTML element. | ||
|
||
## Install | ||
### Using | ||
|
||
```bash | ||
npm i -S pinch-zoom-pan | ||
``` | ||
|
||
## Usage | ||
```html | ||
<div class="root" id="root"> | ||
<div class="point"> | ||
<div class="canvas"> | ||
<!-- your content here --> | ||
</div> | ||
</div> | ||
</div> | ||
``` | ||
|
||
```typescript jsx | ||
import PinchZoomPan from 'pinch-zoom-pan'; | ||
```css | ||
.root { | ||
position: relative; | ||
transform: translateZ(0); | ||
overflow: hidden; | ||
} | ||
|
||
.point { | ||
position: absolute; | ||
width: 0; | ||
height: 0; | ||
transform: translate(0, 0) scale(1); | ||
transform-origin: center; | ||
will-change: transform; | ||
} | ||
|
||
.canvas { | ||
position: absolute; | ||
transform: translate(-50%, -50%); | ||
} | ||
``` | ||
|
||
<PinchZoomPan style={{ width: 300, height: 300 }}> | ||
<img width="600" height="400" /> | ||
</PinchZoomPan> | ||
```javascript | ||
import { create } from 'pinch-zoom-pan'; | ||
create({ element: document.getElementById('root') }); | ||
``` | ||
|
||
### Props | ||
#### Frameworks & libraries | ||
|
||
| name | description | type | default | | ||
|------|-------------|------|---------| | ||
|className? | additional css class | `string` | `''` | | ||
|style? | additional style | `React.CSSProperties` | `{}` | | ||
|min? | minimal zoom | `number` | `0.1` | | ||
|max? | maximal zoom | `number` | `3.5` | | ||
|captureWheel? | capture wheel event, otherwise zoom works with holding `Alt` key | `boolean` | `false` | | ||
|debug? | render debug info | `boolean` | `false` | | ||
* [React example](https://github.com/SanichKotikov/react-family-tree-example/tree/master/src/components/PinchZoomPan) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 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,4 @@ | ||
export const MIN_ZOOM = 0.1; | ||
export const MAX_ZOOM = 3.5; | ||
|
||
export const DEFAULT_STATE = { x: 0, y: 0, z: 1 }; |
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
Oops, something went wrong.