本文整理匯總了TypeScript中app/shared/scroll-spy.service.ScrollSpyService類的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.ScrollSpyService類的具體用法?TypeScript service.ScrollSpyService怎麽用?TypeScript service.ScrollSpyService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了service.ScrollSpyService類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should call `onResize()` if it is the first `ScrollSpiedElementGroup`', () => {
const actions: string[] = [];
const onResizeSpy = spyOn(ScrollSpyService.prototype as any, 'onResize')
.and.callFake(() => actions.push('onResize'));
const calibrateSpy = spyOn(ScrollSpiedElementGroup.prototype, 'calibrate')
.and.callFake(() => actions.push('calibrate'));
expect(onResizeSpy).not.toHaveBeenCalled();
scrollSpyService.spyOn([]);
expect(actions).toEqual(['onResize', 'calibrate']);
scrollSpyService.spyOn([]);
expect(actions).toEqual(['onResize', 'calibrate', 'calibrate']);
});
示例2: it
it('should first re-calibrate if the content height has changed', () => {
const body = injector.get(DOCUMENT).body as any;
scrollSpyService.spyOn([]);
scrollSpyService.spyOn([]);
scrollSpyService.spyOn([]);
const spiedElemGroups: ScrollSpiedElementGroup[] = (scrollSpyService as any).spiedElementGroups;
const onScrollSpies = spiedElemGroups.map(group => spyOn(group, 'onScroll'));
const calibrateSpies = spiedElemGroups.map((group, i) => spyOn(group, 'calibrate')
.and.callFake(() => expect(onScrollSpies[i]).not.toHaveBeenCalled()));
calibrateSpies.forEach(spy => expect(spy).not.toHaveBeenCalled());
onScrollSpies.forEach(spy => expect(spy).not.toHaveBeenCalled());
// No content height change...
(scrollSpyService as any).onScroll();
calibrateSpies.forEach(spy => expect(spy).not.toHaveBeenCalled());
onScrollSpies.forEach(spy => expect(spy).toHaveBeenCalled());
onScrollSpies.forEach(spy => spy.calls.reset());
body.scrollHeight = 100;
// Viewport changed...
(scrollSpyService as any).onScroll();
calibrateSpies.forEach(spy => expect(spy).toHaveBeenCalled());
onScrollSpies.forEach(spy => expect(spy).toHaveBeenCalled());
});
示例3: it
it('should only fire every 300ms', fakeAsync(() => {
scrollSpyService.spyOn([]);
window.dispatchEvent(new Event('scroll'));
tick(100);
expect(onScrollSpy).not.toHaveBeenCalled();
window.dispatchEvent(new Event('scroll'));
tick(100);
expect(onScrollSpy).not.toHaveBeenCalled();
window.dispatchEvent(new Event('scroll'));
tick(100);
expect(onScrollSpy).toHaveBeenCalledTimes(1);
onScrollSpy.calls.reset();
tick(150);
window.dispatchEvent(new Event('scroll'));
tick(100);
expect(onScrollSpy).not.toHaveBeenCalled();
window.dispatchEvent(new Event('scroll'));
tick(100);
expect(onScrollSpy).not.toHaveBeenCalled();
window.dispatchEvent(new Event('scroll'));
tick(100);
expect(onScrollSpy).toHaveBeenCalledTimes(1);
}));