# HG changeset patch # User hertzhaft # Date 1423411860 -3600 # Node ID 668a62a873b24c58183f4a3cc89afbddad5f7d97 # Parent 7c6292ae8725e05053e1480dfcbb0f0599905aa9 store screen positions on drag; trigger positionShape event diff -r 7c6292ae8725 -r 668a62a873b2 webapp/src/main/webapp/jquery/jquery.digilib.measure.css --- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.css Tue Feb 03 23:52:29 2015 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.css Sun Feb 08 17:11:00 2015 +0100 @@ -24,7 +24,7 @@ input#dl-measure-value1:disabled { color: black; background-color: silver; - border: none; + border: none; } span.dl-measure-label { diff -r 7c6292ae8725 -r 668a62a873b2 webapp/src/main/webapp/jquery/jquery.digilib.measure.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Tue Feb 03 23:52:29 2015 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.measure.js Sun Feb 08 17:11:00 2015 +0100 @@ -803,6 +803,12 @@ _debug_shape('onCreateShape', shape); }; + // event handler for positionShape + var onPositionShape = function(event, shape) { + var data = this; + _debug_shape('onPositionShape', shape.properties.screenpos); + }; + // event handler for dragShape var onDragShape = function(event, shape) { var data = this; @@ -1216,6 +1222,7 @@ $data.on('createShape', onCreateShape); $data.on('renderShape', onRenderShape); $data.on('changeShape', onChangeShape); + $data.on('positionShape', onPositionShape); $data.on('dragShape', onDragShape); }; diff -r 7c6292ae8725 -r 668a62a873b2 webapp/src/main/webapp/jquery/jquery.digilib.vector.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.vector.js Tue Feb 03 23:52:29 2015 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.vector.js Sun Feb 08 17:11:00 2015 +0100 @@ -298,7 +298,7 @@ 'style': 'position:absolute; z-index:10; pointer-events:none;'}); $svg = $(svgElem); layer.svgElem = svgElem; - layer.$elem = $svg; + layer.$elem = $svg; for (var i = 0; i < shapes.length; ++i) { var shape = shapes[i]; renderShape(data, shape, layer); @@ -492,6 +492,8 @@ // cancel if not left-click if (evt.which != 1) return; pStart = geom.position(evt); + shape.properties.screenpos[0] = pStart; + $(data).trigger('positionShape', shape); if ($.inArray(shapeType, ['Rectangle', 'Circle', 'Ellipse']) > -1) { // save screen points of coordinates pt1 = data.imgTrafo.transform(geom.position(shape.geometry.coordinates[0])); @@ -505,6 +507,8 @@ var dragMove = function (evt) { // dragging var pt = geom.position(evt); + shape.properties.screenpos[vtx] = pt; + $(data).trigger('positionShape', shape); pt.clipTo(imgRect); // move handle $handle.attr({'x': pt.x-hs/2, 'y': pt.y-hs/2}); @@ -556,6 +560,8 @@ var dragEnd = function (evt) { // end dragging var pt = geom.position(evt); + shape.properties.screenpos[vtx] = pt; + $(data).trigger('positionShape', shape); if ((pt.distance(pStart) < 5) && evt.type === 'mouseup') { // not drag but click to start return false; @@ -636,6 +642,7 @@ if (shape.properties != null) { shape.properties._editable = shape.properties.editable; shape.properties.editable = false; + shape.properties.screenpos = []; } else { shape.properties = {'editable' : false}; }