This time I will share jQuery Plugin and tutorial about Simple jQuery Image Zoom With Mouse Wheel or Touch Scroll, hope it will help you in programming stack.
Ap Image Zoom is a jQuery plugin which allows you to zoom in/out an image with mouse wheel or touch scroll. Also provides a simple image pan functionality which which allows to move an image via mouse drag or touch swipe.
How to use it:
1. Include jQuery library together with jQuery ap image zoom plugin’s JS and CSS files in the document.
1 |
< link rel = "stylesheet" href = "css/ap-image-fullscreen.css" > |
3 |
< script src = "ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" ></ script > |
4 |
< script src = "js/ap-image-zoom.js" ></ script > |
2. Include the latest hammer.js JS library to add touch gestures support to the plugin.
1 |
< script src = "js/hammer.min.js" ></ script > |
3. Include the jQuery mousewheel plugin in the document.
1 |
< script src = "//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.11/jquery.mousewheel.min.js" ></ script > |
4. Insert a large image into your document.
1 |
< img src = "1.jpg" width = "325" height = "425" alt = "dirndl" id = "image" style = "display: none" > |
5. Call the plugin on the image and set the custom wrapper class option.
01 |
function initImage() { |
02 |
$( '#image' ).apImageZoom({ |
03 |
cssWrapperClass: 'custom-wrapper-class' , |
6. Style the image wrapper in the CSS.
7. Add the default settings.
04 |
loadingAnimation: undefined, |
05 |
loadingAnimationData: undefined, |
08 |
loadingAnimationFadeOutDuration: 200, |
09 |
cssWrapperClass: undefined, |
26 |
hammerPluginEnabled: true , |
27 |
mouseWheelPluginEnabled: true , |
28 |
hardwareAcceleration: true , |
40 |
doubleClick: 'zoomToggle' |
Change logs:
2016-03-09
2014-12-05
- Added class “apiz-loading” to wrapper while loading image.
2014-12-04
- New options for swipe gestures, click and double click: reset, center
2014-12-04
- Complete rewrite of plugin
2014-11-18
2014-10-01
- Improved throbber CSS animation.
- Improved and fixed trigger method.
2014-09-18
- Improved plugin so it can be called from a container with imageUrl
2014-09-17
- Improved positioning a little bit for better resize experience.
2014-09-16
- Added error handling when loading image fails.
- New Feature: new initialization mechanism for adding a loading
2014-09-13
- Complete rewrite auf plugin with lots of improvements.
This awesome jQuery plugin is developed by armin-pfaeffle. For more Advanced Usages, please check the demo page or visit the official website.