Skip to content

Commit d881d7a

Browse files
committed
chore(*): refactor types into one file
1 parent cf2de04 commit d881d7a

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

lib/ObserveBoundingClientRect.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
const raf = require('raf');
33

44
import { shallowEqualRect } from './utils';
5+
import { IRect } from './types';
56

67
interface IProps {
78
/**
@@ -29,15 +30,6 @@ interface IProps {
2930
onUpdate?: (rect: IRect) => void;
3031
}
3132

32-
export interface IRect {
33-
top: number;
34-
right: number;
35-
bottom: number;
36-
left: number;
37-
height: number;
38-
width: number;
39-
}
40-
4133
interface IState extends IRect {
4234
isInitialized: boolean;
4335
}

lib/ObserveViewport.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const memoize =
55
const raf = require('raf');
66

77
import { shallowEqualScroll, shallowEqualDimensions } from './utils';
8+
import { IScroll, IDimensions } from './types';
89

910
import {
1011
Consumer,
@@ -15,24 +16,10 @@ import {
1516
SCROLL_DIR_DOWN,
1617
SCROLL_DIR_RIGHT,
1718
SCROLL_DIR_LEFT,
18-
IDimensions,
1919
} from './ViewportProvider';
2020

2121
interface IState extends IContextScroll, IDimensions {}
2222

23-
export interface IScroll {
24-
x: number;
25-
y: number;
26-
xTurn: number;
27-
yTurn: number;
28-
xDTurn: number;
29-
yDTurn: number;
30-
isScrollingUp: boolean;
31-
isScrollingDown: boolean;
32-
isScrollingLeft: boolean;
33-
isScrollingRight: boolean;
34-
}
35-
3623
export interface IChildProps {
3724
scroll: IScroll | null;
3825
dimensions: IDimensions | null;

lib/ViewportProvider.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import * as React from 'react';
22
const throttle = require('lodash.throttle');
33
const debounce = require('lodash.debounce');
44

5+
import { IDimensions } from './types';
6+
57
export const SCROLL_DIR_DOWN = Symbol('SCROLL_DIR_DOWN');
68
export const SCROLL_DIR_UP = Symbol('SCROLL_DIR_UP');
79
export const SCROLL_DIR_LEFT = Symbol('SCROLL_DIR_LEFT');
@@ -18,11 +20,6 @@ export interface IScroll {
1820
yDTurn: number;
1921
}
2022

21-
export interface IDimensions {
22-
width: number;
23-
height: number;
24-
}
25-
2623
const ViewportContext = React.createContext({
2724
scroll: {},
2825
dimensions: {},

lib/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { default as ViewportProvider, IDimensions } from './ViewportProvider';
1+
export { default as ViewportProvider } from './ViewportProvider';
22
export {
33
/**
44
* @deprecated use connectViewport instead
@@ -8,6 +8,6 @@ export {
88
} from './ConnectViewport';
99
export {
1010
default as ObserveBoundingClientRect,
11-
IRect,
1211
} from './ObserveBoundingClientRect';
13-
export { default as ObserveViewport, IScroll } from './ObserveViewport';
12+
export { default as ObserveViewport } from './ObserveViewport';
13+
export { IRect, IScroll, IDimensions } from './types';

lib/types.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export interface IDimensions {
2+
width: number;
3+
height: number;
4+
}
5+
6+
export interface IScroll {
7+
x: number;
8+
y: number;
9+
xTurn: number;
10+
yTurn: number;
11+
xDTurn: number;
12+
yDTurn: number;
13+
isScrollingUp: boolean;
14+
isScrollingDown: boolean;
15+
isScrollingLeft: boolean;
16+
isScrollingRight: boolean;
17+
}
18+
19+
export interface IRect {
20+
top: number;
21+
right: number;
22+
bottom: number;
23+
left: number;
24+
height: number;
25+
width: number;
26+
}

0 commit comments

Comments
 (0)