A jQuery plugin for responsive zoom of images & more!
Documentation will improve over time. Feel free to contribute on Github!
Submit questions or ideas to the issues on GitHub.
Simple example using default options and inner mode.
Using outer mode and a custom zoom level.
Include the CSS and JavaScript from the lib directory in your page. Also include the dependencies (jquery-bridget, jquery-throttle-debounce). Then define some markup as below, and call the jQuery plugin!
<!-- main element & unzoomed content -->
<div data-magnificent="SOME_KEY">
<div class="inner">
<img src="img/rieti-106848-500x334.jpg" />
</div>
</div>
<!-- viewport element & zoomed content -->
<div data-magnificent-viewport="SOME_KEY">
<div class="inner">
<img src="img/rieti-106848.jpg" />
</div>
</div>
There are two components.
Add a data-magnificent attribute your main element, with a unique key as a value. Add a data-magnificent-viewport attribute on your viewport element with a matching value.
Also, to indicate which elements should be considered as the unzoomed and zoomed content, add inner classes to an element inside each of these. (This allows for flexibility in the inner DOM, e.g. wrapping it for different border styles.)
Initialize the plugin, optionally with options (documented below).
Return the Magnificent instance of the first element.
Focus the viewport and lens on the given coordinates.
Pass an object with top and left properties as percentage values from 0 to 1.
Tell the widget(s) to redraw. Used internally on events.
Destroy the widget. Removes event listeners. Best attempt made to restore original state of DOM.
Many of the important options are documented here.
See the source code for all available options.
| Name | type | default | description |
|---|---|---|---|
| mode | string | 'inner' |
The mode to use:
|
| zoomWidth | See viewport.zoomWidth | ||
| viewport.zoomWidth | string | number | function | '3x' | Determines the zoomed width. Height should be proportional. If a number, should be the desired width in pixels. If a string, should be either:
$().width().
|
| viewport.toggle | boolean | true | Whether to toggle visibility of the viewport on interaction, e.g. when the mouse enters and leaves the unzoomed area. |
| smoothMove | boolean | true | Whether to use smooth the motion when focusing. |
MIT License
Copyright © 2013 Anders D. Johnson