From 5cde5f4d82638a1ae9bc83127ff0a5d7b9ea2254 Mon Sep 17 00:00:00 2001 From: aramin Date: Tue, 2 Jan 2024 15:25:09 +0100 Subject: [PATCH] ONEUP-7762: Fix linting issues --- src/StickyObserver.test.ts | 2 +- src/StickyObserver.ts | 6 +++--- src/helper.ts | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/StickyObserver.test.ts b/src/StickyObserver.test.ts index 1dbddbc..491057b 100644 --- a/src/StickyObserver.test.ts +++ b/src/StickyObserver.test.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; import sinon from 'sinon'; +import * as Helper from './helper'; import { Sticky, StickyObserver } from './StickyObserver'; import { scrollTo, @@ -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 diff --git a/src/StickyObserver.ts b/src/StickyObserver.ts index fedd686..386f979 100644 --- a/src/StickyObserver.ts +++ b/src/StickyObserver.ts @@ -3,6 +3,7 @@ import { addPlaceholder, addStickyClass, noop, + PageSize, position, recalculateOnNormalState, removeClass, @@ -11,8 +12,7 @@ import { removeScrollEvent, removeStickyClass, toNumber, - toStyleClasses, - PageSize + toStyleClasses } from './helper'; import * as Helper from './helper'; import * as states from './states'; @@ -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; diff --git a/src/helper.ts b/src/helper.ts index 9961b48..ec4d5b4 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -1,9 +1,10 @@ import { RectPosition, StickyHTMLElement, StickyState } from './types'; -export type WidthHeight = { +export interface WidthHeight { width: number; height: number; -}; +} + export type PageSize = WidthHeight & { equals: (other: WidthHeight) => boolean }; export const position: (element: HTMLElement) => RectPosition = (element: HTMLElement): RectPosition => { @@ -140,9 +141,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; + } + }; }