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

Commit 4d11d66

Browse files
committed
typescript support
1 parent d0c48ce commit 4d11d66

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

index.d.ts

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { FC, ReactNode } from "react";
2+
3+
export interface ShapeVisiblitySensor {
4+
top?: number;
5+
left?: number;
6+
bottom?: number;
7+
right?: number;
8+
}
9+
10+
export interface VisibilitySensorProps {
11+
onChange?: (isVisible: boolean) => void;
12+
active?: boolean;
13+
partialVisibility?: boolean;
14+
offset?: ShapeVisiblitySensor;
15+
minTopValue?: number;
16+
intervalCheck?: boolean;
17+
intervalDelay?: number;
18+
scrollCheck?: boolean;
19+
scrollDelay?: number;
20+
scrollThrottle?: number;
21+
resizeCheck?: boolean;
22+
resizeDelay?: number;
23+
resizeThrottle?: number;
24+
containment?: any;
25+
delayedCall?: boolean;
26+
children?:
27+
| ReactNode
28+
| ((args: { isVisible: boolean; visibilityRect?: ShapeVisiblitySensor }) => ReactNode);
29+
}
30+
31+
declare const LazyImage: FC<{
32+
children: (image: string, loading: boolean, isVisible: boolean) => ReactNode;
33+
placeholder: string;
34+
src: string;
35+
visibilitySensorProps: VisibilitySensorProps;
36+
onError: (ev: ErrorEvent) => void;
37+
}>;
38+
39+
export default LazyImage;

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
"engines": {
77
"node": ">=6.0.0"
88
},
9+
"types": "index.d.ts",
910
"files": [
1011
".github",
1112
"lib",
12-
"src"
13+
"src",
14+
"index.d.ts"
1315
],
1416
"scripts": {
1517
"predev": "rimraf dist",

0 commit comments

Comments
 (0)