Skip to content

Commit

Permalink
ONEUP-7762: Fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aramin committed Jan 2, 2024
1 parent f4b0e6a commit f15fbe2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/StickyObserver.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import sinon from 'sinon';
import * as Helper from './helper';
import { Sticky, StickyObserver } from './StickyObserver';
import {
scrollTo,
Expand All @@ -10,7 +11,6 @@ import {
triggerResizeEvent
} from './test-helper';
import { StickyHTMLElement, StickyState } from './types';
import * as Helper from './helper';

// Info:
// The sticky element should be always normal even on scrolling
Expand Down
6 changes: 3 additions & 3 deletions src/StickyObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
addPlaceholder,
addStickyClass,
noop,
PageSize,
position,
recalculateOnNormalState,
removeClass,
Expand All @@ -11,8 +12,7 @@ import {
removeScrollEvent,
removeStickyClass,
toNumber,
toStyleClasses,
PageSize
toStyleClasses
} from './helper';
import * as Helper from './helper';
import * as states from './states';
Expand Down Expand Up @@ -235,7 +235,7 @@ export class StickyObserver implements Sticky {
}

private onResize(element: StickyHTMLElement): void {
const windowDimensions = Helper.getPageSize();
const windowDimensions: PageSize = Helper.getPageSize();

if (this.pageSize.equals(windowDimensions)) {
return;
Expand Down
16 changes: 11 additions & 5 deletions src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { RectPosition, StickyHTMLElement, StickyState } from './types';

export type WidthHeight = { width: number; height: number };
export interface WidthHeight {
width: number;
height: number;
}
export type PageSize = WidthHeight & { equals: (other: WidthHeight) => boolean };

export const position: (element: HTMLElement) => RectPosition = (element: HTMLElement): RectPosition => {
Expand Down Expand Up @@ -137,9 +140,12 @@ export const toStyleClasses: (value: string | undefined) => string[] = (value: s
export function getPageSize(): PageSize {
const width: number = document.documentElement.scrollWidth;
const height: number = document.documentElement.scrollHeight;
const equals = (other: WidthHeight) => {
return width === other.width && height === other.height;
};

return { width, height, equals };
return {
width,
height,
equals: (other: WidthHeight): boolean => {
return width === other.width && height === other.height;
}
};
}

0 comments on commit f15fbe2

Please sign in to comment.