1. Start
  2. Implementation
  3. Customisation
  4. Plugin Methods
  5. Get Zoom Data

Smooth Zoom Pan - jQuery Image Viewer

UPDATE 7.0


This plugin can be used 7 different ways as shown in the "Examples" folder. Each variation has its own style sheet and html elements but uses same Javascript file.

Implementation


The source package includes 7 example variations to match different needs. Choose one of the example that best fits your need and then edit it if deeper custmisation required.
Each example requires slightly different implementation steps:
Example 1 Example 2 Example 3 Example 4 Example 5 Example 6 Example 7

Back to Top
Example 1 - Default version
1. First set ID attribute for the image in your web page. For example:
<img id="yourImageID" src="your_image.jpg" />

2. Inside the head tag of your page, paste the following style:
<style>
	.smooth_zoom_preloader {
		background-image: url(zoom_assets/preloader.gif);
	}	
	.smooth_zoom_icons {
		background-image: url(zoom_assets/icons.png);
	}
</style>

In the above style sheet:

.smooth_zoom_preloader just sets preloader GIF as a background-image of zoom container (the container is a dynamically created div).

.smooth_zoom_icons sets path to the button icon image.


3. Inside the head tag of your page (below the style added in Step 2), paste the following code:
<script src="zoom_assets/jquery-1.11.1.min.js"></script>
<script src="zoom_assets/jquery.smoothZoom.min.js"></script>
<script>
jQuery(function($){
	$('#yourImageID').smoothZoom({
		width: 512,
		height: 384
	});
});
</script>

In the above code,

- 1st line loads jQuery library. You may download the latest version of jQuery file from here and use it in case needed.

- 2nd line loads this Zoom plugin.

- The remaining lines are to implement and configure zoom plugin into your image.

- The line number 5 needs to be updated with image ID name which you already set for img tag.

- Line 6 & 7 are parameters to set Width & Height of the zoom area. Those values can be in number, pixels or percentage. If no width or height properties added, the plugin will try to take the dimension of container element. All the below 3 values are valid:
width: '480'
width: '480px'
width: '100%'

 

4. Next step is configuring the settings as per your need, which is explained in next Chapter. After customisation, upload the folder named zoom_assets along with your file.

 
 
 
 
 
 
 
 
 
 

Back to Top
Example 2

- The Pan buttons removed.
- The image is allowed to drag / pan more than boundary.
- Button Size increased.
- Buttons are aligned to Top Right.
1. First set ID attribute for the image in your web page. For example:
<img id="yourImageID" src="your_image.jpg" />

2. Inside the head tag of your page, paste the following style:
<style>	
	.smooth_zoom_preloader {
		background-image: url(zoom_assets/preloader.gif);
	}	
	.smooth_zoom_icons {
		background-image: url(zoom_assets/icons.png);
	}
</style>

In the above style sheet:

.smooth_zoom_preloader just sets preloader GIF as a background-image of zoom container (the container is a dynamically created div). 

.smooth_zoom_icons sets path to the button icon image.


3. Inside the head tag of your page (below the style added in Step 2), paste the following code:
<script src="zoom_assets/jquery-1.11.1.min.js"></script>
<script src="zoom_assets/jquery.smoothZoom.min.js"></script>
<script>
jQuery(function($){
	$('#yourImageID').smoothZoom({
		width: 512,
		height: 384,
		pan_BUTTONS_SHOW: "NO",
		pan_LIMIT_BOUNDARY: "NO",
		button_SIZE: 24,
		button_ALIGN: "top right",	
		zoom_MAX: 100,
		border_TRANSPARENCY: 20
	});
});
</script>

In the above code,

- 1st line loads jQuery library. You may download the latest version of jQuery file from here and use it in case needed.

- 2nd line loads this Zoom plugin.

- The remaining lines are to implement and configure zoom plugin into your image.

- The line number 5 needs to be updated with image ID name which you already set for img tag.

- Line 6 & 7 are parameters to set Width & Height of the zoom area. Those values can be in number, pixels or percentage. If no width or height properties added, the plugin will try to take the dimension of container element. All the below 3 values are valid:
width: '480'
width: '480px'
width: '100%'

 

4. Next step is configuring the settings as per your need, which is explained in next Chapter. After customisation, upload the folder named zoom_assets along with your file.

 
 
 
 
 
 
 
 
 
 

Back to Top
Example 3

- Button size increased a little bit.
- Buttons aligned to Bottom - Center.
- Auto Hide enabled for Buttons.
1. First set ID attribute for the image in your web page. For example:
<img id="yourImageID" src="your_image.jpg" />

2. Inside the head tag of your page, paste the following style:
<style>	
	.smooth_zoom_preloader {
		background-image: url(zoom_assets/preloader.gif);
	}	
	.smooth_zoom_icons {
		background-image: url(zoom_assets/icons.png);
	}
</style>

In the above style sheet:

.smooth_zoom_preloader just sets preloader GIF as a background-image of zoom container (the container is a dynamically created div). 

.smooth_zoom_icons sets path to the button icon image.


3. Inside the head tag of your page (below the style added in Step 2), paste the following code:
<script src="zoom_assets/jquery-1.11.1.min.js"></script>
<script src="zoom_assets/jquery.smoothZoom.min.js"></script>
<script>
jQuery(function($){
	$('#yourImageID').smoothZoom({
		width: 800,
		height: 600,
		button_SIZE: 22,
		button_ALIGN: "bottom center",
		zoom_OUT_TO_FIT: "NO",
		button_AUTO_HIDE: "YES",
		button_AUTO_HIDE_DELAY: 2
	});
});
</script>

In the above code,

- 1st line loads jQuery library. You may download the latest version of jQuery file from here and use it in case needed.

- 2nd line loads this Zoom plugin.

- The remaining lines are to implement and configure zoom plugin into your image.

- The line number 5 needs to be updated with image ID name which you already set for img tag.

- Line 6 & 7 are parameters to set Width & Height of the zoom area. Those values can be in number, pixels or percentage. If no width or height properties added, the plugin will try to take the dimension of container element. All the below 3 values are valid:
width: '480'
width: '480px'
width: '100%'

 

4. Next step is configuring the settings as per your need, which is explained in next Chapter. After customisation, upload the folder named zoom_assets along with your file.

 
 
 
 
 
 
 
 
 
 

Back to Top
Example 4

- This example included just to demonstrate how to control the zoom navigation from outside the plugin by calling plugin methods.
- Also demonstrates how to retrieve the scale and position values on run-time.
Initiate:
$('#yourImageID').smoothZoom({
	width: 480,
	height: 360,
	zoom_BUTTONS_SHOW: 'NO',
	pan_BUTTONS_SHOW: 'NO',
	pan_LIMIT_BOUNDARY: 'NO'
});



focusTo:
$('#yourImageID').smoothZoom('focusTo',{
	x: 365,
	y: 245,
	zoom: 200,
	speed: 2
});


Important: All the below functions should be called on Mouse Down event. Not on click or mouse up.

Zoom In:
$('#yourImageID').smoothZoom('zoomIn');


Zoom Out:
$('#yourImageID').smoothZoom('zoomOut');


Move Left:
$('#yourImageID').smoothZoom('moveLeft');


Move Right:
$('#yourImageID').smoothZoom('moveRight');


Move Up:
$('#yourImageID').smoothZoom('moveUp');


Move Down:
$('#yourImageID').smoothZoom('moveDown');


Reset:
$('#yourImageID').smoothZoom('Reset'); 

 
 
 
 
 
 
 
 
 
 
 

Back to Top
Example 5

- Location / Landmarks can be added with custom position.
- Landmarks can be showed either always or showed only when enlarged to certain percentage.
- 2 different types of landmark elements can be added:
     LABLE Type: This is a div that can have text, image or any html elements. This will be centered to the specified point.
     MARK Type:
This is a div that can have text and a pin graphic (image) which always aligns its bottom to the specified position.
1. Paste following code in the body of your html.
<div id="zoom_container">
    <img id="yourImageID" src="images/your_image_map.jpg" width="1024px" height="768px" />
    
    <div class="landmarks" data-show-at-zoom="100" data-allow-drag="true">    
           
        <!-- This is a lable-type landmark -->
        <div class="item lable" data-position="780,170" data-bg-color="#000000" data-bg-opacity=".7" data-show-at-zoom="0">    
            <div>                                                
                <strong>Permanent Lable</strong>
            </div>
        </div>
           
        <!-- This is a mark-type landmark -->
        <div class="item mark" data-position="480,465" data-show-at-zoom="0">
            <div>
                <div class="text">
                    <strong>Permanent Mark</strong>
                </div>
                <img src="images/mark.png" width="50px" height="50px" alt="Permanent Mark" />    
            </div>    
        </div>        
               
    </div>
</div>

      It is important to set correct width and height attribute values to the img tag. Otherwise Apple devices (iPad, iPhone and iPod) may not position the landmarks correctly.

In the above code,
      zoom_container - The div having this id is a container that wraps main image as well as landmark elements.
      yourImageID - The image having this id is the main image to be zoomed.
      landmarks - The div having this class is the container of all the landmarks.
      item lable - The divs having these two classes are LABLE - Type landmarks.
      item mark - The divs having these two classes are MARK - Type landmarks.

This example code contains 2 landmarks. So just copying those landmarks and adjusting the data-postion attribute's x,y values will be enough to add more landmarks.

You can also find following attributes for the item lable and item mark divs:
      data-position = "780, 170" - X, Y Position of landmark.
      data-show-at-zoom = "100" - The zoom percentage on which the landmark should show. Set 0 to show always.
      data-bg-color = "#000000" - Background color of lable.
      data-bg-opacity = "0.7" - Transparency of background.

Addition to the individual landmak option, it is possible set 2 global properties for landmarks. The global attributes should be set to the container div of landmarks which has class name landmarks). Those attributes are:
      data-show-at-zoom = "100" - The zoom percentage above which the landmark should show. Set 0 to show always.
      data-allow-drag= "false" - To enable/disable the draggability of landmarks.


2. Inside the head tag of your page, paste the following style:
<style>	
	.smooth_zoom_preloader {
		background-image: url(zoom_assets/preloader.gif);
	}	
	.smooth_zoom_icons {
		background-image: url(zoom_assets/icons.png);
	}
	#zoom_container .landmarks{
		position:absolute;
		z-index:10;	
		top:0px;
		left:0px;
		font-family: Helvetica, Arial, Verdana;
		font-size:12px;
		color: #ffffff;
	}	
	#zoom_container .landmarks .item {
		position:absolute;		
		text-align:center;		
		display: none;	
	}	
	#zoom_container .landmarks .lable div {
		width: 100px;
		padding: 4px;		
	}	
	#zoom_container .landmarks .mark .text{
		background-color:#000000;
		padding:2px 6px;
	}	
</style>

In the above style sheet:

.smooth_zoom_preloader just sets preloader GIF as a background-image of zoom container. 

.smooth_zoom_icons sets path to the button icon image.

#zoom_container . landmarks - This is the class for landmarks container div. Font family, size and color set through this class will serve as global setting for all the landmarks - lables.

#zoom_container . landmarks .item - This is the class applies for all the individual landmarks.

#zoom_container . landmarks .lable div - Set style here for LABLE Type landmarks. (such as adjusting width, height, padding etc)

#zoom_container . landmarks .mark .text - Set style here for MARK Type landmark's text area. (such as adjusting width, height, padding etc)


3. Inside the head tag of your page (below the style added in Step 2), paste the following code:
<script src="zoom_assets/jquery-1.11.1.min.js"></script>
<script src="zoom_assets/jquery.smoothZoom.min.js"></script>
<script>
jQuery(function($){
	$('#yourImageID').smoothZoom({
	    width: 512,
            height: 384,
            pan_BUTTONS_SHOW: "NO",
            pan_LIMIT_BOUNDARY: "NO",
            button_SIZE: 24,
            button_ALIGN: "top right",    
            zoom_MAX: 200,
            border_TRANSPARENCY: 20,
            container: 'zoom_container'
	});
});
</script>

In the above code,

- 1st line loads jQuery library. You may download the latest version of jQuery file from here and use it in case needed.

- 2nd line loads this Zoom plugin.

- The remaining lines are to implement and configure zoom plugin into your image.

- The line number 5 needs to be updated with image ID name which you already set for img tag.

- Line 6 & 7 are parameters to set Width & Height of the zoom area. Those values can be in number, pixels or percentage. If no width or height properties added, the plugin will try to take the dimension of container element. All the below 3 values are valid:
width: '480'
width: '480px'
width: '100%'

- In the propoerty 'container', the id name of the div which wraps main image and landmarks. (which mentioned in the 1st step)

- To know more about other settings proprties, please go through the customisation section.

 

4. Next step is configuring the settings as per your need, which is explained in next Chapter. After customisation, upload the folder named zoom_assets along with your file.
 
 
 
 
 
 
 
 
 
 
 
 

Back to Top
Example 6

- Works as a simple Thumbnail gallery.
- Thumbnail images can be added easily as list item <li>
- Main image url can be added using hyperlinks of thumbnails.
1. Paste following code in the body of your html.
<div id="zoom_container"></div>
<ul class="zoom_thumbnails">
	<li><a href="images/gallery_images/main1.jpg"><img src="images/gallery_images/thumb1.jpg"></a></li>        
	<li><a href="images/gallery_images/main2.jpg"><img src="images/gallery_images/thumb2.jpg"></a></li>        
	<li><a href="images/gallery_images/main3.jpg"><img src="images/gallery_images/thumb3.jpg"></a></li>        
	<li><a href="images/gallery_images/main4.jpg"><img src="images/gallery_images/thumb4.jpg"></a></li>
</ul>

In the above code,
      zoom_container - The div having this id is a container that will wrap dynamically created image and zoom elements.

      zoom_thumbnails - Inside this unordered list, add your thumbnail images as list item.

Inside each list tag, add thumbnails as img tag and add main image urls as link.

If you need to align both the thumbnails and image center to each other, wrap the above code with following div and set your preferred width:
<div style="width: 512px; text-align:center">
</div>


2. Inside the head tag of your page, paste the following style:
<style>    
	.smooth_zoom_preloader {
		background-image: url(zoom_assets/preloader.gif);
	}	
	.smooth_zoom_icons {
		background-image: url(zoom_assets/icons.png);
	}
	#zoom_container {
		overflow: hidden;
	}
	.zoom_thumbnails {
		margin: 0px;
		padding: 0px;
		display: inline-block;
	}
	.zoom_thumbnails li {
		display: inline-block;
	}
	.zoom_thumbnails li img {
		margin: 5px;
		border: 0px;
	}
</style>

In the above style sheet:

.smooth_zoom_preloader just sets preloader GIF as a background-image of zoom container. 

.smooth_zoom_icons sets path to the button icon image.

#zoom_container - This is the id for zoom plugin's container div. 

.zoom_thumbnails - Margin and padding adjusted here to avoid default list padding and margin

.zoom_thumbnails li - To make the list items inline. Otherwise, thumbnails will show vertically.

.zoom_thumbnails li img - Thumbnail image's border and margin set here.


3. Inside the head tag of your page (below the style added in Step 2), paste the following code:
<script src="zoom_assets/jquery-1.11.1.min.js"></script>
<script src="zoom_assets/jquery.smoothZoom.min.js"></script>
<script>
jQuery(function($){
	$('.zoom_thumbnails').find('li a').each(function (){        
		$(this).bind('click', {src: $(this).attr('href')}, function (e){

			//Add your zoom settings here
			$('#zoom_container').smoothZoom('destroy').css('background-image', 'url(zoom_assets/preloader.gif)').smoothZoom({
				width: 512,
				width: 384,
				image_url: e.data.src
			});
			return false;

		});            
	}).eq(0).trigger('click');
});
</script>

In the above code,

- 1st line loads jQuery library. You may download the latest version of jQuery file from here and use it in case needed.

- 2nd line loads this Zoom plugin.

- The remaining lines are to implement and configure zoom plugin with thumbnail gallery.

- If you need to configure plugin with more properties (as listed in customisation section), add the plugin properties above the line "image_url" and seperate the properties with comma.

 

4. Next step is configuring the settings as per your need, which is explained in next Chapter. After customisation, upload the folder named zoom_assets along with your file.
 
 
 
 
 
 
 
 
 
 
 
 

Back to Top
Example 7

- Works as a lightbox gallery using prettyPhoto plugin.
- Thumbnail images can be added easily as list item <li>
- Main image url can be added using hyperlinks of thumbnails.
1. Paste following code in the body of your html.
<ul class="zoom_gallery">
	<li><a href="images/gallery_images/main1.jpg" rel="prettyPhoto[gallery2]" title=""><img src="images/gallery_images/thumb1.jpg" width="100" height="75" alt=""></a></li>        
	<li><a href="images/gallery_images/main2.jpg" rel="prettyPhoto[gallery2]" title=""><img src="images/gallery_images/thumb2.jpg" width="100" height="75" alt=""></a></li>        
	<li><a href="images/gallery_images/main3.jpg" rel="prettyPhoto[gallery2]" title=""><img src="images/gallery_images/thumb3.jpg" width="100" height="75" alt=""></a></li>        
	<li><a href="images/gallery_images/main4.jpg" rel="prettyPhoto[gallery2]" title=""><img src="images/gallery_images/thumb4.jpg" width="100" height="75" alt=""></a></li>
</ul>

In the above code,
      zoom_gallery - The ul having this class is a container that wraps thumbnails.
     
Each list item contains one thumbnail as <img> element.
In the anchor tag <a> the href attribute points the large image which needs to be zoomed.
In the anchor tag <a> the rel attribute value "prettyPhoto[gallery2]" helps to add the list to prettyPhoto plugin.
In the anchor tag <a> the title attributevalue will be displayed as description text below main image.


2. Inside the head tag of your page, paste the following style:
<style>    
	.smooth_zoom_preloader {
		background-image: url(zoom_assets/preloader.gif);
	}	
	.smooth_zoom_icons {
		background-image: url(zoom_assets/icons.png);
	}
	.zoom_gallery {
		margin: 0px;
		padding: 0px;        
	}
	.zoom_gallery li {
		display: inline;
	}
	.zoom_gallery li img {
		margin: 5px;
		border: 1px solid #666666;
	}     
</style>    
<link rel="stylesheet" href="prettyPhoto/css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" />

In the above style sheet:

.smooth_zoom_preloader just sets preloader GIF as a background-image of zoom container (the container is a dynamically created div). 

.smooth_zoom_icons sets path to the button icon image.

.zoom_gallery - Wrapper of thumbnails. Margin and padding adjusted here to avoid default list padding and margin.

.zoom_gallery li - To make the list items inline. Otherwise, thumbnails will show vertically.

.zoom_gallery li img - Thumbnail image's border and margin set here.

The last line is to link the prettyPhoto's style sheet.


3. Inside the head tag of your page (below the style added in Step 2), paste the following code:
<script src="zoom_assets/jquery-1.11.1.min.js"></script>
<script src="zoom_assets/jquery.smoothZoom.min.js"></script>
<script src="prettyPhoto/js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>    
<script>
	jQuery(function($){

       		function setZoom (){
			$('#fullResImage').smoothZoom('destroy').smoothZoom();
		}
       
		function closeZoom (){
			$('#fullResImage').smoothZoom('destroy');        
		}

       		//Set your popup window size here (in pixels):
		var canvasWidth = 512;
		var canvasHeight = 384;

		$(".zoom_gallery a[rel^='prettyPhoto']").prettyPhoto({
			default_width: canvasWidth,
			default_height: canvasHeight,
			//slideshow:false, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.70, /* opacity of background black */
			theme: 'pp_default', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			modal: true, /* If set to true, only the close button will close the window */    
			overlay_gallery: false,
			changepicturecallback: setZoom,
			callback: closeZoom,
			social_tools:false,
			image_markup: '<div style="width:'+canvasWidth+'px; height:'+canvasHeight+'px;"><img id="fullResImage" src="{path}" /></div>',
			fixed_size: true
		});
      
	});
</script>

In the above code,

- 1st line loads jQuery library. You may download the latest version of jQuery file from here and use it in case needed.

- 2nd line loads this Zoom plugin.

- 3rd line loads prettyPhoto plugin.

- The remaining lines are to implement and configure zoom plugin with prettyPhoto gallery.

- In these 2 lines, set the width and height of lightbox window:
        var canvasWidth = 512;
        var canvasHeight = 384;

- If you do not need fixed width & height for popup window and allow it to take available size of browser, do the following:
     1. Delete these 3 properties (just remove the whole line where these properties resides)
         default_width
         default_height
         image_markup

     2. Set value of the property fixed_size into false.

- All the remaining code are mostly prettyPhoto's settings. Please go through prettyPhoto's documentation for further details.

 

4. Next step is configuring the settings as per your need, which is explained in next Chapter. After customisation, upload the 2 folders zoom_assets and prettyPhoto along with your file.

 

 

 

 

 

 

 

 

 

 

 

Customisation


The Examples will help faster and easier implementation and also you can make deeper customisation from it.

Here are the list of plugin parameters:


Parameter

Description
width: 500
Adjust these two values to set desired zoom area. The values can be in 'px' or % or just number. If these values left blank (Ex: width: ''), the plugin will try to get 100% width and height of the parent container.

Example Values:  500 or '500' or '500px' or '100%'
height: 300
initial_ZOOM: ''

Initial zoom value in percentage. If left blank, the plugin will resize the image to fit the available area.

Example Values:  100, 200, 75

initial_POSITION: ''
Initial X, Y position value. If left blank, the plugin will just center the image

Example Value:  '300 480'
animation_SMOOTHNESS: 5.5
The zoom and pan smoothness. Values should be positive number and can be anywhere between 0 to 10
animation_SPEED_ZOOM: 5.5
The speed of scaling / resize. Values should be positive number and can be anywhere between 0 to 10
animation_SPEED_PAN: 5.5
The speed of movements / pan. Values should be positive number and can be anywhere between 0 to 10

zoom_MAX:800
Maximum allowable zoom level in percentage.
zoom_MIN:100
Minimum allowable zoom level in percentage.
zoom_SINGLE_STEP: false
To reach maximum and minimum zoom levels in single click.
zoom_OUT_TO_FIT: false

When the image is completely zoomed out, whether it should fill the canvas area (without any white space) or needs to fit and show the full image even if there are white space in either of side. 

Possible values: true / false

zoom_BUTTONS_SHOW: true
To show or hide the + and - Buttons.

Possible values: true / false

pan_BUTTONS_SHOW: true
To show or hide the pan (arrow) buttons. The Pan buttons can be completely removed along with Reset button.

Possible values: true / false
pan_LIMIT_BOUNDARY: true
Whether the image can be dragged inside the boundary fully or not.

Possible values: true / false
pan_REVERSE: false
It is possible to reverse the direction of movment here.

Possible values: true / false

reset_ALIGN_TO: 'center center'

While pressing the reset button, depending on some settings, the image may stilla have larger size than view area. In such cases, it is possible to align the image to desired position. 

Possible values:
'top left'
'top center'
'top right'

'center left'
'center center'
'center right'

'bottom left'
'bottom center'
'bottom right'

reset_TO_ZOOM_MIN: true

If the parameter zoom_MIN is enabled (by adding some value), then clicking minus button or reset button will zoom out only upto minimum value set. By making this paramter into false, reset button will allow image to shrink until it covers view area (even less than minimum value if needed).

Possible values: true / false


button_SIZE: 18
Button size in pixels. Can be increased upto 80
button_SIZE_TOUCH_DEVICE: 24
Button size in pixels but specially for touch devices. In touch devices, the button sizes needs to be larger for usability. Can be increased upto 80
button_COLOR: '#FFFFFF'
Button color in hexadecimal.

Note that some of the browsers doesn't support rounded corners. In such cases this plugin will use image graphics for corners. So when you change this color, you will need to edit the image graphics and change its color also. The image is on: zoom_assets/icons.png
button_BG_COLOR: '#000000'
The color of  background box which is below the buttons.

Note that some of the browsers doesn't support rounded corners. In such cases this plugin will use image graphics for corners. So when you change this color, you will need to edit the image graphics and change its color also. The image is on: zoom_assets/icons.png
button_BG_TRANSPARENCY: 55
The button background's transparency in percentage

Possible values: 0 to 100
button_AUTO_HIDE: false
To Show / Hide the navigation buttons when the user holds mouse over or outside the image.

Possible values: true / false
button_AUTO_HIDE_DELAY: 1
When the user mouse the mouse cursor outside the image, the auto-hide action will be triggered after a delay. Enter delay time in seconds.

Example Values:  2 or 1.5 or 3.2 etc
button_ALIGN: 'bottom right'
The buttons can be aligned to 9 possible locations:

'top left'
'top center'
'top right'

'center left'
'center center'
'center right'

'bottom left'
'bottom center'
'bottom right'
 
button_MARGIN: 10
The space between button set edge of the zoom area in pixels.
button_ROUND_CORNERS: true
To make all the buttons and button backgrounds corner into sharp edge.

Possible values: true / false

touch_DRAG: true
To enable / disable the touch drag option. (for touch devices)

Possible values: true / false
mouse_DRAG: true
To enable / disable the mouse drag option. (for mouse devices)

Possible values: true / false
mouse_WHEEL: true
To enable / disable the mouse wheel zoom option.

Possible values: true / false
mouse_WHEEL_CURSOR_POS: true
When the Mouse Wheel used, the zooming action focuses the mouse cursor position. To disable it and make it focus the canvas center, set this value into false

Possible values: true / false
mouse_DOUBLE_CLICK: true
To enable / disable the zoom action when double clicking the image.

Possible values: true / false

background_COLOR: '#FFFFFF'
Background color of the whole zoom area in hexadecimal. If don't want to set any color, then enter value 'transparent'
border_SIZE: 1
Thickness of the border applied to the entire zoom area. 
border_COLOR: '#000000'
Color of the border in hexadecimal
border_TRANSPARENCY: 10
Transparency of border in percentage

image_url: ''
If you prefer not to use img tag for image and just need to send the image url to plugin, this property will be helpful. In such cases, the plugin needs to be initiated using a div tag's id like this:

Assume, you have this div on body,
<div id='zoom_container'></div>
Initiate plugin this way:
$('#zoom_container').smoothZoom({
	image_url: 'my_image.jpg'
});
image_original_width: ''
Width of the main image. This value needed only when image inserter using image_url parameter instad of img tag. Although it is sufficient to use url attribute for img tags, it is needed on iOS browsers to if the location/landmarks used or focusTo method called.
image_original_height: ''
Height of the main image. This value needed only when image inserter using image_url parameter instad of img tag. Although it is sufficient to use url attribute for img tags, it is needed on iOS browsers to if the location/landmarks used or focusTo method called.
container: ''
By default, this plugin wraps your image by adding a div container as parent. In case you need to use your own container for such thing, enter the id of that container here.

on_IMAGE_LOAD: functionName
In case an external function needs to be called immediatly after image load, set your function here. This function has no return values.
on_ZOOM_PAN_UPDATE: functionName
In case an external function needs to be called whenever the zoom/pan animation happens, set your function here. The external function will receive 2 arguments.

- First one is the same object that getZoomData method returns. See getZoomData to know more about return values.
- Second argument is a boolean value to mention whether the animation completed or not.
on_ZOOM_PAN_COMPLETE: functionName
In case an external function needs to be called whenever the zoom/pan animation completes, set your function here. The external function will receive an argument which is the same object that getZoomData method returns. See getZoomData to know more about return values.
on_LANDMARK_STATE_CHANGE: functionName
In case an external function needs to be called whenever the zoom/pan animation completes, set your function here. The external function will receive single argument as boolean whether the landmarks are visible or not.

use_3D_Transform: true

In webkit based browsers (Chrome and Safari), using 3D transformation enables hardware acceleration which imporves performance. This is more benificial on the Smart phones and Tablets. However while using large number of landmarks (above 30-40), the same may not help performance, so it is recommended to disable only on such implementations.

Possible values: true / false


responsive: false
To enable / disable Responsive and Fluid layout support.

Possible values: true / false
responsive_maintain_ratio: true
When the responsive behavior is enabled, the width of the zoom container will resize and adjust to available space. In such cases we can either
- keep the height unchanged or
- change the height to maintain default proportion. 

Possible values: true / false
max_WIDTH: ''
Maximum possible width of view area in pixels. This property will be active only on following 2 occasions:

- Responsive property enabled
- Width property set to % value rather than pixels

Possible values: Any interger
max_HEIGHT: ''
Maximum possible heightof view area in pixels. This property will be active only on following 2 occasions:

- Responsive property enabled
- Height property set to % value rather than pixels

Possible values: Any interger

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Plugin Methods


This section lists all the plugin methods / functions available to interact. These functions does following variety of jobs:

1. Control Button activities such as zooming and panning
2. Adding/Removing landmarks dynamically
3. Resize the entire zoom area (container size) dynamically
4. Gets current scale and position values

1. Methods to mimic the control button activities:

focusTo:
$('#yourImageID').smoothZoom('focusTo',{
	x: 365,
	y: 245,
	zoom: 200,
	speed: 2
});

In the above method, all the 4 available properties are included. The speed is optional. Also the method can work with atleast one of the 3 main properties mentioned. Example: smoothZoom('focusTo', {zoom: 400});

 

Important: All the below functions should be called on Mouse Down event. NOT on click or Mouse Up.


Zoom In:
$('#yourImageID').smoothZoom('zoomIn');

Zoom Out:
$('#yourImageID').smoothZoom('zoomOut');

Move Left:
$('#yourImageID').smoothZoom('moveLeft');

Move Right:
$('#yourImageID').smoothZoom('moveRight');

Move Up:
$('#yourImageID').smoothZoom('moveUp');

Move Down:
$('#yourImageID').smoothZoom('moveDown');

Reset:
$('#yourImageID').smoothZoom('Reset'); 

 

 



2. Dynamic Location and Landmarks

To add/remove/update landmarks dynamically after page load, call the following methods:

For this particular set of methods, please go through the help comments added in the file Example 5 [Landmarks] - 02 Dynamic for more details.

 

Add new landmarks:
$('#yourImageID').smoothZoom('addLandmark', [LANDMARK 1, LANDMARK 2]);

More than 1 landmark can be added at a time. In the above code, LANDMARK 1 and LANDMARK 2 etc needs to be replaced with your DIV set. (See the file Example 5 [Landmarks] - 02 Dynamic on the source package for more details)


Attach landmarks:
$('#yourImageID').smoothZoom('attachLandmark', [ID1, ID2]);
Attaching landmarks means, the DIV set related to new landmark already appended to the landmarks container and now that new set needs to be "informed" to the zoom plugin. In the above code, ID1 and ID2 can be either a jQuery object or id of DIV sets to be attached.



Remove landmarks:
$('#yourImageID').smoothZoom('removeLandmark', [ID1, ID2]);
One or more Landmarks can be permanantly removes using the method. In the above code, ID1 and ID2 can be either a jQuery object or id of DIV sets to be attached.



Refresh the entire Landmark list:
$('#yourImageID').smoothZoom('refreshAllLandmarks');

This method may be required in case some of the landmarks added / removed directly inside the landmarks wrapper without using above methods. For example, if one or two new landmark DIV sets appended to the landmarks container, the plugin may not aware there are new elements added to the landmarks wrapper. Calling this method helps resolve that problem.

 

 

 


3. Resize view area (the container)

This plugin supports resposive behavior, so just enabling resposive setting will solve most of such requirements. However additionally this resize method provided.

Resize
$('#yourImageID').smoothZoom('resize', {width: 800, height: 600});
In the above method, just one property is enough if sufficient. Also following 2 properties can be added instead of width and height:
$('#yourImageID').smoothZoom('resize', {max_WIDTH: 800, max_HEIGHT: 600});

 

 

4. Get scale and position values

Calling this method returns the values as object. Please go through the next section Get Zoom Data for more details about accessing values. 

Get Zoom Data
$('#yourImageID').smoothZoom('getZoomData');

 

Get Zoom Data


It is possible to retrieve the zoom data at any time. Calling the getZoomData method will return details.
The example code to get scale ratio, x and y position:
var zoomData = $('#yourImageID').smoothZoom('getZoomData');
ratio = zoomData.ratio;
offsetX = zoomData.normX;
offsetY = zoomData.normY;

 

List of all the properties returned by the above method:

 
normX X offset without scale ratio multiplied
normY Y offset without scale ratio multiplied
normWidth Original image Width
normHeight Original image Height
 
scaledX X offset with scale ratio multiplied
scaledY Y offset with scale ratio multiplied
scaledWidth Scaled image Width
scaledHeight Scaled image Height
 
centerX The X point on image which is currently over center of canvas 
centerY The Y point on image which is currently over center of canvas 
ratio Ratio between original and scaled image dimension