当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript scroll-spy.service.ScrollSpyService类代码示例

本文整理汇总了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']);
    });
开发者ID:DanielKucal,项目名称:angular,代码行数:16,代码来源:scroll-spy.service.spec.ts

示例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());
    });
开发者ID:DallanQ,项目名称:rxjs,代码行数:28,代码来源:scroll-spy.service.spec.ts

示例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);
    }));
开发者ID:rjamet,项目名称:angular,代码行数:30,代码来源:scroll-spy.service.spec.ts


注:本文中的app/shared/scroll-spy.service.ScrollSpyService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。