Skip to content
Snippets Groups Projects
Commit 36f64f19 authored by rhenck's avatar rhenck
Browse files

[editor] Remove resize functionality in dynamic sections

This had to many implementation problems and is not really an important 
feature. Removing the corresponding stylings also improves the visual 
layout - elements can now grow freely and the section resized with them.
parent b3ba97b0
No related branches found
No related tags found
No related merge requests found
import { import {
Component, Input, Output, EventEmitter, ViewChild, ElementRef Component, Input, ViewChild, ElementRef
} from '@angular/core'; } from '@angular/core';
import { CdkDragMove } from '@angular/cdk/drag-drop';
import { CanvasElementOverlay } from './canvas-element-overlay'; import { CanvasElementOverlay } from './canvas-element-overlay';
import { UIElement } from '../../../../../../../../common/interfaces/elements';
@Component({ @Component({
selector: 'aspect-dynamic-canvas-overlay', selector: 'aspect-dynamic-canvas-overlay',
...@@ -14,7 +12,6 @@ import { UIElement } from '../../../../../../../../common/interfaces/elements'; ...@@ -14,7 +12,6 @@ import { UIElement } from '../../../../../../../../common/interfaces/elements';
[class.fixed-size-content-wrapper]="element.position?.dynamicPositioning && [class.fixed-size-content-wrapper]="element.position?.dynamicPositioning &&
element.position?.fixedSize" element.position?.fixedSize"
[class.temporaryHighlight]="temporaryHighlight" [class.temporaryHighlight]="temporaryHighlight"
[style.display]="dragging ? 'none' : ''"
tabindex="-1" tabindex="-1"
cdkDrag [cdkDragData]="{dragType: 'move', element: element}" cdkDrag [cdkDragData]="{dragType: 'move', element: element}"
(click)="elementClicked($event)" (dblclick)="openEditDialog()" (click)="elementClicked($event)" (dblclick)="openEditDialog()"
...@@ -23,17 +20,6 @@ import { UIElement } from '../../../../../../../../common/interfaces/elements'; ...@@ -23,17 +20,6 @@ import { UIElement } from '../../../../../../../../common/interfaces/elements';
[style.outline]="isSelected ? 'purple solid 1px' : ''" [style.outline]="isSelected ? 'purple solid 1px' : ''"
[style.z-index]="isSelected ? 2 : 1"> [style.z-index]="isSelected ? 2 : 1">
<div *cdkDragPlaceholder></div> <div *cdkDragPlaceholder></div>
<div *ngIf="isSelected"
[style.width.%]="dragging ? 100 : 0"
[style.height.%]="dragging ? 100 : 0"
cdkDrag [cdkDragData]="{dragType: 'resize', element: element}"
(cdkDragStarted)="resizeDragStart()" (cdkDragEnded)="resizeDragEnd()"
(cdkDragMoved)="resizeDragMove($event)">
<div class="resizeHandle">
<mat-icon>aspect_ratio</mat-icon>
<div *cdkDragPlaceholder></div>
</div>
</div>
<div [class.fixed-size-content]="element.position?.dynamicPositioning && <div [class.fixed-size-content]="element.position?.dynamicPositioning &&
element.position?.fixedSize" element.position?.fixedSize"
[style.width]="element.position?.dynamicPositioning && element.position?.fixedSize ? [style.width]="element.position?.dynamicPositioning && element.position?.fixedSize ?
...@@ -43,61 +29,18 @@ import { UIElement } from '../../../../../../../../common/interfaces/elements'; ...@@ -43,61 +29,18 @@ import { UIElement } from '../../../../../../../../common/interfaces/elements';
<ng-template #elementContainer></ng-template> <ng-template #elementContainer></ng-template>
</div> </div>
</div> </div>
<div class="resize-preview"
[style.position]="'relative'"
[style.width.px]="dragging ? elementWidth : 0"
[style.height.px]="dragging ? elementHeight : 0"
[style.border]="'1px dashed purple'">
</div>
`, `,
styles: [ styles: [
'.draggable-element {position: relative; width: 100%; height: 100%}', '.draggable-element {position: relative; width: 100%; height: 100%}',
'.draggable-element:active {cursor: grabbing}', '.draggable-element:active {cursor: grabbing}',
'.resizeHandle {position: absolute; right: 3px; bottom: 3px; z-index: 1; height: 25px}',
'.resizeHandle {cursor: nwse-resize}',
'.cdk-drag {position: absolute; bottom: 0; right: 0}',
'.temporaryHighlight {z-index: 100}' '.temporaryHighlight {z-index: 100}'
] ]
}) })
export class DynamicCanvasOverlayComponent extends CanvasElementOverlay { export class DynamicCanvasOverlayComponent extends CanvasElementOverlay {
@Input() dynamicPositioning!: boolean; @Input() dynamicPositioning!: boolean;
@Output() dragStart = new EventEmitter();
@Output() dragEnd = new EventEmitter();
@ViewChild('draggableElement') dragElement!: ElementRef; @ViewChild('draggableElement') dragElement!: ElementRef;
private gridElementWidth: number = 0;
private gridElementHeight: number = 0;
elementWidth: number = 0;
elementHeight: number = 0;
dragging = false;
bodyElement: HTMLElement = document.body; bodyElement: HTMLElement = document.body;
resizeDragStart(): void {
this.bodyElement.classList.add('inheritCursors');
this.bodyElement.style.cursor = 'nwse-resize';
this.dragging = true;
this.gridElementWidth = this.dragElement.nativeElement.offsetWidth - 2;
this.gridElementHeight = this.dragElement.nativeElement.offsetHeight - 2;
this.elementWidth = this.dragElement.nativeElement.offsetWidth - 2;
this.elementHeight = this.dragElement.nativeElement.offsetHeight - 2;
this.dragStart.emit();
}
resizeDragMove(event: CdkDragMove<{ dragType: string; element: UIElement }>): void {
this.dragging = true;
this.elementWidth = this.gridElementWidth + event.distance.x;
this.elementHeight = this.gridElementHeight + event.distance.y;
}
resizeDragEnd(): void {
this.bodyElement.classList.remove('inheritCursors');
this.bodyElement.style.cursor = 'unset';
this.dragging = false;
this.dragEnd.emit();
}
moveDragStart(): void { moveDragStart(): void {
this.selectElement(); this.selectElement();
this.bodyElement.classList.add('inheritCursors'); this.bodyElement.classList.add('inheritCursors');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment