Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
react-magnifier
Advanced tools
React image zoom component
→ Demo
Install the package using NPM:
npm install react-magnifier
Add the component to your React application:
import Magnifier from "react-magnifier";
import yourImage from "./path/to/image";
export default function ExampleComponent() {
return <Magnifier src={yourImage} width={500} />;
}
Prop | Type | Default | Description |
---|---|---|---|
src (required) | String | – | URL/path of the large image |
height | Number/String | 'auto' | Image height (absolute or relative values possible) |
width | Number/String | '100%' | Image width (absolute or relative values possible) |
className | String | '' | Class which will be applied to the image wrapper |
zoomImgSrc | String | – | URL/path of the image inside the magnifying glass (if not specified, the large image will be used) |
zoomFactor | Number | 1.5 | Factor by which the zoom image will be scaled (based on the size of the large image) |
mgWidth | Number | 150 | Width of the magnifying glass in px |
mgHeight | Number | 150 | Height of the magnifying glass in px |
mgBorderWidth | Number | 2 | Border width of the magnifying glass in px |
mgShape | String | 'circle' | Shape of the magnifying glass (possible values: 'circle' , 'square' ) |
mgShowOverflow | Boolean | true | Set this to false to cut off the magnifying glass at the image borders. When disabling mgShowOverflow , it's recommended that you also set all offsets to 0 |
mgMouseOffsetX | Number | 0 | Horizontal offset of the magnifying glass in px when hovering with a mouse |
mgMouseOffsetY | Number | 0 | Vertical offset of the magnifying glass in px when hovering with a mouse |
mgTouchOffsetX | Number | -50 | Horizontal offset of the magnifying glass in px when dragging on a touch screen |
mgTouchOffsetY | Number | -50 | Vertical offset of the magnifying glass in px when dragging on a touch screen |
Any other props will be passed down to the <img>
element. This way, you can e.g. add an alt
attribute to the image.
.magnifier {
/* Styles for <div> around image and magnifying glass */
}
.magnifier-image {
/* Styles for large image */
}
.magnifying-glass {
/* Styles for magnifying glass */
}
Requirements: Node.js, Yarn
git clone [repo-url]
yarn install
yarn start
to generate the library bundle using Rollup and see the component in action using StorybookSuggestions and contributions are always welcome! Please first discuss changes via issue before submitting a pull request.
FAQs
React image zoom component
The npm package react-magnifier receives a total of 4,823 weekly downloads. As such, react-magnifier popularity was classified as popular.
We found that react-magnifier 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.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.