Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-native-simple-svg-pan-zoom
Advanced tools
Readme
This repo is used by react-native-simple-maps - an svg map component for React Native.
Pan-zoom for react-native-svg via "Google Maps"-style pinch and drag gestures.
npm install --save react-native-svg-pan-zoom
Simply use SvgPanZoom as a wrapper and begin dropping components. Plain react-native-svg components will not react to clicks per default. To make things clickable, use the react-native PanResponder or wrap them in the included SvgPanZoomElement as shown below
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 (
<View style = {{ width: '100%', height:'100%' }}>
<SvgPanZoom
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 */}
<Circle
cx = {100}
cy = {100}
r = {42}
stroke = "red"
strokeWidth = "2.5"
fill = "blue"
/>
{/* Responds to clicks */}
<SvgPanZoomElement
x ={50}
y ={50}
onClick = {()=>{ console.log('onClick!') }}
onClickCanceled = {()=>{ console.log('onClickCanceled!') }}
onClickRelease = {()=>{ console.log('onClickRelease!') }}
onDrag = {()=>{ console.log('onDrag!') }}
>
<Circle
cx = {42}
cy = {42}
r = {42}
stroke = "blue"
strokeWidth = "2.5"
fill = "red"
/>
</SvgPanZoomElement>
</SvgPanZoom>
</View>
);
}
}
The drag and zoom gestures are constrained to never leave the SvgPanZoom canvas. It's size as well as scaling constraints can be set through props as shown in the above example.
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
FAQs
Pan-zoom for react-native-svg via 'Google Maps'-style pinch and drag gestures
The npm package react-native-simple-svg-pan-zoom receives a total of 165 weekly downloads. As such, react-native-simple-svg-pan-zoom popularity was classified as not popular.
We found that react-native-simple-svg-pan-zoom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.