Skip to content

Commit 9de7be9

Browse files
authored
Merge pull request #10149 from IgniteUI/dTsvetkov/add-drag-drop-shadow-dom-dev-sample
chore(dev-demos): Add drag and drop sample overlapping shadow dom
2 parents 58f8845 + ad4886d commit 9de7be9

File tree

6 files changed

+128
-1
lines changed

6 files changed

+128
-1
lines changed

src/app/app.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { ChipsSampleComponent } from './chips/chips.sample';
2828
import { DatePickerSampleComponent } from './date-picker/date-picker.sample';
2929
import { DialogSampleComponent } from './dialog/dialog.sample';
3030
import { DragDropSampleComponent } from './drag-drop/drag-drop.sample';
31+
import { ShadowGridSampleComponent } from './drag-drop/shadow-dom-grid/shadow-grid-sample';
3132
import { MaskSampleComponent, DisplayFormatPipe, InputFormatPipe } from './mask/mask.sample';
3233
import { IconSampleComponent } from './icon/icon.sample';
3334
import { InputSampleComponent } from './input/input.sample';
@@ -176,6 +177,7 @@ const components = [
176177
DisplayDensityDropDownComponent,
177178
DropDownVirtualComponent,
178179
DragDropSampleComponent,
180+
ShadowGridSampleComponent,
179181
ComboSampleComponent,
180182
IconSampleComponent,
181183
InputSampleComponent,

src/app/drag-drop/drag-drop.sample.html

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,50 @@ <h4>Drag a suspect inside or outside the cage:</h4>
173173
</div>
174174
</article>
175175
</section>
176+
177+
178+
<section class="sample-content">
179+
<article class="sample-column">
180+
<h4>Drag and drop elements overlapping grid in shadow dom:</h4>
181+
182+
<button #buttonElement igxButton="raised" (click)="openOverlappingDialog()">Show Dialog</button>
183+
184+
<div igxToggle #toggleForm1="toggle" class="igx-dialog" [style.width.px]="320" igxDrag [ghost]="false"
185+
[dragTolerance]="0" [dragChannel]="'dialog'">
186+
<div class="igx-dialog__window">
187+
<div class="igx-dialog__window-content">
188+
<div class="dialogHeader">
189+
<span [style.margin.px]="10">Draggable Dialog</span>
190+
<igx-icon igxDragHandle class="dialogHandle">control_camera</igx-icon>
191+
</div>
192+
<p>Drop Area 1</p>
193+
<div igxDrop (dropped)="onItemDropped($event)" style="border-style:solid;height:150px;">
194+
<igx-input-group igxDrag>
195+
<igx-prefix>
196+
<igx-icon>person</igx-icon>
197+
</igx-prefix>
198+
<input type="text" igxInput />
199+
<label igxLabel>Username</label>
200+
</igx-input-group>
201+
<igx-input-group igxDrag>
202+
<igx-prefix>
203+
<igx-icon>lock</igx-icon>
204+
</igx-prefix>
205+
<label igxLabel>Password</label>
206+
<input type="password" igxInput />
207+
</igx-input-group>
208+
</div>
209+
</div>
210+
<div class="igx-dialog__window-actions">
211+
<button igxButton="flat" type="button" igxRipple (click)="toggleForm1.close()"> Cancel </button>
212+
</div>
213+
<div class="igx-dialog__window-content">
214+
<p>Drop Area 2</p>
215+
<div igxDrop id="droppable" style="border-style:solid;height:150px;"
216+
(dropped)="onItemDropped($event)"></div>
217+
</div>
218+
</div>
219+
</div>
220+
<app-shadow-grid-sample></app-shadow-grid-sample>
221+
</article>
222+
</section>

src/app/drag-drop/drag-drop.sample.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
IgxInsertDropStrategy,
99
IDragBaseEventArgs,
1010
IgxDragLocation,
11-
DragDirection
11+
DragDirection,
12+
IDropDroppedEventArgs
1213
} from 'igniteui-angular';
1314

1415
@Component({
@@ -50,6 +51,12 @@ export class DragDropSampleComponent {
5051
@ViewChild('toggleForm', { read: IgxDragDirective, static: true })
5152
public toggleFormDrag: IgxDragDirective;
5253

54+
@ViewChild('toggleForm1', { static: true })
55+
public toggleForm1: IgxToggleDirective;
56+
57+
@ViewChild('toggleForm', { read: IgxDragDirective, static: true })
58+
public toggleFormDrag1: IgxDragDirective;
59+
5360
@ViewChildren('listItem', { read: IgxDragDirective })
5461
public listNotesDirs: QueryList<IgxDragDirective>;
5562

@@ -168,6 +175,22 @@ export class DragDropSampleComponent {
168175
this.toggleFormDrag.setLocation(new IgxDragLocation(this.toggleStartPageX, this.toggleStartPageY));
169176
}
170177

178+
public openOverlappingDialog() {
179+
const overlaySettings: OverlaySettings = {
180+
positionStrategy: new GlobalPositionStrategy(),
181+
scrollStrategy: new NoOpScrollStrategy(),
182+
modal: false,
183+
closeOnOutsideClick: false
184+
};
185+
this.toggleForm1.open(overlaySettings);
186+
187+
if (!this.toggleStartPageX && !this.toggleStartPageY) {
188+
this.toggleStartPageX = this.toggleFormDrag.pageX;
189+
this.toggleStartPageY = this.toggleFormDrag.pageY;
190+
}
191+
this.toggleFormDrag.setLocation(new IgxDragLocation(this.toggleStartPageX, this.toggleStartPageY));
192+
}
193+
171194
public toOriginNoGhost() {
172195
const startX = this.startX.nativeElement.value;
173196
const startY = this.startY.nativeElement.value;
@@ -375,4 +398,18 @@ export class DragDropSampleComponent {
375398
public dragClick() {
376399
console.log('click');
377400
}
401+
402+
public onDragMove(e) {
403+
const deltaX = e.nextPageX - e.pageX;
404+
const deltaY = e.nextPageY - e.pageY;
405+
e.cancel = true;
406+
this.toggleForm.setOffset(deltaX, deltaY);
407+
}
408+
409+
public onItemDropped(event: IDropDroppedEventArgs) {
410+
const dropDivArea: HTMLElement = event.owner.element.nativeElement;
411+
const draggedEl = event.drag.element.nativeElement;
412+
dropDivArea.appendChild(draggedEl);
413+
event.cancel = true;
414+
}
378415
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<igx-grid #grid1 [data]="localData" [autoGenerate]="true" (columnInit)="initColumns($event)" (selected)="selectCell($event)">
2+
</igx-grid>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import '../../../../projects/igniteui-angular/src/lib/core/styles/themes/index';
2+
@import '../../../styles/demo-theme';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
2+
import { IgxColumnComponent } from 'igniteui-angular';
3+
4+
@Component({
5+
selector: 'app-shadow-grid-sample',
6+
templateUrl: './shadow-grid-sample.html',
7+
styleUrls: ['./shadow-grid-sample.scss'],
8+
encapsulation: ViewEncapsulation.ShadowDom
9+
})
10+
export class ShadowGridSampleComponent implements OnInit {
11+
public localData: any[];
12+
public selectedCell;
13+
14+
public ngOnInit(): void {
15+
this.localData = [
16+
{ ID: 1, Name: 'A' },
17+
{ ID: 2, Name: 'B' },
18+
{ ID: 3, Name: 'C' },
19+
{ ID: 4, Name: 'D' },
20+
{ ID: 5, Name: 'E' }
21+
];
22+
}
23+
24+
public initColumns(event: IgxColumnComponent) {
25+
const column: IgxColumnComponent = event;
26+
column.movable = true;
27+
if (column.field === 'Name') {
28+
column.filterable = true;
29+
column.sortable = true;
30+
column.editable = true;
31+
}
32+
}
33+
34+
public selectCell(event) {
35+
this.selectedCell = event;
36+
}
37+
}

0 commit comments

Comments
 (0)