本文整理匯總了TypeScript中@angular/cdk/overlay.OverlayContainer類的典型用法代碼示例。如果您正苦於以下問題:TypeScript OverlayContainer類的具體用法?TypeScript OverlayContainer怎麽用?TypeScript OverlayContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了OverlayContainer類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('NzPopover', () => {
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
let demoAppFixture: ComponentFixture<DemoAppComponent>;
let demoAppComponent: DemoAppComponent;
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports: [ NzPopoverModule, NoopAnimationsModule ],
declarations: [ DemoAppComponent ]
});
TestBed.compileComponents();
}));
beforeEach(inject([ OverlayContainer ], (oc: OverlayContainer) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
afterEach(() => {
overlayContainer.ngOnDestroy();
});
beforeEach(() => {
demoAppFixture = TestBed.createComponent(DemoAppComponent);
demoAppComponent = demoAppFixture.componentInstance;
demoAppFixture.detectChanges();
});
it('should show/hide normal tooltip', fakeAsync(() => {
const featureKey = 'NORMAL';
const triggerElement = demoAppComponent.normalTrigger.nativeElement;
expect(overlayContainerElement.textContent).not.toContain(featureKey);
// Move inside to trigger tooltip shown up
dispatchMouseEvent(triggerElement, 'mouseenter');
demoAppFixture.detectChanges();
tick(150); // wait for the default 100ms delay
demoAppFixture.detectChanges();
tick();
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain(featureKey);
// Move out from the trigger element to hide it
dispatchMouseEvent(triggerElement, 'mouseleave');
tick(100); // wait for the default 100ms delay
demoAppFixture.detectChanges();
tick(); // wait for next tick to hide
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));
it('should show tooltip with custom template', fakeAsync(() => {
const triggerElement = demoAppComponent.templateTrigger.nativeElement;
dispatchMouseEvent(triggerElement, 'mouseenter');
demoAppFixture.detectChanges();
tick(150); // wait for the default 100ms delay
demoAppFixture.detectChanges();
tick();
demoAppFixture.detectChanges();
expect(overlayContainerElement.querySelector('.anticon-file')).not.toBeNull();
}));
it('should show/hide tooltip by focus', fakeAsync(() => {
const featureKey = 'FOCUS';
const triggerElement = demoAppComponent.focusTrigger.nativeElement;
dispatchMouseEvent(triggerElement, 'focus');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain(featureKey);
dispatchMouseEvent(triggerElement, 'blur');
tick(100); // wait for the default 100ms delay
demoAppFixture.detectChanges();
tick(); // wait for next tick to hide
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));
it('should show/hide tooltip by click', fakeAsync(() => {
const featureKey = 'CLICK';
const triggerElement = demoAppComponent.clickTrigger.nativeElement;
dispatchMouseEvent(triggerElement, 'click');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain(featureKey);
dispatchMouseEvent(overlayContainerElement.querySelector('.cdk-overlay-backdrop'), 'click');
tick();
demoAppFixture.detectChanges();
tick(500); // Wait for animations
demoAppFixture.detectChanges();
tick();
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));
it('should show/hide by nzVisible change', fakeAsync(() => {
const featureKey = 'VISIBLE';
demoAppComponent.visible = true;
//.........這裏部分代碼省略.........
示例2: beforeEach
beforeEach(inject([ OverlayContainer ], (oc: OverlayContainer) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
示例3: beforeEach
beforeEach(inject([ NzNotificationService, OverlayContainer ], (m: NzNotificationService, oc: OverlayContainer) => {
messageService = m;
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
示例4: describe
describe('NzNotification', () => {
let messageService: NzNotificationService;
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
let demoAppFixture: ComponentFixture<DemoAppComponent>;
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports : [ NzNotificationModule, NoopAnimationsModule ],
declarations: [ DemoAppComponent ],
providers : [ { provide: NZ_NOTIFICATION_CONFIG, useValue: { nzMaxStack: 2 } } ] // Override default config
});
TestBed.compileComponents();
}));
beforeEach(inject([ NzNotificationService, OverlayContainer ], (m: NzNotificationService, oc: OverlayContainer) => {
messageService = m;
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
afterEach(() => {
overlayContainer.ngOnDestroy();
});
beforeEach(() => {
demoAppFixture = TestBed.createComponent(DemoAppComponent);
});
it('should open a message box with success', (() => {
messageService.success('test-title', 'SUCCESS');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('SUCCESS');
expect(overlayContainerElement.querySelector('.ant-notification-notice-icon-success')).not.toBeNull();
}));
it('should open a message box with error', (() => {
messageService.error('test-title', 'ERROR');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('ERROR');
expect(overlayContainerElement.querySelector('.ant-notification-notice-icon-error')).not.toBeNull();
}));
it('should open a message box with warning', (() => {
messageService.warning('test-title', 'WARNING');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('WARNING');
expect(overlayContainerElement.querySelector('.ant-notification-notice-icon-warning')).not.toBeNull();
}));
it('should open a message box with info', (() => {
messageService.info('test-title', 'INFO');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('INFO');
expect(overlayContainerElement.querySelector('.ant-notification-notice-icon-info')).not.toBeNull();
}));
it('should open a message box with blank', (() => {
messageService.blank('test-title', 'BLANK');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('BLANK');
expect(overlayContainerElement.querySelector('.ant-notification-notice-icon')).toBeNull();
}));
it('should auto closed by 1s', fakeAsync(() => {
messageService.create(null, null, 'EXISTS', { nzDuration: 1000 });
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('EXISTS');
tick(1200 + 10); // Wait for animation with 200ms
expect(overlayContainerElement.textContent).not.toContain('EXISTS');
}));
it('should not destroy when hovered', fakeAsync(() => {
messageService.create(null, null, 'EXISTS', { nzDuration: 3000 });
demoAppFixture.detectChanges();
const messageElement = overlayContainerElement.querySelector('.ant-notification-notice');
dispatchMouseEvent(messageElement, 'mouseenter');
tick(50000);
expect(overlayContainerElement.textContent).toContain('EXISTS');
dispatchMouseEvent(messageElement, 'mouseleave');
tick(5000);
expect(overlayContainerElement.textContent).not.toContain('EXISTS');
}));
it('should not destroyed automatically but manually', fakeAsync(() => {
const filledMessage = messageService.success('title', 'SUCCESS', { nzDuration: 0 });
demoAppFixture.detectChanges();
tick(50000);
expect(overlayContainerElement.textContent).toContain('SUCCESS');
//.........這裏部分代碼省略.........
示例5: describe
describe('NzPopover', () => {
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
let fixture;
let component;
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports : [ NzPopoverModule, NoopAnimationsModule, NzToolTipModule, NzIconModule ],
declarations: [ NzPopoverTestWrapperComponent, NzPopoverTestNewComponent ],
providers : [ { provide: NZ_ICONS, useValue: [ FileOutline ] } ]
});
TestBed.compileComponents();
}));
beforeEach(inject([ OverlayContainer ], (oc: OverlayContainer) => {
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
afterEach(() => {
overlayContainer.ngOnDestroy();
});
describe('should not bring break changes', () => {
beforeEach(() => {
fixture = TestBed.createComponent(NzPopoverTestWrapperComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should show/hide normal tooltip', fakeAsync(() => {
const featureKey = 'NORMAL';
const triggerElement = component.normalTrigger.nativeElement;
expect(overlayContainerElement.textContent).not.toContain(featureKey);
// Move inside to trigger tooltip shown up
dispatchMouseEvent(triggerElement, 'mouseenter');
fixture.detectChanges();
tick(150); // wait for the default 100ms delay
fixture.detectChanges();
tick();
fixture.detectChanges();
expect(overlayContainerElement.textContent).toContain(featureKey);
// Move out from the trigger element to hide it
dispatchMouseEvent(triggerElement, 'mouseleave');
tick(100); // wait for the default 100ms delay
fixture.detectChanges();
tick(); // wait for next tick to hide
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));
it('should show tooltip with custom template', fakeAsync(() => {
const triggerElement = component.templateTrigger.nativeElement;
dispatchMouseEvent(triggerElement, 'mouseenter');
fixture.detectChanges();
tick(150); // wait for the default 100ms delay
fixture.detectChanges();
tick();
fixture.detectChanges();
expect(overlayContainerElement.querySelector('.anticon-file')).not.toBeNull();
}));
it('should show/hide tooltip by focus', fakeAsync(() => {
const featureKey = 'FOCUS';
const triggerElement = component.focusTrigger.nativeElement;
dispatchMouseEvent(triggerElement, 'focus');
fixture.detectChanges();
expect(overlayContainerElement.textContent).toContain(featureKey);
dispatchMouseEvent(triggerElement, 'blur');
tick(100); // wait for the default 100ms delay
fixture.detectChanges();
tick(); // wait for next tick to hide
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));
it('should show/hide tooltip by click', fakeAsync(() => {
const featureKey = 'CLICK';
const triggerElement = component.clickTrigger.nativeElement;
dispatchMouseEvent(triggerElement, 'click');
fixture.detectChanges();
expect(overlayContainerElement.textContent).toContain(featureKey);
dispatchMouseEvent(overlayContainerElement.querySelector('.cdk-overlay-backdrop'), 'click');
tick();
fixture.detectChanges();
tick(500); // Wait for animations
fixture.detectChanges();
tick();
expect(overlayContainerElement.textContent).not.toContain(featureKey);
}));
it('should show/hide by nzVisible change', fakeAsync(() => {
//.........這裏部分代碼省略.........
示例6: describe
describe('NzMessage', () => {
let messageService: NzMessageService;
let overlayContainer: OverlayContainer;
let overlayContainerElement: HTMLElement;
let demoAppFixture: ComponentFixture<DemoAppComponent>;
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports: [ NzMessageModule, NoopAnimationsModule ],
declarations: [ DemoAppComponent ],
providers: [ { provide: NZ_MESSAGE_CONFIG, useValue: { nzMaxStack: 2 } } ] // Override default config
});
TestBed.compileComponents();
}));
beforeEach(inject([ NzMessageService, OverlayContainer ], (m: NzMessageService, oc: OverlayContainer) => {
messageService = m;
overlayContainer = oc;
overlayContainerElement = oc.getContainerElement();
}));
afterEach(() => {
overlayContainer.ngOnDestroy();
});
beforeEach(() => {
demoAppFixture = TestBed.createComponent(DemoAppComponent);
});
it('should open a message box with success', (() => {
messageService.success('SUCCESS');
demoAppFixture.detectChanges();
expect((overlayContainerElement.querySelector('.cdk-overlay-pane') as HTMLElement).style.zIndex).toBe('1010');
expect(overlayContainerElement.textContent).toContain('SUCCESS');
expect(overlayContainerElement.querySelector('.anticon-check-circle')).not.toBeNull();
}));
it('should open a message box with error', (() => {
messageService.error('ERROR');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('ERROR');
expect(overlayContainerElement.querySelector('.anticon-cross-circle')).not.toBeNull();
}));
it('should open a message box with warning', (() => {
messageService.warning('WARNING');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('WARNING');
expect(overlayContainerElement.querySelector('.anticon-exclamation-circle')).not.toBeNull();
}));
it('should open a message box with info', (() => {
messageService.info('INFO');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('INFO');
expect(overlayContainerElement.querySelector('.anticon-info-circle')).not.toBeNull();
}));
it('should open a message box with loading', (() => {
messageService.loading('LOADING');
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('LOADING');
expect(overlayContainerElement.querySelector('.anticon-loading')).not.toBeNull();
}));
it('should auto closed by 1s', fakeAsync(() => {
messageService.create(null, 'EXISTS', { nzDuration: 1000 });
demoAppFixture.detectChanges();
expect(overlayContainerElement.textContent).toContain('EXISTS');
tick(1200 + 10); // Wait for animation with 200ms
expect(overlayContainerElement.textContent).not.toContain('EXISTS');
}));
it('should not destroy when hovered', fakeAsync(() => {
messageService.create(null, 'EXISTS', { nzDuration: 3000 });
demoAppFixture.detectChanges();
const messageElement = overlayContainerElement.querySelector('.ant-message-notice');
dispatchMouseEvent(messageElement, 'mouseenter');
tick(1000);
expect(overlayContainerElement.textContent).toContain('EXISTS');
dispatchMouseEvent(messageElement, 'mouseleave');
tick(5000);
expect(overlayContainerElement.textContent).not.toContain('EXISTS');
}));
it('should not destroyed automatically but manually', fakeAsync(() => {
const filledMessage = messageService.success('SUCCESS', { nzDuration: 0 });
demoAppFixture.detectChanges();
tick(50000);
//.........這裏部分代碼省略.........
示例7: ngOnInit
ngOnInit(): void {
let theme = 'light-custom-theme';
if (this.storageService.hasTheme()) {
theme = this.storageService.getTheme();
} else {
this.storageService.setTheme(theme);
}
document.body.classList.add(theme, 'mat-app-background');
this.overlay.getContainerElement().classList.add(theme);
}
示例8: afterEach
afterEach(() => {
overlayContainer.ngOnDestroy();
});
示例9:
configurationService.getApplicationConfiguration().subscribe((conf) => {
overlayContainer.getContainerElement().classList.add(conf.application.theme + '-theme')
})