Images used are copyrighted and are used for demonstration only.
Download shiftzoom.js and include it into your webpages HEAD section.
<script type="text/javascript" src="shiftzoom.js"></script>
// only if the cursor images for IE are not in the current path
<scriptscript type="text/javascript">
shiftzoom.defaultCurpath='images/cursors/';
</script>
To add shiftzoom just set the event onload="shiftzoom.add(this);" to an div surrounded image.
<div><img onLoad="shiftzoom.add(this);" width="400" height="200" ...></div>
Mouse- and Keyboard-driven handling:
![]() ![]() |
zoom in | ![]() |
zoom in | ![]() |
zoom in* | ||||||
![]() ![]() |
zoom out | ![]() |
zoom out | ![]() |
zoom out* |
Keyboard-driven handling: (if focused through mouse over image)
![]() |
pan left | ![]() ![]() |
pan left (fast) | ![]() ![]() |
pan left (slow) | ||||||
![]() |
pan right | ![]() ![]() |
pan right (fast) | ![]() ![]() |
pan right (slow) | ||||||
![]() |
pan up | ![]() ![]() |
pan up (fast) | ![]() ![]() |
pan up (slow) | ||||||
![]() |
pan down | ![]() ![]() |
pan down (fast) | ![]() ![]() |
pan down (slow) | ||||||
![]() |
zoom in* | ![]() |
zoom in (fast) | ![]() |
zoom in | ||||||
![]() |
zoom out* | ![]() |
zoom out (fast) | ![]() |
zoom out |
shiftzoom.defaultFading = true; //BOOLEAN startup image fadingshiftzoom.defaultButtons = true; //BOOLEAN left top buttonsshiftzoom.defaultZoom = 0; //INT/FLOAT 0-100 (%) zooming percentageshiftzoom.defaultXpos = 50; //INT/FLOAT 0-100 (%) horizontal positionshiftzoom.defaultYpos = 50; //INT/FLOAT 0-100 (%) vertical positionshiftzoom.defaultOpacity = 70; //INT 0-100 (%) zoom button opacityshiftzoom.defaultMillisec = 30; //INT 5-100 zoom interval delayshiftzoom.defaultIntitle = 'zoom in'; //STR zoom in button title textshiftzoom.defaultOuttitle = 'zoom out'; //STR zoom out button title textshiftzoom.defaultCurpath = ''; //STR cursor path (*.cur) IE onlyshiftzoom.defaultShowcoords = false; //BOOLEAN show coordinatesshiftzoom.defaultPixelcoords= true; //BOOLEAN show pixel coords instead of Lat/Lonshiftzoom.defaultOverview = true; //BOOLEAN show overviewshiftzoom.defaultOvsfact = 25; //INT 10-50 (%) overview size factorshiftzoom.defaultOvaopac = 75; //INT 0-100 (%) overview area opacityshiftzoom.defaultOvacolor = 'red'; //STR overview area css colorshiftzoom.defaultOvbcolor = 'white'; //STR overview border css colorshiftzoom.defaultOvborder = ''; //INT 0-20 (px) or "" overview border widthshiftzoom.add(image[, options]);image == div surrounded imageoptions e.g. {overview: true, opacity: 32, ...}fading == BOOLEAN true or false Default: truebuttons == BOOLEAN true or false Default: truezoom == INT/FLOAT 0 - 100 Default: 0xpos == INT/FLOAT 0 - 100 Default: 50ypos == INT/FLOAT 0 - 100 Default: 50opacity == INT 0 - 100 Default: 90millisec == INT 5 - 100 Default: 40intitle == STRING Default: 'click or press shift key to zoom in'outtitle == STRING Default: 'click or press alt key to zoom out'curpath == STRING Default: ''showcoords == BOOLEAN true or false Default: falsepixelcoords== BOOLEAN true or false Default: trueoverview == BOOLEAN true or false Default: trueovsfact == INT 10 - 50 Default: 25ovaopac == INT 0 - 100 Default: 75ovacolor == STRING '#ffaa00' or 'orange' Default: 'red'ovbcolor == STRING '#0000ff' or 'blue' Default: 'white'ovborder == INT 0 - 20 Default: automatic
FLOAT|INT = shiftzoom.get(image, ['maxzoomx'|'maxzoomy'|'maxwidth'|'maxheight']);
shiftzoom.set(image, ['buttons'|'overview'|'showcoords'|'pixelcoords'], [true|false]);
shiftzoom.source(image, value, boolean);value == URI (e.g. 'images/world.jpg')
boolean == fade out/in (true or false)
shiftzoom.zooming(image, value);value == 0 - 100 (%) default: 0
shiftzoom.moveto(image, x, y);
x,y default: 0,0if x or y == INT e.g. 189
then it's interpreted as pixel from within natural image dimensionif x or y == STR e.g. '50%' Pattern: (INT|FLOAT)%
then it's interpreted as percentageif x or y == STR e.g. '-23.057' Pattern: (+|-)(INT|FLOAT)
then it's interpreted as longitude or latitudeshiftzoom.remove(image);
<img onLoad="shiftzoom.add(this);" ...>shiftzoom.add(document.getElementById('img'));if(typeof $=='undefined') {function $(v) {return(document.getElementById(v));}}shiftzoom.add($('img'));shiftzoom.add($('img'), {fading:false, curpath:'cursors/'});shiftzoom.set($('img'),'overview',false);alert(shiftzoom.get($('img'),'maxwidth'));shiftzoom.source($('img'),'images/world.jpg',false);shiftzoom.zooming($('img'),100);shiftzoom.moveto($('img'),'50%','50%');shiftzoom.remove($('img'));In very old browsers, the script degrades and your visitors won't notice a thing.
Please read the License before you download shiftzoom.js 1.9
Please read the Frequently Asked Questions before you contact the author.
Operas cursor handling sucks. IE needs external cursor images (*.cur).
Handling javascript mouse events is not a simple thing, because there are inconsistancies in the way different browsers implement mouse events. That's the reason why the response on right mouse button is inconsistent in shiftzoom. The differences in detail:
Version 1.9
Please leave any comments at this contact formular.
shiftzoom.js is distributed under the Netzgestade Non-commercial Software License Agreement.
License permits free of charge use on non-commercial and private web sites only under special conditions (as described in the license).
This license equals neither "open source" nor "public domain".
There are also Commercial Software Licenses available.