Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 10ae219

Browse files
feat(popover): force positioning
1 parent f72e3eb commit 10ae219

File tree

9 files changed

+167
-86
lines changed

9 files changed

+167
-86
lines changed

Diff for: projects/core/src/lib/popover/popover-element.directive.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { FivPopover } from './popover.component';
22
import { Directive, ElementRef, Input, AfterViewInit } from '@angular/core';
3-
import { tap } from 'rxjs/operators';
3+
import { tap, delay } from 'rxjs/operators';
44

55
@Directive({
66
selector: '[fivPopover]',
77
exportAs: 'fivPopover'
88
})
99
export class PopoverElementDirective implements AfterViewInit {
1010
_show: boolean;
11+
@Input('fivPopover.delay') delay = 50;
1112
@Input() fivPopover: FivPopover;
1213

1314
@Input('fivPopover.show') set show(visible: boolean) {
@@ -29,13 +30,14 @@ export class PopoverElementDirective implements AfterViewInit {
2930
open() {
3031
this.show = true;
3132
}
32-
close() {
33+
hide() {
3334
this.show = false;
3435
}
3536

3637
ngAfterViewInit(): void {
3738
this.fivPopover.overlay.afterInit
3839
.pipe(
40+
delay(this.delay),
3941
tap(() => {
4042
this.show = this._show;
4143
})

Diff for: projects/core/src/lib/popover/popover.animations.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ export const animIn = (
2626
beforeStyle(
2727
element,
2828
'transform-origin',
29-
`${position.vertical === 'top' ? 'bottom' : 'top'} ${
30-
position.horizontal === 'left' ? 'right' : 'left'
31-
}`
29+
`${position.vertical} ${position.horizontal}`
3230
)
3331
)
3432
);

Diff for: projects/core/src/lib/popover/popover.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<fiv-overlay>
22
<div *ngIf="backdrop && !hidden" [ngClass]="classes" class="fiv-popover-backdrop" (click)="close()">
33
</div>
4-
<div *ngIf="!hidden" [ngClass]="classes" class="popover-container" [style]="containerStyles">
4+
<div *ngIf="!hidden" [ngClass]="classes" class="popover-container" [style]="styles">
55
<div #animation *ngIf="overlay?.open" class="animation-container" anim [anim.in]="animationIn">
66
<ng-content>
77
</ng-content>

Diff for: projects/core/src/lib/popover/popover.component.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { IonicModule } from '@ionic/angular';
33

4-
import { PopoverComponent } from './popover.component';
4+
import { FivPopover } from './popover.component';
55

6-
describe('PopoverComponent', () => {
7-
let component: PopoverComponent;
8-
let fixture: ComponentFixture<PopoverComponent>;
6+
describe('FivPopover', () => {
7+
let component: FivPopover;
8+
let fixture: ComponentFixture<FivPopover>;
99

1010
beforeEach(async(() => {
1111
TestBed.configureTestingModule({
12-
declarations: [ PopoverComponent ],
12+
declarations: [FivPopover],
1313
imports: [IonicModule.forRoot()]
1414
}).compileComponents();
1515

16-
fixture = TestBed.createComponent(PopoverComponent);
16+
fixture = TestBed.createComponent(FivPopover);
1717
component = fixture.componentInstance;
1818
fixture.detectChanges();
1919
}));

0 commit comments

Comments
 (0)