Pan-zoom for react-native-svg via 'Google Maps'-style pinch and drag gestures
npm install react-native-svg-pan-zoom```
npm install --save react-native-svg-pan-zoom
js
import React, { Component } from 'react';
import { Circle } from 'react-native-svg';
import SvgPanZoom, { SvgPanZoomElement } from 'react-native-svg-pan-zoom';class Example extends Component {
render() {
return (
canvasHeight = {500}
canvasWidth = {500}
minScale = {0.5}
initialZoom = {0.7}
onZoom = {(zoom) => { console.log('onZoom:' + zoom) }}
canvasStyle = {{ backgroundColor: 'yellow' }}
viewStyle = {{ backgroundColor: 'green' }}
>
{/ Doesn't consume or respond to clicks /}
cx = {100}
cy = {100}
r = {42}
stroke = "red"
strokeWidth = "2.5"
fill = "blue"
/>
{/ Responds to clicks /}
x ={50}
y ={50}
onClick = {()=>{ console.log('onClick!') }}
onClickCanceled = {()=>{ console.log('onClickCanceled!') }}
onClickRelease = {()=>{ console.log('onClickRelease!') }}
onDrag = {()=>{ console.log('onDrag!') }}
>
cx = {42}
cy = {42}
r = {42}
stroke = "blue"
strokeWidth = "2.5"
fill = "red"
/>
);
}
}
``It is recommended not to set maxScale above 1 as this results in blurred react-native-svg elements. Instead, increase your SVG element dimensions and set minScale lower.
This project is licensed under the MIT License - see the LICENSE.md file for details