|
1 | 1 | import React, { Component, ReactNode, CSSProperties } from "react"; |
2 | | -import { throttle } from 'throttle-debounce'; |
| 2 | +import { throttle } from "throttle-debounce"; |
3 | 3 | import { ThresholdUnits, parseThreshold } from "./utils/threshold"; |
4 | 4 |
|
5 | 5 | type Fn = () => any; |
6 | 6 | interface Props { |
7 | | - next?: Fn; |
8 | | - hasMore?: boolean; |
9 | | - children?: ReactNode; |
| 7 | + next: Fn; |
| 8 | + hasMore: boolean; |
| 9 | + children: ReactNode; |
10 | 10 | loader: ReactNode; |
11 | 11 | scrollThreshold?: number | string; |
12 | 12 | endMessage?: ReactNode; |
@@ -74,7 +74,9 @@ export default class InfiniteScroll extends Component<Props, State> { |
74 | 74 | : this._scrollableNode || window; |
75 | 75 |
|
76 | 76 | if (this.el) { |
77 | | - this.el.addEventListener("scroll", (e) => this.throttledOnScrollListener(e as MouseEvent)); |
| 77 | + this.el.addEventListener("scroll", e => |
| 78 | + this.throttledOnScrollListener(e as MouseEvent) |
| 79 | + ); |
78 | 80 | } |
79 | 81 |
|
80 | 82 | if ( |
@@ -116,7 +118,9 @@ export default class InfiniteScroll extends Component<Props, State> { |
116 | 118 |
|
117 | 119 | componentWillUnmount() { |
118 | 120 | if (this.el) { |
119 | | - this.el.removeEventListener("scroll", (e) => this.throttledOnScrollListener(e as MouseEvent)); |
| 121 | + this.el.removeEventListener("scroll", e => |
| 122 | + this.throttledOnScrollListener(e as MouseEvent) |
| 123 | + ); |
120 | 124 |
|
121 | 125 | if (this.props.pullDownToRefresh) { |
122 | 126 | this.el.removeEventListener("touchstart", this.onStart); |
@@ -191,7 +195,10 @@ export default class InfiniteScroll extends Component<Props, State> { |
191 | 195 | // user is scrolling down to up |
192 | 196 | if (this.currentY < this.startY) return; |
193 | 197 |
|
194 | | - if (this.currentY - this.startY >= Number(this.props.pullDownToRefreshThreshold)) { |
| 198 | + if ( |
| 199 | + this.currentY - this.startY >= |
| 200 | + Number(this.props.pullDownToRefreshThreshold) |
| 201 | + ) { |
195 | 202 | this.setState({ |
196 | 203 | pullToRefreshThresholdBreached: true |
197 | 204 | }); |
|
0 commit comments