Mercurial > hg > digilib-old
changeset 1093:75a54db031dd
move found region into view, keep zoom factor if possible
author | hertzhaft |
---|---|
date | Thu, 18 Oct 2012 18:49:05 +0200 |
parents | 4964a1e252eb |
children | 8d6bc18f7145 |
files | webapp/src/main/webapp/jquery/jquery.digilib.regions.js |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/webapp/src/main/webapp/jquery/jquery.digilib.regions.js Thu Oct 18 17:22:55 2012 +0200 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.regions.js Thu Oct 18 18:49:05 2012 +0200 @@ -31,6 +31,7 @@ // the digilib object var digilib = null; // the functions made available by digilib + var FULL_AREA = null; var fn = { // dummy function to avoid errors, gets overwritten by buttons plugin highlightButtons : function () { @@ -312,7 +313,17 @@ var coords = $input.val(); var attr = { 'class' : cssPrefix+'regionURL '+cssPrefix+'findregion' }; console.debug('findCoords', coords); - createRegionFromCoords(data, data.userRegions, coords, attr); + var rect = createRegionFromCoords(data, data.userRegions, coords, attr); + var za = data.zoomArea; + if (!fn.isFullArea(za)) { + za.setCenter(rect.getCenter()); + za.clipTo(FULL_AREA); + if (!za.containsRect(rect)) { + fn.setZoomArea(data, FULL_AREA.copy()); + } else { + fn.setZoomArea(data, za); + } + } fn.withdraw($info); redisplay(data); return false; @@ -697,6 +708,7 @@ var $elem = data.$elem; var settings = data.settings; var cssPrefix = data.settings.cssPrefix; + FULL_AREA = geom.rectangle(0, 0, 1, 1); // region arrays data.userRegions = []; data.htmlRegions = [];