Socket
Socket
Sign inDemoInstall

reactjs-magnifying-glass

Package Overview
Dependencies
10
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    reactjs-magnifying-glass

React component that zooms into any HTML element.


Version published
Maintainers
1
Install size
4.40 MB
Created

Readme

Source

react-magnifying-glass

React component that zooms into any HTML element.

demo

How it works

MagnifyingGlass component is inserted as a child of the target container that we want to zoom into. html2canvas is used to capture an image of the target container (and its children, except MagnifyingGlass) and reflected on the MagnifyingGlass as background image. Event listener is added to detect any mouse movement within the target container to update the image on the MagnifyingGlass to correspond to its position in the container.

Docs

MagnifyingGlass Props

NameTypeDefaultDescription
zoomnumber2The zoom factor of the magnifying glass.
glassStyleReact.CSSProperties{ border: "1px solid black", borderRadius:"50%", width:"50px", height:"50px", }Custom CSS styling for the magnifying glass.
offsetTopnumber0Number of pixels that the cursor is to the top of the center of the magnifying glass.
offsetLeftnumber0Number of pixels that the cursor is to the left of the center of the magnifying glass.

Limitations

CSS transitions and animations which can cause a change in visual representation of the target container are not supported (yet?). However, simple visual changes can be implemented via React state. Any state change of the target container will cause it rerender which will in turn cause MagnifyingGlass to rerender and update its image of the target container.

Usage

Insert the MagnifyingGlass component into any target container you want to zoom into:

<ParentComponent> {/* your target container */}
    <MagnifyingGlass {/* props here */} />
    <ChildComponent>...</ChildComponent>
    <ChildComponent>...</ChildComponent>
    {/* ...other child components */}
</ParentComponent>

Keywords

FAQs

Last updated on 15 Jan 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc