Skip to content

Commit 158c22b

Browse files
committed
Fix lint issues
1 parent 268f2d8 commit 158c22b

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

app/index.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ export default class InfiniteScroll extends Component {
8787

8888
componentWillReceiveProps(props) {
8989
// do nothing when dataLength and key are unchanged
90-
if (this.props.key === props.key && this.props.dataLength === props.dataLength) return;
90+
if (
91+
this.props.key === props.key &&
92+
this.props.dataLength === props.dataLength
93+
)
94+
return;
9195

9296
this.actionTriggered = false;
9397
// update state when new data was sent in
@@ -98,8 +102,9 @@ export default class InfiniteScroll extends Component {
98102
}
99103

100104
getScrollableTarget() {
101-
if (this.props.scrollableTarget instanceof HTMLElement) return this.props.scrollableTarget;
102-
if (typeof this.props.scrollableTarget === 'string') {
105+
if (this.props.scrollableTarget instanceof HTMLElement)
106+
return this.props.scrollableTarget;
107+
if (typeof this.props.scrollableTarget === "string") {
103108
return document.getElementById(this.props.scrollableTarget);
104109
}
105110
if (this.props.scrollableTarget === null) {
@@ -119,7 +124,8 @@ export default class InfiniteScroll extends Component {
119124
this.currentY = this.startY;
120125

121126
this._infScroll.style.willChange = "transform";
122-
this._infScroll.style.transition = `transform 0.2s cubic-bezier(0,0,0.31,1)`;
127+
this._infScroll.style.transition =
128+
"transform 0.2s cubic-bezier(0,0,0.31,1)";
123129
}
124130

125131
onMove(evt) {
@@ -143,7 +149,7 @@ export default class InfiniteScroll extends Component {
143149
this.startY}px, 0px)`;
144150
}
145151

146-
onEnd(evt) {
152+
onEnd() {
147153
this.startY = 0;
148154
this.currentY = 0;
149155

@@ -156,9 +162,9 @@ export default class InfiniteScroll extends Component {
156162
requestAnimationFrame(() => {
157163
// this._infScroll
158164
if (this._infScroll) {
159-
this._infScroll.style.overflow = "auto";
160-
this._infScroll.style.transform = "none";
161-
this._infScroll.style.willChange = "none";
165+
this._infScroll.style.overflow = "auto";
166+
this._infScroll.style.transform = "none";
167+
this._infScroll.style.willChange = "none";
162168
}
163169
});
164170
}
@@ -178,7 +184,8 @@ export default class InfiniteScroll extends Component {
178184
}
179185

180186
return (
181-
target.scrollTop + clientHeight >= threshold.value / 100 * target.scrollHeight
187+
target.scrollTop + clientHeight >=
188+
(threshold.value / 100) * target.scrollHeight
182189
);
183190
}
184191

@@ -193,8 +200,8 @@ export default class InfiniteScroll extends Component {
193200
this.props.height || this._scrollableNode
194201
? event.target
195202
: document.documentElement.scrollTop
196-
? document.documentElement
197-
: document.body;
203+
? document.documentElement
204+
: document.body;
198205

199206
// return immediately if the action has already been triggered,
200207
// prevents multiple triggers.
@@ -232,7 +239,7 @@ export default class InfiniteScroll extends Component {
232239
return (
233240
<div style={outerDivStyle}>
234241
<div
235-
className={`infinite-scroll-component ${this.props.className || ''}`}
242+
className={`infinite-scroll-component ${this.props.className || ""}`}
236243
ref={infScroll => (this._infScroll = infScroll)}
237244
style={style}
238245
>

app/utils/threshold.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
export const ThresholdUnits = {
2-
Pixel: 'Pixel',
3-
Percent: 'Percent',
2+
Pixel: "Pixel",
3+
Percent: "Percent"
44
};
55

66
const defaultThreshold = {
77
unit: ThresholdUnits.Percent,
8-
value: 0.8,
8+
value: 0.8
99
};
1010

1111
export function parseThreshold(scrollThreshold) {
1212
if (typeof scrollThreshold === "number") {
1313
return {
1414
unit: ThresholdUnits.Percent,
15-
value: scrollThreshold * 100,
15+
value: scrollThreshold * 100
1616
};
1717
}
1818

1919
if (typeof scrollThreshold === "string") {
2020
if (scrollThreshold.match(/^(\d*(\.\d+)?)px$/)) {
2121
return {
2222
unit: ThresholdUnits.Pixel,
23-
value: parseFloat(scrollThreshold),
23+
value: parseFloat(scrollThreshold)
2424
};
2525
}
2626

2727
if (scrollThreshold.match(/^(\d*(\.\d+)?)%$/)) {
2828
return {
2929
unit: ThresholdUnits.Percent,
30-
value: parseFloat(scrollThreshold),
30+
value: parseFloat(scrollThreshold)
3131
};
3232
}
3333

34-
console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...');
34+
console.warn(
35+
"scrollThreshold format is invalid. Valid formats: '120px', '50%'..."
36+
);
3537

3638
return defaultThreshold;
3739
}
3840

39-
console.warn('scrollThreshold should be string or number');
41+
console.warn("scrollThreshold should be string or number");
4042

4143
return defaultThreshold;
4244
}

0 commit comments

Comments
 (0)