Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

typescript support #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { FC, ReactNode } from "react";

export interface ShapeVisiblitySensor {
top?: number;
left?: number;
bottom?: number;
right?: number;
}

export interface VisibilitySensorProps {
onChange?: (isVisible: boolean) => void;
active?: boolean;
partialVisibility?: boolean;
offset?: ShapeVisiblitySensor;
minTopValue?: number;
intervalCheck?: boolean;
intervalDelay?: number;
scrollCheck?: boolean;
scrollDelay?: number;
scrollThrottle?: number;
resizeCheck?: boolean;
resizeDelay?: number;
resizeThrottle?: number;
containment?: any;
delayedCall?: boolean;
children?:
| ReactNode
| ((args: { isVisible: boolean; visibilityRect?: ShapeVisiblitySensor }) => ReactNode);
}

declare const LazyImage: FC<{
children: (image: string, loading: boolean, isVisible: boolean) => ReactNode;
placeholder: string;
src: string;
visibilitySensorProps?: VisibilitySensorProps;
onError?: (ev: ErrorEvent) => void;
}>;

export default LazyImage;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"engines": {
"node": ">=6.0.0"
},
"types": "index.d.ts",
"files": [
".github",
"lib",
"src"
"src",
"index.d.ts"
],
"scripts": {
"predev": "rimraf dist",
Expand Down