A useful library to create the Magnifying effect with ease.
<!-- In the HTML -->
<link href="./style.css" rel="stylesheet" />
// In your main javascript file.
import "[path_to_library]/main.js"
<!-- The magnifying container -->
<div class="magnify-box"></div>
<div
class="magnify-box"
data-background="/images/veronica_mars_poster_bw.jpg"
data-foreground="/images/veronica_mars_poster.jpg"
>
</div>
You can choose to change the zoom level of the magnify glass using the data propert data-zoom
to indicate the level of zoom in of the image.
<div
class="magnify-box"
data-zoom="2"
data-background="/images/veronica_mars_poster_bw.jpg"
data-foreground="/images/veronica_mars_poster.jpg"
>
</div>
- The library will try to catch all
.magnify-box
containers. - Then for each
.magnify-box
it will create the necessary dom children to build the magnify glass effect. - The library will attach the events for desktop and mobile in order to drag the magnify box.
Thank you for considering contributing to the project! You can send any bug report or suggestions as an issue of this repository. @dmarte/magnifying-glass