Skip to content

Commit 25c6bc9

Browse files
committed
修复:
1. 没有声明allLoaded属性 2. 没有加载组件的时候,声明allLoaded报错 3. 修正ts类型错误
1 parent dfc38c8 commit 25c6bc9

File tree

3 files changed

+16
-39
lines changed

3 files changed

+16
-39
lines changed

src/SpringScrollView.js

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
9696
refreshHeader: Refresh,
9797
loadingFooter: Loading
9898
} = this.props;
99-
const wStyle = StyleSheet.flatten([
100-
styles.wrapperStyle,
101-
style,
102-
{ transform: inverted ? [{ scaleY: -1 }] : [] }
103-
]);
99+
const wStyle = StyleSheet.flatten([styles.wrapperStyle, style, { transform: inverted ? [{ scaleY: -1 }] : [] }]);
104100
const elements = (
105101
<SpringScrollViewNative
106102
{...this.props}
@@ -150,11 +146,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
150146
return (
151147
onRefresh && (
152148
<Animated.View style={this._getRefreshHeaderStyle()}>
153-
<Refresh
154-
ref={ref => (this._refreshHeader = ref)}
155-
offset={this._offsetY}
156-
maxHeight={Refresh.height}
157-
/>
149+
<Refresh ref={ref => (this._refreshHeader = ref)} offset={this._offsetY} maxHeight={Refresh.height} />
158150
</Animated.View>
159151
)
160152
);
@@ -185,9 +177,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
185177
if (!measured) return null;
186178
return (
187179
showsVerticalScrollIndicator &&
188-
this._contentHeight > this._height && (
189-
<Animated.View style={this._getVerticalIndicatorStyle()} />
190-
)
180+
this._contentHeight > this._height && <Animated.View style={this._getVerticalIndicatorStyle()} />
191181
);
192182
}
193183

@@ -198,9 +188,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
198188
if (!measured) return null;
199189
return (
200190
showsHorizontalScrollIndicator &&
201-
this._contentWidth > this._width && (
202-
<Animated.View style={this._getHorizontalIndicatorStyle()} />
203-
)
191+
this._contentWidth > this._width && <Animated.View style={this._getHorizontalIndicatorStyle()} />
204192
);
205193
}
206194

@@ -227,18 +215,9 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
227215

228216
scrollTo(offset: Offset, animated: boolean = true) {
229217
if (Platform.OS === "ios") {
230-
NativeModules.SpringScrollView.scrollTo(
231-
findNodeHandle(this._scrollView),
232-
offset.x,
233-
offset.y,
234-
animated
235-
);
218+
NativeModules.SpringScrollView.scrollTo(findNodeHandle(this._scrollView), offset.x, offset.y, animated);
236219
} else if (Platform.OS === "android") {
237-
UIManager.dispatchViewManagerCommand(findNodeHandle(this._scrollView), 10002, [
238-
offset.x,
239-
offset.y,
240-
animated
241-
]);
220+
UIManager.dispatchViewManagerCommand(findNodeHandle(this._scrollView), 10002, [offset.x, offset.y, animated]);
242221
}
243222
return new Promise((resolve, reject) => {
244223
if (animated) setTimeout(resolve, 500);
@@ -329,16 +308,16 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
329308

330309
_toRefreshStatus(status: HeaderStatus) {
331310
this._refreshStatus = status;
332-
this._refreshHeader.changeToState(status);
311+
idx(() => this._refreshHeader.changeToState(status));
333312
}
334313

335314
_toLoadingStatus(status: FooterStatus) {
336315
this._loadingStatus = status;
337-
this._loadingFooter.changeToState(status);
316+
idx(() => this._loadingFooter.changeToState(status));
338317
}
339318

340319
_getVerticalIndicatorStyle() {
341-
const indicatorHeight = this._height / this._contentHeight * this._height;
320+
const indicatorHeight = (this._height / this._contentHeight) * this._height;
342321
return {
343322
position: "absolute",
344323
top: 0,
@@ -357,7 +336,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
357336
}
358337

359338
_getHorizontalIndicatorStyle() {
360-
const indicatorWidth = this._width / this._contentWidth * this._width;
339+
const indicatorWidth = (this._width / this._contentWidth) * this._width;
361340
return {
362341
position: "absolute",
363342
bottom: 2,
@@ -401,8 +380,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
401380
console.warn(
402381
"unsupported value: '",
403382
style,
404-
"' in SpringScrollView, " +
405-
"select one in 'topping','stickyScrollView','stickyContent' please"
383+
"' in SpringScrollView, " + "select one in 'topping','stickyScrollView','stickyContent' please"
406384
);
407385
}
408386
if (this.props.inverted) transform.push({ scaleY: -1 });
@@ -443,8 +421,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
443421
console.warn(
444422
"unsupported value: '",
445423
style,
446-
"' in SpringScrollView, " +
447-
"select one in 'bottoming','stickyScrollView','stickyContent' please"
424+
"' in SpringScrollView, " + "select one in 'bottoming','stickyScrollView','stickyContent' please"
448425
);
449426
}
450427
if (this.props.inverted) transform.push({ scaleY: -1 });
@@ -489,8 +466,7 @@ export class SpringScrollView extends React.PureComponent<SpringScrollViewPropTy
489466
};
490467

491468
_onTouchBegin = () => {
492-
if (TextInputState.currentlyFocusedField())
493-
TextInputState.blurTextInput(TextInputState.currentlyFocusedField());
469+
if (TextInputState.currentlyFocusedField()) TextInputState.blurTextInput(TextInputState.currentlyFocusedField());
494470
this._indicatorAnimation && this._indicatorAnimation.stop();
495471
this._indicatorOpacity.setValue(1);
496472
this.props.tapToHideKeyboard && Keyboard.dismiss();
@@ -523,5 +499,4 @@ const SpringScrollViewNative = Animated.createAnimatedComponent(
523499
requireNativeComponent("SpringScrollView", SpringScrollView)
524500
);
525501

526-
const SpringScrollContentViewNative =
527-
Platform.OS === "ios" ? requireNativeComponent("SpringScrollContentView") : View;
502+
const SpringScrollContentViewNative = Platform.OS === "ios" ? requireNativeComponent("SpringScrollContentView") : View;

src/Types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export interface SpringScrollViewPropType extends ViewProps {
5252
loadingFooter?: LoadingFooter,
5353
onRefresh?: () => any,
5454
onLoading?: () => any,
55+
allLoaded?: boolean;
5556
textInputRefs?: any[],
5657
inputToolBarHeight?: number,
5758
tapToHideKeyboard?: boolean,

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ declare module "react-native-spring-scrollview" {
9999
loadingFooter?: React.ComponentClass<LoadingFooterPropType, LoadingFooterStateType>;
100100
onRefresh?: () => any;
101101
onLoading?: () => any;
102+
allLoaded?: boolean;
102103
textInputRefs?: any[];
103104
inputToolBarHeight?: number;
104105
tapToHideKeyboard?: boolean;

0 commit comments

Comments
 (0)