From a2d81b75b4a97810054b75edf4cc2b55cd46d3e1 Mon Sep 17 00:00:00 2001 From: Piotr Pekala Date: Wed, 27 Feb 2019 01:44:26 -0800 Subject: [PATCH] Fix for moving tool --- .../drawing-adding.component.ts | 4 +-- .../text-editor/text-editor.component.ts | 8 +++--- src/app/cartography/widgets/drawings.ts | 28 +++++++++---------- .../projects/projects.component.html | 6 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/app/cartography/components/drawing-adding/drawing-adding.component.ts b/src/app/cartography/components/drawing-adding/drawing-adding.component.ts index 4553ae81..41782c86 100644 --- a/src/app/cartography/components/drawing-adding/drawing-adding.component.ts +++ b/src/app/cartography/components/drawing-adding/drawing-adding.component.ts @@ -25,8 +25,8 @@ export class DrawingAddingComponent implements OnInit, OnDestroy { activate() { let listener = (event: MouseEvent) => { - let x = event.pageX - this.context.getZeroZeroTransformationPoint().x; - let y = event.pageY - this.context.getZeroZeroTransformationPoint().y; + let x = event.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x); + let y = event.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y); this.drawingsEventSource.pointToAddSelected.emit(new AddedDataEvent(x, y)); this.deactivate(); diff --git a/src/app/cartography/components/text-editor/text-editor.component.ts b/src/app/cartography/components/text-editor/text-editor.component.ts index 10549b48..a5b72242 100644 --- a/src/app/cartography/components/text-editor/text-editor.component.ts +++ b/src/app/cartography/components/text-editor/text-editor.component.ts @@ -54,8 +54,8 @@ export class TextEditorComponent implements OnInit, OnDestroy { this.drawingsEventSource.textAdded.emit( new TextAddedDataEvent( this.temporaryTextElement.nativeElement.innerText.replace(/\n$/, ''), - event.pageX, - event.pageY + event.pageX - this.context.transformation.x, + event.pageY - this.context.transformation.y ) ); this.deactivateTextAdding(); @@ -92,8 +92,8 @@ export class TextEditorComponent implements OnInit, OnDestroy { this.editingDrawingId = textElements[index].parentElement.parentElement.getAttribute('drawing_id'); var transformData = textElements[index].parentElement.getAttribute('transform').split(/\(|\)/); - var x = Number(transformData[1].split(/,/)[0]) + this.context.getZeroZeroTransformationPoint().x; - var y = Number(transformData[1].split(/,/)[1]) + this.context.getZeroZeroTransformationPoint().y; + var x = Number(transformData[1].split(/,/)[0]) + this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x; + var y = Number(transformData[1].split(/,/)[1]) + this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y; this.leftPosition = x.toString() + 'px'; this.topPosition = y.toString() + 'px'; this.temporaryTextElement.nativeElement.innerText = elem.text; diff --git a/src/app/cartography/widgets/drawings.ts b/src/app/cartography/widgets/drawings.ts index aa240980..734c0bfd 100644 --- a/src/app/cartography/widgets/drawings.ts +++ b/src/app/cartography/widgets/drawings.ts @@ -111,15 +111,15 @@ export class DrawingsWidget implements Widget { } } } else { - dy = y - (evt.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y); - y = evt.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y; + dy = y - (evt.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y)); + y = evt.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y); if (datum.element.height + dy < 0) { isReflectedVertical = false; y = topEdge; datum.element.height = Math.abs(datum.element.height + evt.dy); } else { - datum.y = evt.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y; + datum.y = evt.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y); datum.element.height += dy; if (datum.element instanceof EllipseElement) { (datum.element as EllipseElement).cy = @@ -143,7 +143,7 @@ export class DrawingsWidget implements Widget { let top = drag() .on('start', (datum: MapDrawing) => { - y = event.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y; + y = event.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y); bottomEdge = y + datum.element.height; document.body.style.cursor = 'ns-resize'; }) @@ -151,15 +151,15 @@ export class DrawingsWidget implements Widget { const evt = event; if (!isReflectedVertical) { - dy = y - (evt.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y); - y = evt.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y; + dy = y - (evt.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y)); + y = evt.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y); if (datum.element.height + dy < 0) { y = bottomEdge; isReflectedVertical = true; datum.element.height = Math.abs(datum.element.height + evt.dy); } else { - datum.y = evt.sourceEvent.pageY - this.context.getZeroZeroTransformationPoint().y; + datum.y = evt.sourceEvent.pageY - (this.context.getZeroZeroTransformationPoint().y + this.context.transformation.y); datum.element.height += dy; if (datum.element instanceof EllipseElement) { (datum.element as EllipseElement).cy = @@ -207,7 +207,7 @@ export class DrawingsWidget implements Widget { let isReflectedHorizontal: boolean = false; let right = drag() .on('start', (datum: MapDrawing) => { - x = event.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x; + x = event.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x); leftEdge = x + datum.element.width; document.body.style.cursor = 'ew-resize'; }) @@ -215,15 +215,15 @@ export class DrawingsWidget implements Widget { const evt = event; if (!isReflectedHorizontal) { - dx = x - (evt.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x); - x = evt.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x; + dx = x - (evt.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x)); + x = evt.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x); if (datum.element.width + dx < 0) { x = leftEdge; isReflectedHorizontal = true; datum.element.width = Math.abs(datum.element.width + evt.dx); } else { - datum.x = evt.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x; + datum.x = evt.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x); datum.element.width += dx; if (datum.element instanceof EllipseElement) { (datum.element as EllipseElement).cx = @@ -290,15 +290,15 @@ export class DrawingsWidget implements Widget { datum.element.width = datum.element.width + evt.dx < 0 ? 1 : (datum.element.width += evt.dx); } } else { - dx = x - (evt.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x); - x = evt.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x; + dx = x - (evt.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x)); + x = evt.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x); if (datum.element.width + dx < 0) { x = rightEdge; isReflectedHorizontal = false; datum.element.width = Math.abs(datum.element.width + evt.dx); } else { - datum.x = evt.sourceEvent.pageX - this.context.getZeroZeroTransformationPoint().x; + datum.x = evt.sourceEvent.pageX - (this.context.getZeroZeroTransformationPoint().x + this.context.transformation.x); datum.element.width += dx; if (datum.element instanceof EllipseElement) { (datum.element as EllipseElement).cx = diff --git a/src/app/components/projects/projects.component.html b/src/app/components/projects/projects.component.html index 945b2663..7f785447 100644 --- a/src/app/components/projects/projects.component.html +++ b/src/app/components/projects/projects.component.html @@ -37,15 +37,15 @@ Actions + -