Download
User Rating: 4.3/5 ( 1 votes)
Magnify JS is a simple, lightweight jQuery plugin that adds a magnifying glass style zoom functionality to images. It is a useful feature to have for product images on ecommerce websites, or if you just want people to be able to zoom into an image without spawning additional overlays or popup windows that may cover your content.
Source: thdoan.github.io
1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" href="css/magnify.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="js/jquery.magnify.js"></script>
2. HTML
The URI to the large image can be placed in the data-magnify-src attribute (as shown below) or passed as the src option when calling the .magnify() function.
<img src="/images/product.jpg" data-magnify-src="/images/product-large.jpg">
If the data-magnify-src attribute or src option is not used, then Magnify JS will try to grab the large image from the parent <a> tag, e.g.:
<a href="/images/product-large.jpg">
<img src="/images/product.jpg">
</a>
3. JAVASCRIPT
$(document).ready(function() {
$('img').magnify();
});
4. OPTIONS
Options can be set using data attributes or passed in an options JavaScript object when calling .magnify(). For data attributes, append the option name to data-magnify- (e.g.,data-magnify-src="...").
Name |
Type |
Default |
Description |
speed |
number |
200 |
The fade-in/out animation speed in ms when the lens moves on/off the image. |
src |
string |
'' |
The URI of the large image that will be shown in the magnifying lens. |