Skip to content

Commit 7a9fd49

Browse files
committed
fix(overlay): fix enums & sample #7941
1 parent 0778d81 commit 7a9fd49

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

projects/igniteui-angular/src/lib/services/overlay/overlay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export class IgxOverlayService implements OnDestroy {
150150
*/
151151
public static createRelativeOverlaySettings(
152152
target: Point | HTMLElement,
153-
strategy?: RelativePositionStrategy,
154-
position?: RelativePosition):
153+
position?: RelativePosition,
154+
strategy?: RelativePositionStrategy):
155155
OverlaySettings {
156156
const positionSettings = this.createRelativePositionSettings(position);
157157
const overlaySettings: OverlaySettings = {

projects/igniteui-angular/src/lib/services/overlay/utilities.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,31 @@ export enum VerticalAlignment {
2121
/**
2222
* Defines the possible values of the overlays' position strategy.
2323
*/
24-
export const RelativePositionStrategy = mkenum({
25-
Connected: 'connected',
26-
Auto: 'auto',
27-
Elastic: 'elastic'
28-
});
29-
export type RelativePositionStrategy = (typeof RelativePositionStrategy)[keyof typeof RelativePositionStrategy];
24+
export enum RelativePositionStrategy {
25+
Connected = 'connected',
26+
Auto = 'auto',
27+
Elastic = 'elastic'
28+
}
3029

3130
/**
3231
* Defines the possible positions for the relative overlay settings presets.
3332
*/
34-
export const RelativePosition = mkenum({
35-
Above: 'above',
36-
Below: 'below',
37-
Before: 'before',
38-
After: 'after',
39-
Default: 'default'
40-
});
41-
export type RelativePosition = (typeof RelativePosition)[keyof typeof RelativePosition];
33+
export enum RelativePosition {
34+
Above = 'above',
35+
Below = 'below',
36+
Before = 'before',
37+
After = 'after',
38+
Default = 'default'
39+
}
4240

4341
/**
4442
* Defines the possible positions for the absolute overlay settings presets.
4543
*/
46-
export const AbsolutePosition = mkenum({
47-
Bottom: 'bottom',
48-
Top: 'top',
49-
Center: 'center'
50-
});
51-
export type AbsolutePosition = (typeof AbsolutePosition)[keyof typeof AbsolutePosition];
44+
export enum AbsolutePosition {
45+
Bottom = 'bottom',
46+
Top = 'top',
47+
Center = 'center'
48+
}
5249

5350
export class Point {
5451
constructor(public x: number, public y: number) { }

src/app/overlay/overlay-presets.sample.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ export class OverlayPresetsSampleComponent implements OnInit {
3333
private yAddition = 0;
3434
items = [];
3535
itemsCount = 10;
36-
relStrategies = ['Auto', 'Connected', 'Elastic'];
36+
relStrategies = [RelativePositionStrategy.Auto, RelativePositionStrategy.Connected, RelativePositionStrategy.Elastic];
3737
absStrategies = ['Global', 'Container'];
3838
positionStrategy = 'Global';
3939
absPosition: AbsolutePosition = AbsolutePosition.Center;
4040
absPositions = [AbsolutePosition.Center, AbsolutePosition.Top, AbsolutePosition.Bottom];
41-
relPosition: RelativePosition = RelativePosition.Below;
41+
relPosition: RelativePosition;
4242
relPositions = [
4343
RelativePosition.Above,
4444
RelativePosition.Below,
@@ -60,16 +60,18 @@ export class OverlayPresetsSampleComponent implements OnInit {
6060

6161
onChange(ev) {
6262
switch (this.positionStrategy) {
63-
case 'Auto':
64-
case 'Connected':
65-
case 'Elastic':
63+
case RelativePositionStrategy.Auto:
64+
case RelativePositionStrategy.Connected:
65+
case RelativePositionStrategy.Elastic:
6666
this.absPosition = null;
67+
this.relPosition = this.relPosition || RelativePosition.Default;
6768
this._overlaySettings = IgxOverlayService.createRelativeOverlaySettings(
6869
this.button.nativeElement,
69-
RelativePositionStrategy[this.positionStrategy],
70-
this.relPosition);
70+
this.relPosition,
71+
this.positionStrategy);
7172
break;
7273
case 'Global':
74+
this.relPosition = null;
7375
this._overlaySettings = IgxOverlayService.createAbsoluteOverlaySettings(this.absPosition);
7476
break;
7577
case 'Container':

0 commit comments

Comments
 (0)