Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
react-prismazoom
Advanced tools
A pan and zoom component for React, using CSS transformations.
Depends only upon prop-types, react and react-dom modules.
Works on both desktop and mobile.
Online demo here!
If you want to contribute, feel free to send a merge request or open a discussion. Currently, I just have time to maintain the package, but not enough to make big changes or add important features.
All contributions would be quite appreciated! 😉
Among changes I would like to apply:
- Migrate to TypeScript
- Transform to a functional component (that could help split the code)
locked
prop has been replaced by allowZoom
and allowPan
to handle zooming and panning events separatelyscrollVelocity
property passed to the component to keep the same effect.$ npm i -D react-prismazoom
This project includes a full-featured application demo.
First clone the project.
Go to the subfolder:
$ cd demo
Then, install it:
$ npm ci
Run the Webpack Dev Server:
$ npm start
⚠️ There are no unit tests anymore since the previously used library is deprecated and doesn't support React 18. The current test suite needs to be adapted using a different library.
import PrismaZoom from 'react-prismazoom'
<PrismaZoom>
<img src="my-image.png" />
<p>A text that can be zoomed and dragged</p>
</PrismaZoom>
Name | Type | Default | Description |
---|---|---|---|
className | string | None | Class name to apply on the zoom wrapper. |
style | object | None | Style to apply on the zoom wrapper. Note that transform, transition, cursor, touch-action and will-change cannot be overridden. Example: style={{backgroundColor: 'red'}} . |
minZoom | number | 1 | Minimum zoom ratio. |
maxZoom | number | 5 | Maximum zoom ratio. |
scrollVelocity | number | 0.1 | Zoom increment or decrement on each scroll wheel detection. |
onZoomChange | function | null | Function called each time the zoom value changes. |
onPanChange | function | null | Function called each time the posX or posY value changes (aka images was panned). |
animDuration | number | 0.25 | Animation duration (in seconds). |
doubleTouchMaxDelay | number | 300 | Max delay between two taps to consider a double tap (in milliseconds). |
decelerationDuration | number | 750 | Decelerating movement duration after a mouse up or a touch end event (in milliseconds). |
allowZoom | boolean | true | Enable or disable zooming in place. |
allowPan | boolean | true | Enable or disable panning in place. |
allowTouchEvents | boolean | false | Enables touch event propagation. |
allowParentPanning | boolean | false | When enabled, allows the parent element/page to pan with single-finger touch events as long as zoom = 1. |
allowWheel | boolean | true | Enable or disable mouse wheel and touchpad zooming in place |
ignoredMouseButtons | number[] | [] | Optional array of ignored mouse buttons allows to prevent panning for specific mouse buttons. By default all mouse buttons are enabled. MDN |
Note: all props are optional.
These functions can be called from parent components.
zoomIn (value) Increments the zoom with the given value. Param {value: Number} : Zoom value
zoomOut (value) Decrements the zoom with the given value. Param {value: Number} : Zoom value
zoomToZone (relX, relY, relWidth, relHeight) Zoom in on the specified zone with the given relative coordinates and dimensions. Param {relX: Number}: Relative X position of the zone left-top corner in pixels Param {relY: Number}: Relative Y position of the zone left-top corner in pixels Param {relWidth: Number}: Zone width in pixels Param {relHeight: Number}: Zone height in pixels
reset () Resets the component to its initial state.
getZoom () Returns the current zoom value. Return {Number} : Zone value
React PrismaZoom is licensed under the ISC license. See the LICENSE.md file for more details.
[3.3.2] - 2023-03-25
FAQs
A pan and zoom component for React, using CSS transformations.
The npm package react-prismazoom receives a total of 9,729 weekly downloads. As such, react-prismazoom popularity was classified as popular.
We found that react-prismazoom 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.