Skip to content
Snippets Groups Projects
Commit 37a5b75d authored by jojohoch's avatar jojohoch
Browse files

Define placeholder dimensions for dynamic aligned drop lists

- Refactor variable of the placeholder dimensions
parent c5eac7f3
No related branches found
No related tags found
No related merge requests found
...@@ -64,8 +64,8 @@ import { DropListComponent } from 'common/components/input-elements/drop-list.co ...@@ -64,8 +64,8 @@ import { DropListComponent } from 'common/components/input-elements/drop-list.co
{{value.text}} {{value.text}}
</div> </div>
<div class="drag-placeholder" *cdkDragPlaceholder <div class="drag-placeholder" *cdkDragPlaceholder
[style.height.%]="placeholderHeight" [style.height.%]="placeholderDimensions.height"
[style.width.%]="placeholderWidth"> [style.width.%]="placeholderDimensions.width">
</div> </div>
{{value.text}} {{value.text}}
</div> </div>
...@@ -92,8 +92,7 @@ import { DropListComponent } from 'common/components/input-elements/drop-list.co ...@@ -92,8 +92,7 @@ import { DropListComponent } from 'common/components/input-elements/drop-list.co
}) })
export class DropListSimpleComponent extends FormElementComponent { export class DropListSimpleComponent extends FormElementComponent {
@Input() elementModel!: DropListSimpleElement; @Input() elementModel!: DropListSimpleElement;
placeholderHeight: number = 1; placeholderDimensions: { width: number, height: number } = { width: 1, height: 1 };
placeholderWidth: number = 1;
bodyElement: HTMLElement = document.body; bodyElement: HTMLElement = document.body;
...@@ -147,8 +146,8 @@ export class DropListSimpleComponent extends FormElementComponent { ...@@ -147,8 +146,8 @@ export class DropListSimpleComponent extends FormElementComponent {
} }
setPlaceholderDimensions(itemsCount: number, orientation: unknown): void { setPlaceholderDimensions(itemsCount: number, orientation: unknown): void {
this.placeholderHeight = itemsCount && orientation !== 'horizontal' ? 1 : 100; this.placeholderDimensions.height = itemsCount && orientation === 'vertical' ? 1 : 100;
this.placeholderWidth = itemsCount && orientation !== 'vertical' ? 1 : 100; this.placeholderDimensions.width = itemsCount && orientation !== 'vertical' ? 1 : 100;
} }
onlyOneItemPredicate = (drag: CdkDrag, drop: CdkDropList): boolean => ( onlyOneItemPredicate = (drag: CdkDrag, drop: CdkDropList): boolean => (
......
...@@ -75,8 +75,8 @@ import { FormElementComponent } from '../../directives/form-element-component.di ...@@ -75,8 +75,8 @@ import { FormElementComponent } from '../../directives/form-element-component.di
{{dropListValueElement.text}} {{dropListValueElement.text}}
</div> </div>
<div class="drag-placeholder" *cdkDragPlaceholder <div class="drag-placeholder" *cdkDragPlaceholder
[style.height.%]="placeholderHeight" [style.height.%]="placeholderDimensions.height"
[style.width.%]="placeholderWidth"> [style.width.%]="placeholderDimensions.width">
</div> </div>
{{dropListValueElement.text}} {{dropListValueElement.text}}
</div> </div>
...@@ -142,8 +142,7 @@ export class DropListComponent extends FormElementComponent { ...@@ -142,8 +142,7 @@ export class DropListComponent extends FormElementComponent {
bodyElement: HTMLElement = document.body; bodyElement: HTMLElement = document.body;
draggedItemIndex: number | null = null; draggedItemIndex: number | null = null;
placeholderHeight: number = 1; placeholderDimensions: { width: number, height: number } = { width: 1, height: 1 };
placeholderWidth: number = 1;
dragStart(itemIndex: number, event: CdkDragStart<DropListSimpleComponent>): void { dragStart(itemIndex: number, event: CdkDragStart<DropListSimpleComponent>): void {
this.setPlaceholderDimensions( this.setPlaceholderDimensions(
...@@ -198,8 +197,8 @@ export class DropListComponent extends FormElementComponent { ...@@ -198,8 +197,8 @@ export class DropListComponent extends FormElementComponent {
} }
setPlaceholderDimensions(itemsCount: number, orientation: unknown): void { setPlaceholderDimensions(itemsCount: number, orientation: unknown): void {
this.placeholderHeight = itemsCount && orientation !== 'horizontal' ? 1 : 100; this.placeholderDimensions.height = itemsCount && orientation === 'vertical' ? 1 : 100;
this.placeholderWidth = itemsCount && orientation !== 'vertical' ? 1 : 100; this.placeholderDimensions.width = itemsCount && orientation !== 'vertical' ? 1 : 100;
} }
onlyOneItemPredicate = (drag: CdkDrag, drop: CdkDropList): boolean => ( onlyOneItemPredicate = (drag: CdkDrag, drop: CdkDropList): boolean => (
......
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