{"id":1370,"date":"2010-11-01T19:44:57","date_gmt":"2010-11-01T18:44:57","guid":{"rendered":"http:\/\/www.simonbattersby.com\/blog\/?page_id=1370"},"modified":"2013-09-14T11:46:35","modified_gmt":"2013-09-14T10:46:35","slug":"jquery-plugin-zoom-draggable-image-gallery","status":"publish","type":"page","link":"https:\/\/www.simonbattersby.com\/blog\/jquery-plugin-zoom-draggable-image-gallery\/","title":{"rendered":"jQuery zoom and draggable image gallery"},"content":{"rendered":"<p>This gallery plugin offers an alternate approach to the lightbox-style plugins which are in common use and allows the following:<\/p>\r\n\r\n<ul class=\"bulletlist\">\r\n<li>Large images to be &#8220;zoomed out&#8221; on clicking on a thumbnail<\/li>\r\n<li>Large images to be zoomed back in by another click<\/li>\r\n<li>Optionally, multiple large images to be displayed at once<\/li>\r\n<li>Optionally, large images to be &#8220;draggable&#8221; round the screen to allow the user to examine\/compare large images<\/li>\r\n<li>Configurable border colour, border widths and captions<\/li>\r\n<\/ul>\r\n\r\n<p>I&#8217;ve tested in FF3, IE8, IE7, IE6, Opera 9, Opera 10, Safari 4, Safari 5 and Chrome, using jQuery 1.4.2 and jQuery UI 1.8.2, all on Win\/XP, plus FF23, IE9, IE10, Opera 12 and Chrome, using jQuery 1.8.3 and jQuery UI 1.8.23, on W7. Beware, some combinations of jQuery and jQuery UI cause outerHeight() to return a jQuery object instead of an integer, which results in the caption being positioned incorrectly.<\/p>\r\n\r\n<p class=\"orange\">Due to an apparent bug with jQuery 1.4.3 and jQuery UI 1.8.5 or less, affecting UI Draggable in webkit browsers (Safari and Chrome), this combination does not work. Use jQuery 1.4.3 and jQuery 1.8.6 or later.<\/p>\r\n\r\n<h3>Demo<\/h3>\r\n<div id=\"democontainer\">\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/photography\/insects\/Gallery1.jpg\" class=\"active\" alt=\"Hoverfly on a green leaf\" title=\"Hoverfly. Canon EOS350D, Tamron 90mm\" height=\"100\" width=\"150\"\/>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/photography\/insects\/Gallery9.jpg\" alt=\"House fly on a green leaf\" title=\"House fly. Canon EOS350D, Tamron 90mm\" width=\"150\" height=\"100\"\/>\r\n<img loading=\"lazy\" decoding=\"async\" src=\"\/images\/photography\/insects\/Gallery12.jpg\" alt=\"Blue bottle fly\" title=\"Blue bottle fly. Tamron 90mm\" width=\"150\" height=\"100\"\/>\r\n<\/div>\r\n\r\n<p>There&#8217;s a larger demo <a href=\"\/demos\/galleryplugin_demo.htm\" title=\"Zoom and draggable gallery demo\">here<\/a>.<\/p>\r\n\r\n\r\n<h3>Setup<\/h3>\r\n\r\n<p>This gallery requires jQuery, so you need to load this and the plugin into in your head, plus the css file. If you want to use the draggable options (see below), then jQuery UI is also required:<\/p>\r\n\r\n<pre>&lt;script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.8.3\/jquery.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jqueryui\/1.8.23\/jquery-ui.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\" src=\"\/javascript\/jquery.orangegalleryjs\"&gt;&lt;\/script&gt;\r\n&lt;link rel=\"stylesheet\" href=\"\/css\/orangemenu.css\"\/&gt;\r\n<\/pre>\r\n\r\n<p>The plugin expects images loaded within the target div. There are a couple of conditions:<\/p>\r\n\r\n<ul class=\"bulletlist\">\r\n<li>Other html elements are allowed within the container div, including additional elements enclosing the images, but there must be no elements containing the images that have position:relative. The containing div itself may have position:relative.<\/li>\r\n<li>The container element should not have overflow:hidden, overflow:auto or overflow:scroll set &#8211; otherwise the zoomed out images may not be fully visible<\/li>\r\n<\/ul>\r\n\r\n<p>The large images (currently at least) zoom out to their maximum dimensions.<\/p>\r\n\r\n<h3>Configuration<\/h3>\r\n\r\n<p>To use the plugin with default settings all you need is this:<\/p>\r\n\r\n<pre>&lt;script type=&quot;text\/javascript&quot;&gt;\r\n$(document).ready(function(){\r\n$('#gallery).orangegallery();\r\n});\r\n&lt;\/script&gt;<\/pre>\r\n\r\n<h4>Gallery settings<\/h4>\r\n<p>To apply a setting, the setting name, followed by a colon, followed by the required value as shown below, all wrapped in curly brackets {}, needs to be entered in the round brackets after orangegallery. Separate multiple settings with a comma. See below for some examples.<\/p>\r\n<table class=\"displaytable\">\r\n<tr>\r\n<th>Setting<\/th>\r\n<th>Description<\/th>\r\n<th>Example values<\/th>\r\n<th>Default value<\/th>\r\n<\/tr>\r\n<tr>\r\n<td>borderWidth<\/td>\r\n<td>Sets the width of the border in pixels. Set to 0 for no border. Enter as an integer, without units.<\/td>\r\n<td> 5,10 etc<\/td>\r\n<td>5<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>borderColour<\/td>\r\n<td>Sets the colour of the border and the caption background. Enter either a colour name or a hex value. Note UK spelling of colo<strong>u<\/strong>r.<\/td>\r\n<td>&#8216;steelblue&#8217; , &#8216;#EA714C&#8217;<\/td>\r\n<td>&#8216;black&#8217;<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>caption<\/td>\r\n<td>Sets whether a caption is displayed. Enter as a boolean without quotes.<\/td>\r\n<td>true, false<\/td>\r\n<td>true<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>captionPosition<\/td>\r\n<td>Sets whether the caption should be displayed at the top or bottom of the image.<\/td>\r\n<td>&#8216;top&#8217;,&#8217;bottom&#8217;<\/td>\r\n<td>&#8216;bottom&#8217;<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>captionTextColour<\/td>\r\n<td>Sets the colour of the caption text. Bet you guessed that. Enter either a colour name or a hex value.<\/td>\r\n<td>&#8216;teal&#8217;,&#8217;#121212&#8242;<\/td>\r\n<td>&#8216;white&#8217;<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>captionOpacity<\/td>\r\n<td>Sets the degree of opacity of the caption (how see through it is). Set to 1 for competely opaque.<\/td>\r\n<td>Any numeric value between 0 and 1<\/td>\r\n<td>0.7<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>allowMany<\/td>\r\n<td>Sets whether more than one large image can be displayed at once. If this is set to false, opening a large image will cause a previously opened large inage to fade out. Set as a boolean with no quotes.<\/td>\r\n<td>true,false<\/td>\r\n<td>false<\/td>\r\n<\/tr>\r\n<tr>\r\n<td>draggable<\/td>\r\n<td>Sets whether a large image can be moved around the page once zoomed. Set as a boolean with no quotes.<\/td>\r\n<td>true,false<\/td>\r\n<td>false<\/td>\r\n<\/tr>\r\n<\/table>\r\n\r\n<h4>Configuration examples<\/h4>\r\n<p>This sets a 4px red border, with a caption at the top.<\/p>\r\n<pre>$(document).ready(function(){\r\n    $('#mydiv).orangegallery({borderColour: 'red',borderWidth: 4, captionPosition: 'top'});\r\n});<\/pre>\r\n\r\n<p>This sets an opaque caption, and allows multiple large images.<\/p>\r\n<pre>$(document).ready(function(){\r\n    $('#mydiv').orangegallery({captionOpacity:1,allowMany:true});\r\n});<\/pre>\r\n\r\n<h3>Download<\/h3>\r\n<p><a href=\"\/demos\/plugins\/orangegallery.zip\">Zoom and draggable gallery zip file<\/a><\/p>\r\n\r\n<h3>Can I use this on my site?<\/h3>\r\n<p>Probably. See my <a href=\"\/blog\/use-of-code-from-this-site\/\">policies on using code from this site<\/a>.<\/p>\r\n<script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jqueryui\/1.8.23\/jquery-ui.min.js\" ><\/script>\r\n<script type=\"text\/javascript\" src=\"\/javascript\/jquery.orangegallery.js\"><\/script>\r\n<script type=\"text\/javascript\">$(document).ready(function(){\r\n$('#democontainer').orangegallery({draggable:true,caption:true,allowMany:true});\r\n});<\/script>","protected":false},"excerpt":{"rendered":"<p>This gallery plugin offers an alternate approach to the lightbox-style plugins which are in common use and allows the following: Large images to be &#8220;zoomed out&#8221; on clicking on a thumbnail Large images to be zoomed back in by another click Optionally, multiple large images to be displayed at once Optionally, large images to be [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1370","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/1370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/comments?post=1370"}],"version-history":[{"count":5,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/1370\/revisions"}],"predecessor-version":[{"id":2882,"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/pages\/1370\/revisions\/2882"}],"wp:attachment":[{"href":"https:\/\/www.simonbattersby.com\/blog\/wp-json\/wp\/v2\/media?parent=1370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}