Browse Source

Several drag drop fixes.

pull/604/head
Sebastian 5 years ago
parent
commit
76edc52c1c
  1. 6
      frontend/app/shared/components/schema-category.component.html
  2. 28
      frontend/app/shared/components/schema-category.component.scss
  3. 23
      frontend/app/shared/components/schema-category.component.ts

6
frontend/app/shared/components/schema-category.component.html

@ -34,13 +34,15 @@
</div>
</div>
<div class="nav nav-panel nav-dark nav-dark-bordered flex-column" *ngIf="!isCollapsed" @fade>
<div class="nav nav-panel nav-dark nav-dark-bordered flex-column" *ngIf="!isCollapsed" @fade [style.height]="getContainerHeight()">
<ng-container *ngIf="!forContent; else simpleMode">
<div *ngFor="let schema of filteredSchemas; trackBy: trackBySchema" class="nav-item"
[style.height]="getItemHeight()"
routerLinkActive="active"
cdkDrag
cdkDragLockAxis="y"
[cdkDragData]="schema">
[cdkDragData]="schema"
(cdkDragStarted)="dragStarted($event)">
<i cdkDragHandle class="icon-drag2 drag-handle"></i>

28
frontend/app/shared/components/schema-category.component.scss

@ -42,6 +42,22 @@ $drag-margin: -8px;
}
}
.cdk-drag-preview {
background: $color-dark2-background !important;
a {
color: $color-dark1-foreground !important;
}
}
.cdk-drag-placeholder {
display: none;
}
.cdk-drag-animating {
transition: none;
}
.header {
line-height: 2rem;
margin-bottom: 0;
@ -86,18 +102,6 @@ $drag-margin: -8px;
}
}
.cdk-drag-preview {
background: $color-dark2-background !important;
a {
color: $color-dark1-foreground !important;
}
}
.cdk-drag-animating {
transition: none;
}
.schema {
&-name {
@include truncate;

23
frontend/app/shared/components/schema-category.component.ts

@ -5,12 +5,14 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { CdkDragDrop } from '@angular/cdk/drag-drop';
import { CdkDragDrop, CdkDragStart } from '@angular/cdk/drag-drop';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
import { fadeAnimation, LocalStoreService, SchemaCategory, SchemaDto, SchemasList, SchemasState } from '@app/shared/internal';
import { AppsState } from '../state/apps.state';
import { Settings } from '../state/settings';
const ITEM_HEIGHT = 3.125;
@Component({
selector: 'sqx-schema-category',
styleUrls: ['./schema-category.component.scss'],
@ -83,6 +85,25 @@ export class SchemaCategoryComponent implements OnChanges {
}
}
public dragStarted(event: CdkDragStart) {
setTimeout(() => {
const dropContainer = event.source._dragRef['_dropContainer'];
if (dropContainer) {
dropContainer['_cacheOwnPosition']();
dropContainer['_cacheItemPositions']();
}
});
}
public getItemHeight() {
return `${ITEM_HEIGHT}rem`;
}
public getContainerHeight() {
return `${ITEM_HEIGHT * this.filteredSchemas.length}rem`;
}
public trackBySchema(_index: number, schema: SchemaDto) {
return schema.id;
}

Loading…
Cancel
Save