Skip to content

Commit 269d9c0

Browse files
authored
Merge pull request #5726 from IgniteUI/SKrastev/drag-drop-migration
Add migrations for renamed interfaces. Move breaking changes for drag/drop in correct version.
2 parents 37a6017 + 370e08c commit 269d9c0

File tree

5 files changed

+93
-17
lines changed

5 files changed

+93
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For more information about the theming please read our [documentation](https://w
3737
- `IgxDrag`
3838
- Dragging without ghost. Now it is possible to drag the base element `igxDrag` is instanced on by setting the new input `ghost` to false.
3939
- Ghost template. A custom ghost template reference can be provided on the new `ghostTemplate` input.
40-
- Dragging using a single or multiple handles. New `igxDragHandle` directive is exposed to specify a handle by which and element can be interacted with instead of the whole element `igxDrag` is instanced on.
40+
- Dragging using a single or multiple handles. New `igxDragHandle` directive is exposed to specify a handle by which an element can be interacted with instead of the whole element `igxDrag` is instanced on.
4141
- Linking of drag and drop elements. This can be achieved by using the new provided `dragChannel` input, specifying each element to which channel it corresponds.
4242
- Drag animation improvements. Three new methods have been exposed in place of the old `animateToOrigin` input in order to provide more flexibility when wanting to have transition animation to specific position when dropping. `setLocation`, `transitionToOrigin` and `transitionTo` are all methods that provide a various way to animate a transition to a specific location for the dragged element.
4343
- New getters - `location` and `originLocation` to aid in applying transition animations.
@@ -78,10 +78,6 @@ For more information about the theming please read our [documentation](https://w
7878
```
7979
- **Breaking Change** When using `[valueKey]`, combo methods, events and outputs **cannot** be handled with *data item references*.
8080
- For more information, visit the component's [readme](https://github.com/IgniteUI/igniteui-angular/tree/master/projects/igniteui-angular/src/lib/combo/README.md)
81-
82-
## 8.1.4
83-
- `IgxDialog` new @Input `positionSettings` is now available. It provides the ability to get/set both position and animation settings of the Dialog component.
84-
8581
- `IgxDrag`
8682
- Deprecated inputs - `hideBaseOnDrag`, `animateOnRelease`, `visible`.
8783
- Deprecated methods - `dropFinished`.
@@ -97,10 +93,13 @@ For more information about the theming please read our [documentation](https://w
9793
- **Breaking Change** `onOver` output is renamed to `over`.
9894
- **Breaking Change** `onLeave` output is renamed to `leave`.
9995
- **Breaking Change** `onDrop` output is renamed to `dropped`.
100-
- **Breaking Change** Interfaces `IgxDropEnterEventArgs`, `IgxDropLeaveEventArgs` are both now called `IDragBaseEventArgs`.
96+
- **Breaking Change** Interfaces `IgxDropEnterEventArgs`, `IgxDropLeaveEventArgs` are both now called `IDropBaseEventArgs`.
10197
- **Breaking Change** Interfaces `IgxDropEventArgs` is renamed to `IDropDroppedEventArgs`.
10298
- **Breaking Change** Outputs `enter`, `over`, `leave`(former `onEnter`, `onOver`, `onLeave`) now have arguments of type `IDropBaseEventArgs`
10399
- **Breaking Change** Output `dropped` (former `onDrop`) now have arguments of type `IDropDroppedEventArgs`
100+
101+
## 8.1.4
102+
- `IgxDialog` new @Input `positionSettings` is now available. It provides the ability to get/set both position and animation settings of the Dialog component.
104103

105104
## 8.1.3
106105
- `IgxCombo`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "../../common/schema/class.schema.json",
3+
"changes": [
4+
{
5+
"name": "IgxDropEnterEventArgs",
6+
"replaceWith": "IDropBaseEventArgs"
7+
},
8+
{
9+
"name": "IgxDropLeaveEventArgs",
10+
"replaceWith": "IDropBaseEventArgs"
11+
},
12+
{
13+
"name": "IgxDropEventArgs",
14+
"replaceWith": "IDropDroppedEventArgs"
15+
}
16+
]
17+
}

projects/igniteui-angular/migrations/update-8_2_0/index.spec.ts

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,52 @@ describe('Update 8.2.0', () => {
6666
it('should update igxDrag and igxDrop outputs bindings', done => {
6767
appTree.create(
6868
'/testSrc/appPrefix/component/custom.component.html',
69-
`<div igxDrag (onGhostCreate)="ghostCreateHandler($event)" (onGhostDestroy)="ghostDestroyHandler($event)" (returnMoveEnd)="moveEndHandler($event)" (dragClicked)="clickHandler($event)">Drag me</div>
69+
`<div igxDrag (onGhostCreate)="ghostCreateHandler($event)"
70+
(onGhostDestroy)="ghostDestroyHandler($event)"
71+
(returnMoveEnd)="moveEndHandler($event)"
72+
(dragClicked)="clickHandler($event)">
73+
Drag me
74+
</div>
7075
<div igxDrop (onEnter)="enterHandler($event)" (onLeave)="leaveHandler($event)" (onDrop)="dropHandler($event)">drop area</div>
7176
`);
72-
const tree = schematicRunner.runSchematic('migration-10', {}, appTree);
7377

78+
const tree = schematicRunner.runSchematic('migration-10', {}, appTree);
7479
expect(tree.readContent('/testSrc/appPrefix/component/custom.component.html'))
7580
.toEqual(
76-
`<div igxDrag (ghostCreate)="ghostCreateHandler($event)" (ghostDestroy)="ghostDestroyHandler($event)" (transitioned)="moveEndHandler($event)" (click)="clickHandler($event)">Drag me</div>
81+
`<div igxDrag (ghostCreate)="ghostCreateHandler($event)"
82+
(ghostDestroy)="ghostDestroyHandler($event)"
83+
(transitioned)="moveEndHandler($event)"
84+
(click)="clickHandler($event)">
85+
Drag me
86+
</div>
7787
<div igxDrop (enter)="enterHandler($event)" (leave)="leaveHandler($event)" (dropped)="dropHandler($event)">drop area</div>
7888
`);
7989
done();
8090
});
91+
92+
it('should update igxDrag and igxDrop event argument interfaces', done => {
93+
appTree.create(
94+
'/testSrc/appPrefix/component/test.component.ts',
95+
`import { IgxDragDirective, IgxDropDirective, IgxDropEnterEventArgs,
96+
IgxDropLeaveEventArgs, IgxDropEventArgs } from 'igniteui-angular';
97+
98+
export class DragDropSampleComponent {
99+
public onEnterHandler(event: IgxDropEnterEventArgs) {}
100+
public onLeaveHandler(event: IgxDropLeaveEventArgs) {}
101+
public onDropHandler(event: IgxDropEventArgs) {}
102+
}`);
103+
104+
const tree = schematicRunner.runSchematic('migration-10', {}, appTree);
105+
expect(tree.readContent('/testSrc/appPrefix/component/test.component.ts'))
106+
.toEqual(
107+
`import { IgxDragDirective, IgxDropDirective, IDropBaseEventArgs,
108+
IDropBaseEventArgs, IDropDroppedEventArgs } from 'igniteui-angular';
109+
110+
export class DragDropSampleComponent {
111+
public onEnterHandler(event: IDropBaseEventArgs) {}
112+
public onLeaveHandler(event: IDropBaseEventArgs) {}
113+
public onDropHandler(event: IDropDroppedEventArgs) {}
114+
}`);
115+
done();
116+
});
81117
});

projects/igniteui-angular/src/lib/directives/drag-drop/README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The `ghost` input is set to `true` by default which means that the base element
6161

6262
#### Dragging without ghost
6363

64-
If `renderGhost` input is set to false the dragging logic for the `igxDrag` provides dragging ability for the initialized element itself. This means that it can freely move an element around by click and hold and when released it will keep its position where it was dragged.
64+
If `ghost` input is set to false the dragging logic for the `igxDrag` provides dragging ability for the initialized element itself. This means that it can freely move an element around by click and hold and when released it will keep its position where it was dragged.
6565

6666
#### Dragging using a handle
6767

@@ -119,11 +119,10 @@ If the user want to have other types of animations that involve element transfor
119119

120120
| Name | Type | Default Value | Description |
121121
| :--- | :--- | :--- | :--- |
122-
| igxDrag | any | - | Input used to save data inside the `igxDrag` directive. This can be set when instancing `igxDrag` on an element. |
123-
| dragTolerance | number | 5 | Indicates when the drag should start (in pixels). By default the drag starts after the draggable element is moved by 5px |
124-
| dragGhostHost | any | null | Sets the element to which the dragged element will be appended.
125-
| ghostImageClass | string | '' | Sets a custom class that will be added to the `dragGhost` element. |
126-
| animateOnRelease | boolean | false | Enables/disables the draggable element animation when the element is released. |
122+
| `igxDrag` | any | - | Input used to save data inside the `igxDrag` directive. This can be set when instancing `igxDrag` on an element. |
123+
| `dragTolerance` | number | 5 | Indicates when the drag should start (in pixels). By default the drag starts after the draggable element is moved by 5px |
124+
| `ghostHost` | any | null | Sets the element to which the dragged element will be appended.
125+
| `ghostClass` | string | '' | Sets a custom class that will be added to the `igxDrag` element. |
127126

128127
### Outputs
129128

@@ -185,7 +184,7 @@ public onAreaLeave() {
185184

186185
For achieving a drop functionality with the `igxDrag` directive the `igxDrop` directive should be used. It can be applied on any kind of element and it specifies an area where the `igxDrag` can be dropped.
187186

188-
By default the `igxDrop` does not apply any logic to the dragged element when it is dropped onto it. The user could choose between a few different drop strategies if he would like the `igxDrop` to perform some action or he could implement his own drop logic using the provided `onDragDrop` events.
187+
By default the `igxDrop` does not apply any logic to the dragged element when it is dropped onto it. The user could choose between a few different drop strategies if he would like the `igxDrop` to perform some action or he could implement his own drop logic using the provided `dropped` event.
189188

190189
#### Drop Strategies
191190

@@ -215,7 +214,7 @@ HTML:
215214

216215
#### Canceling a Drop Strategy
217216

218-
When using a specific drop strategy, its behavior can be canceled in the `onDrop` or `onDragDrop` events by setting the cancel property to true. The `onDrop` event is specific to the `igxDrag` and the `onDragDrop` event to the `igxDrop`. If the user does not have drop strategy applied to the `igxDrop` canceling the event would have no side effects.
217+
When using a specific drop strategy, its behavior can be canceled in the [`dropped`]({environment:angularApiUrl}/classes/igxdropdirective.html#dropped) events by setting the `cancel` property to true. The `dropped` event is specific to the `igxDrop`. If you does not have drop strategy applied to the `igxDrop` canceling the event would have no side effects.
219218

220219
*Example:*
221220

projects/igniteui-angular/src/lib/directives/drag-drop/drag-drop.directive.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,31 @@ export class IgxDropDirective implements OnInit, OnDestroy {
14591459
@Input()
14601460
public dropChannel: number | string | number[] | string[];
14611461

1462+
/**
1463+
* An @Input property that specifies a drop strategy type that will be executed when an `IgxDrag` element is released inside
1464+
* the current drop area. The provided strategies are:
1465+
* - IgxDefaultDropStrategy - This is the default base strategy and it doesn't perform any actions.
1466+
* - IgxAppendDropStrategy - Appends the dropped element to last position as a direct child to the `igxDrop`.
1467+
* - IgxPrependDropStrategy - Prepends the dropped element to first position as a direct child to the `igxDrop`.
1468+
* - IgxInsertDropStrategy - If the dropped element is released above a child element of the `igxDrop`, it will be inserted
1469+
* at that position. Otherwise the dropped element will be appended if released outside any child of the `igxDrop`.
1470+
* ```html
1471+
* <div igxDrag>
1472+
* <span>DragMe</span>
1473+
* </div>
1474+
* <div igxDrop [dropStrategy]="myDropStrategy">
1475+
* <span>Numbers drop area!</span>
1476+
* </div>
1477+
* ```
1478+
* ```typescript
1479+
* import { IgxAppendDropStrategy } from 'igniteui-angular';
1480+
*
1481+
* export class App {
1482+
* public myDropStrategy = IgxAppendDropStrategy;
1483+
* }
1484+
* ```
1485+
* @memberof IgxDropDirective
1486+
*/
14621487
@Input()
14631488
public set dropStrategy(classRef: any) {
14641489
this._dropStrategy = new classRef(this._renderer);

0 commit comments

Comments
 (0)