comparison client/digitallibrary/jquery/jquery.digilib.js @ 747:fd4842f0afc7 jquery

smoother birdZoom indicator movement; fixed bug in jQuery.offset()
author hertzhaft
date Sat, 05 Feb 2011 13:53:45 +0100
parents 2e9a48dc7a0c
children 4b9349765b9c
comparison
equal deleted inserted replaced
746:2e9a48dc7a0c 747:fd4842f0afc7
1300 birdZoomRect = geom.rectangle($birdZoom); 1300 birdZoomRect = geom.rectangle($birdZoom);
1301 newRect = null; 1301 newRect = null;
1302 fullRect = setZoomBG(data); // setup zoom background image 1302 fullRect = setZoomBG(data); // setup zoom background image
1303 $document.bind("mousemove.dlBirdMove", birdZoomMove); 1303 $document.bind("mousemove.dlBirdMove", birdZoomMove);
1304 $document.bind("mouseup.dlBirdMove", birdZoomEndDrag); 1304 $document.bind("mouseup.dlBirdMove", birdZoomEndDrag);
1305 // $birdZoom.bind("mousemove.dlBirdMove", birdZoomMove);
1306 // $birdZoom.bind("mouseup.dlBirdMove", birdZoomEndDrag);
1307 return false; 1305 return false;
1308 }; 1306 };
1309 1307
1310 // mousemove handler: drag 1308 // mousemove handler: drag
1311 var birdZoomMove = function(evt) { 1309 var birdZoomMove = function(evt) {
1312 var pos = geom.position(evt); 1310 var pos = geom.position(evt);
1313 var delta = startPos.delta(pos); 1311 var delta = startPos.delta(pos);
1314 // move birdZoom div, keeping size 1312 // move birdZoom div, keeping size
1315 newRect = birdZoomRect.copy(); 1313 newRect = birdZoomRect.copy();
1316 newRect.addPosition(delta); 1314 newRect.addPosition(delta);
1317 // stay within birdimage
1318 newRect.stayInside(birdImgRect); 1315 newRect.stayInside(birdImgRect);
1316 // acount for border width
1317 newRect.addPosition({x : -2, y : -2});
1319 newRect.adjustDiv($birdZoom); 1318 newRect.adjustDiv($birdZoom);
1320 // reflect birdview zoom position in scaler image 1319 // reflect birdview zoom position in scaler image
1321 // TODO: account for scaler position in embedded mode? 1320 // TODO: account for scaler position in embedded mode?
1322 var area = data.birdTrafo.invtransform(newRect); 1321 var area = data.birdTrafo.invtransform(newRect);
1323 var imgArea = data.imgTrafo.transform(area); 1322 var imgArea = data.imgTrafo.transform(area);
1337 // mouseup handler: reload page 1336 // mouseup handler: reload page
1338 var birdZoomEndDrag = function(evt) { 1337 var birdZoomEndDrag = function(evt) {
1339 var settings = data.settings; 1338 var settings = data.settings;
1340 $document.unbind("mousemove.dlBirdMove", birdZoomMove); 1339 $document.unbind("mousemove.dlBirdMove", birdZoomMove);
1341 $document.unbind("mouseup.dlBirdMove", birdZoomEndDrag); 1340 $document.unbind("mouseup.dlBirdMove", birdZoomEndDrag);
1342 // $birdZoom.unbind("mousemove.dlBirdMove", birdZoomMove);
1343 // $birdZoom.unbind("mouseup.dlBirdMove", birdZoomEndDrag);
1344 if (newRect == null) { 1341 if (newRect == null) {
1345 // no movement happened - set center to click position 1342 // no movement happened - set center to click position
1346 startPos = birdZoomRect.getCenter(); 1343 startPos = birdZoomRect.getCenter();
1347 birdZoomMove(evt); 1344 birdZoomMove(evt);
1348 } 1345 }
1346 // ugly, but needed to prevent double border width compensation
1347 newRect.addPosition({x : +2, y : +2});
1349 var newArea = data.birdTrafo.invtransform(newRect); 1348 var newArea = data.birdTrafo.invtransform(newRect);
1350 data.zoomArea = newArea; 1349 data.zoomArea = newArea;
1351 redisplay(data); 1350 redisplay(data);
1352 return false; 1351 return false;
1353 }; 1352 };
1364 }; 1363 };
1365 1364
1366 // move bird zoom indicator to reflect zoomed detail area 1365 // move bird zoom indicator to reflect zoomed detail area
1367 var setBirdZoom = function(data, rect) { 1366 var setBirdZoom = function(data, rect) {
1368 var part = data.imgTrafo.invtransform(rect); 1367 var part = data.imgTrafo.invtransform(rect);
1369 // area = FULL_AREA.fit(part); // we want to see where we transcend the borders 1368 // area = FULL_AREA.fit(part); // no, we want to see where we transcend the borders
1370 birdTrafo = getImgTrafo(data.$birdImg, FULL_AREA); 1369 birdTrafo = getImgTrafo(data.$birdImg, FULL_AREA);
1371 var birdRect = birdTrafo.transform(part); 1370 var birdRect = birdTrafo.transform(part);
1372 // acount for border width 1371 // acount for border width
1373 birdRect.addPosition({x : -2, y : -2}); 1372 birdRect.addPosition({x : -2, y : -2});
1374 birdRect.adjustDiv(data.$birdZoom); 1373 birdRect.adjustDiv(data.$birdZoom);