Skip to content

Commit

Permalink
🐛 Remove constructor from scroll hooks to support Angular 8 (#477)
Browse files Browse the repository at this point in the history
* 🐛  Remove constructor from scroll hooks to support Angular 8

* 🎨
  • Loading branch information
Oskar Karlsson authored Aug 27, 2020
1 parent 78512a9 commit 12f0dc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
17 changes: 11 additions & 6 deletions src/scroll-hooks/__test__/hooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { ScrollHooks } from '../hooks';

describe('isVisible', () => {
const getWindow = () =>
({
innerHeight: 1000,
innerWidth: 1000,
} as any);
const hooks = new ScrollHooks(getWindow);
class Sut extends ScrollHooks {
constructor() {
super();
this.getWindow = () =>
({
innerHeight: 1000,
innerWidth: 1000,
} as any);
}
}
const hooks = new Sut();

const generateElement = (top: number, left: number, height = 300, width = 300): any => ({
getBoundingClientRect: () => ({
Expand Down
7 changes: 1 addition & 6 deletions src/scroll-hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ import { Attributes } from '../types';
import { Rect } from './rect';

export class ScrollHooks extends SharedHooks<Event | string> {
private readonly getWindow: () => Window;
protected getWindow = () => window;
private readonly scrollListeners = new WeakMap<any, Observable<any>>();

constructor(getWindow = () => window) {
super();
this.getWindow = getWindow;
}

getObservable(attributes: Attributes<Event | string>): Observable<Event | string> {
if (this.skipLazyLoading()) {
return of('load');
Expand Down

0 comments on commit 12f0dc2

Please sign in to comment.