Skip to content

Commit 69cd5bb

Browse files
committed
fix(dialog): Expose positionSettings Input #5576
1 parent fd29519 commit 69cd5bb

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

projects/igniteui-angular/src/lib/dialog/dialog.component.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,41 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
216216
this._closeOnOutsideSelect = val;
217217
}
218218

219+
/**
220+
* Get the position and animation settings used by the dialog.
221+
* ```typescript
222+
* @ViewChild('alert', { static: true }) public alert: IgxDialogComponent;
223+
* let currentPosition: PositionSettings = this.alert.positionSettings
224+
* ```
225+
*/
226+
@Input()
227+
public get positionSettings(): PositionSettings {
228+
return this._positionSettings;
229+
}
230+
231+
/**
232+
* Set the position and animation settings used by the dialog.
233+
* ```typescript
234+
* import { slideInLeft, slideOutRight } from 'igniteui-angular';
235+
* ...
236+
* @ViewChild('alert', { static: true }) public alert: IgxDialogComponent;
237+
* public newPositionSettings: PositionSettings = {
238+
* openAnimation: useAnimation(slideInTop, { params: { duration: '2000ms' } }),
239+
* closeAnimation: useAnimation(slideOutBottom, { params: { duration: '2000ms'} }),
240+
* horizontalDirection: HorizontalAlignment.Left,
241+
* verticalDirection: VerticalAlignment.Middle,
242+
* horizontalStartPoint: HorizontalAlignment.Left,
243+
* verticalStartPoint: VerticalAlignment.Middle,
244+
* minSize: { height: 100, width: 100 }
245+
* };
246+
* this.alert.positionSettings = this.newPositionSettings;
247+
* ```
248+
*/
249+
public set positionSettings(settings: PositionSettings) {
250+
this._positionSettings = settings;
251+
this._overlayDefaultSettings.positionStrategy = new GlobalPositionStrategy(this._positionSettings);
252+
}
253+
219254
/**
220255
* An event that is emitted when the dialog is opened.
221256
*```html
@@ -258,7 +293,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
258293
@Output()
259294
public onRightButtonSelect = new EventEmitter<IDialogEventArgs>();
260295

261-
private _animaitonSettings: PositionSettings = {
296+
private _positionSettings: PositionSettings = {
262297
openAnimation: useAnimation(slideInBottom, { params: { fromPosition: 'translateY(100%)' } }),
263298
closeAnimation: useAnimation(slideOutTop, { params: { toPosition: 'translateY(-100%)' } })
264299
};
@@ -365,7 +400,7 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
365400
this._titleId = IgxDialogComponent.NEXT_ID++ + '_title';
366401

367402
this._overlayDefaultSettings = {
368-
positionStrategy: new GlobalPositionStrategy(this._animaitonSettings),
403+
positionStrategy: new GlobalPositionStrategy(this._positionSettings),
369404
scrollStrategy: new NoOpScrollStrategy(),
370405
modal: this.isModal,
371406
closeOnOutsideClick: this.closeOnOutsideSelect

src/app/dialog/dialog.sample.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ <h4 class="sample-title">Alert</h4>
66
<p class="sample-description">Detailed description to be added.</p>
77
<br>
88
<button igxButton="raised" igxRipple (click)="alert.open()">Trigger Alert</button>
9-
<igx-dialog #alert title="Notification" message="Your email has been sent successfully!" leftButtonLabel="OK" (onLeftButtonSelect)="alert.close()">
9+
<igx-dialog #alert title="Notification" message="Your email has been sent successfully!" leftButtonLabel="OK" (onLeftButtonSelect)="alert.close()"
10+
[positionSettings]="positionSettings" >
1011
</igx-dialog>
1112
</article>
1213

src/app/dialog/dialog.sample.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1-
import { Component } from '@angular/core';
1+
import { Component, ViewChild, OnInit } from '@angular/core';
2+
import { IgxDialogComponent, slideOutBottom, slideInTop,
3+
PositionSettings, HorizontalAlignment, VerticalAlignment } from 'igniteui-angular';
4+
import { useAnimation } from '@angular/animations';
25

36
@Component({
47
selector: 'app-dialog-sample',
58
styleUrls: ['dialog.sample.css'],
69
templateUrl: 'dialog.sample.html'
710
})
8-
export class DialogSampleComponent {
11+
export class DialogSampleComponent implements OnInit {
12+
13+
@ViewChild('alert', { static: true }) public alert: IgxDialogComponent;
14+
15+
public positionSettings: PositionSettings = {
16+
openAnimation: useAnimation(slideInTop, { params: { duration: '2000ms' } }),
17+
closeAnimation: useAnimation(slideOutBottom, { params: { duration: '2000ms'} }),
18+
horizontalDirection: HorizontalAlignment.Left,
19+
verticalDirection: VerticalAlignment.Middle,
20+
horizontalStartPoint: HorizontalAlignment.Left,
21+
verticalStartPoint: VerticalAlignment.Middle,
22+
minSize: { height: 100, width: 100 }
23+
};
24+
25+
public positionSettings2: PositionSettings = {
26+
openAnimation: useAnimation(slideInTop),
27+
closeAnimation: useAnimation(slideOutBottom)
28+
};
29+
30+
public ngOnInit() {
31+
// Set position settings on ngOnInit
32+
// this.alert.positionSettings = this.positionSettings2;
33+
34+
console.log(this.alert.positionSettings);
35+
}
936

1037
onDialogOKSelected(args) {
1138
// args.event - event

0 commit comments

Comments
 (0)