react-native-scrollpageviewtest 0.0.1-security → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of react-native-scrollpageviewtest might be problematic. Click here for more details.
- package/.gitattributes +1 -0
- package/GestureCommon/CommonLottieFooter.js +41 -0
- package/GestureCommon/CommonLottieHeader.js +34 -0
- package/GestureCommon/CommonLottieScroller.js +366 -0
- package/GestureCommon/CommonNormalFooter.js +8 -0
- package/GestureCommon/CommonNormalHeader.js +8 -0
- package/GestureCommon/CommonWithLastDateFooter.js +15 -0
- package/GestureCommon/CommonWithLastDateHeader.js +15 -0
- package/GestureCommon/WithLastDateFooter.js +81 -0
- package/GestureCommon/WithLastDateHeader.js +80 -0
- package/GestureCommon/index.js +1 -0
- package/GestureCommon/res/arrow.png +0 -0
- package/GestureCommon/res/loading.json +1 -0
- package/GestureCommon/res/refresh/refreshing.json +1 -0
- package/GestureCommon/res/refresh/refreshing2.json +1 -0
- package/GestureCommon/res/refresh/refreshing3.json +978 -0
- package/GestureLoadingFooter.js +62 -0
- package/GestureNormalFooter.js +101 -0
- package/GestureNormalHeader.js +90 -0
- package/GesturePageView.js +516 -0
- package/GesturePropType.js +68 -0
- package/GestureRefreshHeader.js +53 -0
- package/GestureScrollView.js +509 -0
- package/README.md +43 -3
- package/ScrollPageViewPropType.js +70 -0
- package/index.js +7 -0
- package/package.json +14 -3
- package/styles.js +13 -0
@@ -0,0 +1,509 @@
|
|
1
|
+
import React, { PureComponent } from 'react';
|
2
|
+
import type {GesturePropType} from "./GesturePageViewPropType";
|
3
|
+
import {setScrollEnable} from "./GestureCommon/CommonLottieScroller";
|
4
|
+
import {
|
5
|
+
Animated,
|
6
|
+
Dimensions,
|
7
|
+
findNodeHandle,
|
8
|
+
Keyboard,
|
9
|
+
NativeModules,
|
10
|
+
Platform,
|
11
|
+
StyleSheet,
|
12
|
+
UIManager,
|
13
|
+
View
|
14
|
+
} from "react-native";
|
15
|
+
|
16
|
+
export class GestureScrollView extends PureComponent<GesturePropType> {
|
17
|
+
_contentOffset: Offset = { x: 0, y: 0 };
|
18
|
+
_keyboardHeight: number;
|
19
|
+
_refreshHeader;
|
20
|
+
_loadingFooter;
|
21
|
+
_width: number;
|
22
|
+
_height: number;
|
23
|
+
_scrollView: View;
|
24
|
+
_indicatorOpacity: Animated.Value = new Animated.Value(1);
|
25
|
+
_contentHeight: number;
|
26
|
+
_contentWidth: number;
|
27
|
+
_refreshStatus: GestureHeaderStatus = "waiting";
|
28
|
+
_loadingStatus: FooterStatus = "waiting";
|
29
|
+
_indicatorAnimation;
|
30
|
+
_scrollEventAttachment;
|
31
|
+
_nativeOffset;
|
32
|
+
_touching = false;
|
33
|
+
_dragging = false;
|
34
|
+
_sizeChangeInterval = 0;
|
35
|
+
|
36
|
+
_renderRefreshHeader() {
|
37
|
+
const { onRefresh, refreshHeader: Refresh } = this.props;
|
38
|
+
const measured =
|
39
|
+
this._height !== undefined && this._contentHeight !== undefined;
|
40
|
+
if (!measured) return null;
|
41
|
+
return (
|
42
|
+
onRefresh && (
|
43
|
+
<Animated.View style={this._getRefreshHeaderStyle()}>
|
44
|
+
<Refresh
|
45
|
+
ref={(ref) => (this._refreshHeader = ref)}
|
46
|
+
offset={this._nativeOffset.y}
|
47
|
+
maxHeight={Refresh.height}
|
48
|
+
/>
|
49
|
+
</Animated.View>
|
50
|
+
)
|
51
|
+
);
|
52
|
+
}
|
53
|
+
|
54
|
+
_renderLoadingFooter() {
|
55
|
+
const { onLoading, loadingFooter: Footer } = this.props;
|
56
|
+
const measured =
|
57
|
+
this._height !== undefined && this._contentHeight !== undefined;
|
58
|
+
if (!measured) return null;
|
59
|
+
return (
|
60
|
+
onLoading && (
|
61
|
+
<Animated.View style={this._getLoadingFooterStyle()}>
|
62
|
+
<Footer
|
63
|
+
ref={(ref) => (this._loadingFooter = ref)}
|
64
|
+
offset={this._nativeOffset.y}
|
65
|
+
maxHeight={Footer.height}
|
66
|
+
bottomOffset={this._contentHeight - this._height}
|
67
|
+
/>
|
68
|
+
</Animated.View>
|
69
|
+
)
|
70
|
+
);
|
71
|
+
}
|
72
|
+
|
73
|
+
_renderVerticalIndicator() {
|
74
|
+
if (Platform.OS === "ios") return null;
|
75
|
+
const { showsVerticalScrollIndicator } = this.props;
|
76
|
+
const measured =
|
77
|
+
this._height !== undefined && this._contentHeight !== undefined;
|
78
|
+
if (!measured) return null;
|
79
|
+
return (
|
80
|
+
showsVerticalScrollIndicator &&
|
81
|
+
this._contentHeight > this._height && (
|
82
|
+
<Animated.View style={this._getVerticalIndicatorStyle()} />
|
83
|
+
)
|
84
|
+
);
|
85
|
+
}
|
86
|
+
|
87
|
+
_renderHorizontalIndicator() {
|
88
|
+
if (Platform.OS === "ios") return null;
|
89
|
+
const { showsHorizontalScrollIndicator } = this.props;
|
90
|
+
const measured =
|
91
|
+
this._height !== undefined && this._contentHeight !== undefined;
|
92
|
+
if (!measured) return null;
|
93
|
+
return (
|
94
|
+
showsHorizontalScrollIndicator &&
|
95
|
+
this._contentWidth > this._width && (
|
96
|
+
<Animated.View style={this._getHorizontalIndicatorStyle()} />
|
97
|
+
)
|
98
|
+
);
|
99
|
+
}
|
100
|
+
|
101
|
+
async componentDidMount() {
|
102
|
+
this._nativeOffset = {
|
103
|
+
x: new Animated.Value(0),
|
104
|
+
y: new Animated.Value(0)
|
105
|
+
};
|
106
|
+
setScrollEnable(false);
|
107
|
+
this._nativeOffset.x.setValue(this.props.initialContentOffset.y);
|
108
|
+
this._nativeOffset.y.setValue(this.props.initialContentOffset.y);
|
109
|
+
this._width = Dimensions.get('window').width;
|
110
|
+
this._height = Dimensions.get('window').height;
|
111
|
+
}
|
112
|
+
|
113
|
+
scrollToBegin(animated: boolean) {
|
114
|
+
return this.scrollTo({ x: this._contentOffset.x, y: 0 }, animated);
|
115
|
+
}
|
116
|
+
|
117
|
+
scrollToEnd(animated: boolean = true) {
|
118
|
+
let toOffsetY = this._contentHeight - this._height;
|
119
|
+
if (toOffsetY < 0) toOffsetY = 0;
|
120
|
+
return this.scrollTo({ x: this._contentOffset.x, y: toOffsetY }, animated);
|
121
|
+
}
|
122
|
+
|
123
|
+
scrollTo(offset: Offset, animated: boolean = true) {
|
124
|
+
if (Platform.OS === "ios") {
|
125
|
+
NativeModules.SpringScrollView.scrollTo(
|
126
|
+
findNodeHandle(this._scrollView),
|
127
|
+
offset.x,
|
128
|
+
offset.y,
|
129
|
+
animated
|
130
|
+
);
|
131
|
+
} else if (Platform.OS === "android") {
|
132
|
+
UIManager.dispatchViewManagerCommand(
|
133
|
+
findNodeHandle(this._scrollView),
|
134
|
+
"10002",
|
135
|
+
[offset.x, offset.y, animated]
|
136
|
+
);
|
137
|
+
}
|
138
|
+
return new Promise((resolve, reject) => {
|
139
|
+
if (animated) setTimeout(resolve, 500);
|
140
|
+
else resolve();
|
141
|
+
});
|
142
|
+
}
|
143
|
+
|
144
|
+
scroll(offset: Offset, animated: boolean = true) {
|
145
|
+
return this.scrollTo(
|
146
|
+
{
|
147
|
+
x: offset.x + this._contentOffset.x,
|
148
|
+
y: offset.y + this._contentOffset.y
|
149
|
+
},
|
150
|
+
animated
|
151
|
+
);
|
152
|
+
}
|
153
|
+
|
154
|
+
beginRefresh() {
|
155
|
+
if (!this.props.loadingFooter || this.props.loadingFooter.height <= 0)
|
156
|
+
return Promise.reject(
|
157
|
+
"SpringScrollView: call beginRefresh without loadingFooter or loadingFooter height"
|
158
|
+
);
|
159
|
+
return this.scrollTo({
|
160
|
+
x: this._contentOffset.x,
|
161
|
+
y: -this.props.loadingFooter.height - 1,
|
162
|
+
});
|
163
|
+
}
|
164
|
+
|
165
|
+
endRefresh() {
|
166
|
+
if (Platform.OS === "ios") {
|
167
|
+
NativeModules.SpringScrollView.endRefresh(
|
168
|
+
findNodeHandle(this._scrollView)
|
169
|
+
);
|
170
|
+
} else if (Platform.OS === "android") {
|
171
|
+
UIManager.dispatchViewManagerCommand(
|
172
|
+
findNodeHandle(this._scrollView),
|
173
|
+
"10000",
|
174
|
+
[]
|
175
|
+
);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
endLoading(rebound: boolean = false) {
|
180
|
+
if (Platform.OS === "ios") {
|
181
|
+
NativeModules.SpringScrollView.endLoading(
|
182
|
+
findNodeHandle(this._scrollView),
|
183
|
+
rebound
|
184
|
+
);
|
185
|
+
} else if (Platform.OS === "android") {
|
186
|
+
UIManager.dispatchViewManagerCommand(
|
187
|
+
findNodeHandle(this._scrollView),
|
188
|
+
"10001",
|
189
|
+
[rebound]
|
190
|
+
);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
_onKeyboardWillShow = (evt) => {
|
195
|
+
this._touching = false;
|
196
|
+
this.props.textInputRefs.every((input) => {
|
197
|
+
if (idx(() => input.current.isFocused())) {
|
198
|
+
input.current.measureInWindow((x, y, w, h, l, t) => {
|
199
|
+
this._keyboardHeight =
|
200
|
+
-evt.endCoordinates.screenY + this.props.inputToolBarHeight + y + h;
|
201
|
+
this._keyboardHeight > 0 &&
|
202
|
+
this.scroll({ x: 0, y: this._keyboardHeight });
|
203
|
+
});
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
return true;
|
207
|
+
});
|
208
|
+
};
|
209
|
+
|
210
|
+
_onKeyboardWillHide = () => {
|
211
|
+
if (this._keyboardHeight > 0) {
|
212
|
+
!this._touching && this.scroll({ x: 0, y: -this._keyboardHeight });
|
213
|
+
this._keyboardHeight = 0;
|
214
|
+
}
|
215
|
+
};
|
216
|
+
|
217
|
+
_beginIndicatorDismissAnimation() {
|
218
|
+
this._indicatorOpacity.setValue(1);
|
219
|
+
this._indicatorAnimation && this._indicatorAnimation.stop();
|
220
|
+
this._indicatorAnimation = Animated.timing(this._indicatorOpacity, {
|
221
|
+
toValue: 0,
|
222
|
+
delay: 500,
|
223
|
+
duration: 500,
|
224
|
+
useNativeDriver: true,
|
225
|
+
});
|
226
|
+
this._indicatorAnimation.start(({ finished }) => {
|
227
|
+
if (!finished) {
|
228
|
+
this._indicatorOpacity.setValue(1);
|
229
|
+
}
|
230
|
+
this._indicatorAnimation = null;
|
231
|
+
});
|
232
|
+
}
|
233
|
+
|
234
|
+
_onScroll = (e) => {
|
235
|
+
const {
|
236
|
+
contentOffset: { x, y },
|
237
|
+
refreshStatus,
|
238
|
+
loadingStatus,
|
239
|
+
} = e.nativeEvent;
|
240
|
+
this._contentOffset = { x, y };
|
241
|
+
if (this._refreshStatus !== refreshStatus) {
|
242
|
+
this._toRefreshStatus(refreshStatus);
|
243
|
+
this.props.onRefresh &&
|
244
|
+
refreshStatus === "refreshing" &&
|
245
|
+
this.props.onRefresh();
|
246
|
+
}
|
247
|
+
if (this._loadingStatus !== loadingStatus) {
|
248
|
+
this._toLoadingStatus(loadingStatus);
|
249
|
+
this.props.onLoading &&
|
250
|
+
loadingStatus === "loading" &&
|
251
|
+
this.props.onLoading();
|
252
|
+
}
|
253
|
+
this.props.onScroll && this.props.onScroll(e);
|
254
|
+
if (!this._indicatorAnimation) {
|
255
|
+
this._indicatorOpacity.setValue(1);
|
256
|
+
}
|
257
|
+
};
|
258
|
+
|
259
|
+
_toRefreshStatus(status: GestureHeaderStatus) {
|
260
|
+
this._refreshStatus = status;
|
261
|
+
idx(() => this._refreshHeader.changeToState(status));
|
262
|
+
}
|
263
|
+
|
264
|
+
_toLoadingStatus(status: FooterStatus) {
|
265
|
+
this._loadingStatus = status;
|
266
|
+
idx(() => this._loadingFooter.changeToState(status));
|
267
|
+
}
|
268
|
+
|
269
|
+
_getVerticalIndicatorStyle() {
|
270
|
+
const indicatorHeight = (this._height / this._contentHeight) * this._height;
|
271
|
+
return {
|
272
|
+
position: "absolute",
|
273
|
+
top: 0,
|
274
|
+
right: 2,
|
275
|
+
height: indicatorHeight,
|
276
|
+
width: 3,
|
277
|
+
borderRadius: 3,
|
278
|
+
opacity: this._indicatorOpacity,
|
279
|
+
backgroundColor: "#A8A8A8",
|
280
|
+
transform: [
|
281
|
+
{
|
282
|
+
translateY: Animated.multiply(
|
283
|
+
this._nativeOffset.y,
|
284
|
+
this._height / this._contentHeight
|
285
|
+
),
|
286
|
+
},
|
287
|
+
],
|
288
|
+
};
|
289
|
+
}
|
290
|
+
|
291
|
+
_getHorizontalIndicatorStyle() {
|
292
|
+
const indicatorWidth = (this._width / this._contentWidth) * this._width;
|
293
|
+
return {
|
294
|
+
position: "absolute",
|
295
|
+
bottom: 2,
|
296
|
+
left: 0,
|
297
|
+
height: 3,
|
298
|
+
width: indicatorWidth,
|
299
|
+
borderRadius: 3,
|
300
|
+
opacity: this._indicatorOpacity,
|
301
|
+
backgroundColor: "#A8A8A8",
|
302
|
+
transform: [
|
303
|
+
{
|
304
|
+
translateX: Animated.multiply(
|
305
|
+
this._nativeOffset.x,
|
306
|
+
this._width / this._contentWidth
|
307
|
+
),
|
308
|
+
},
|
309
|
+
],
|
310
|
+
};
|
311
|
+
}
|
312
|
+
|
313
|
+
_getRefreshHeaderStyle() {
|
314
|
+
const rHeight = this.props.refreshHeader.height;
|
315
|
+
const style = this.props.refreshHeader.style;
|
316
|
+
let transform = [];
|
317
|
+
if (style === "topping") {
|
318
|
+
transform = [
|
319
|
+
{
|
320
|
+
translateY: this._nativeOffset.y.interpolate({
|
321
|
+
inputRange: [-rHeight - 1, -rHeight, 0, 1],
|
322
|
+
outputRange: [-1, 0, rHeight, rHeight],
|
323
|
+
}),
|
324
|
+
},
|
325
|
+
];
|
326
|
+
} else if (style === "stickyScrollView") {
|
327
|
+
transform = [
|
328
|
+
{
|
329
|
+
translateY: this._nativeOffset.y.interpolate({
|
330
|
+
inputRange: [-rHeight - 1, -rHeight, 0, 1],
|
331
|
+
outputRange: [-1, 0, 0, 0],
|
332
|
+
}),
|
333
|
+
},
|
334
|
+
];
|
335
|
+
} else if (style !== "stickyContent") {
|
336
|
+
console.warn(
|
337
|
+
"unsupported value: '",
|
338
|
+
style,
|
339
|
+
"' in SpringScrollView, " +
|
340
|
+
"select one in 'topping','stickyScrollView','stickyContent' please"
|
341
|
+
);
|
342
|
+
}
|
343
|
+
if (this.props.inverted) transform.push({ scaleY: -1 });
|
344
|
+
return {
|
345
|
+
position: "absolute",
|
346
|
+
top: -rHeight,
|
347
|
+
right: 0,
|
348
|
+
height: rHeight,
|
349
|
+
left: 0,
|
350
|
+
transform,
|
351
|
+
};
|
352
|
+
}
|
353
|
+
|
354
|
+
_getLoadingFooterStyle() {
|
355
|
+
const fHeight = this.props.loadingFooter.height;
|
356
|
+
const maxOffset = this._contentHeight - this._height;
|
357
|
+
const style = this.props.loadingFooter.style;
|
358
|
+
let transform = [];
|
359
|
+
if (style === "bottoming") {
|
360
|
+
transform = [
|
361
|
+
{
|
362
|
+
translateY: this._nativeOffset.y.interpolate({
|
363
|
+
inputRange: [
|
364
|
+
maxOffset - 1,
|
365
|
+
maxOffset,
|
366
|
+
maxOffset + fHeight,
|
367
|
+
maxOffset + fHeight + 1,
|
368
|
+
],
|
369
|
+
outputRange: [-fHeight, -fHeight, 0, 1],
|
370
|
+
}),
|
371
|
+
},
|
372
|
+
];
|
373
|
+
} else if (style === "stickyScrollView") {
|
374
|
+
transform = [
|
375
|
+
{
|
376
|
+
translateY: this._nativeOffset.y.interpolate({
|
377
|
+
inputRange: [
|
378
|
+
maxOffset - 1,
|
379
|
+
maxOffset,
|
380
|
+
maxOffset + fHeight,
|
381
|
+
maxOffset + fHeight + 1,
|
382
|
+
],
|
383
|
+
outputRange: [0, 0, 0, 1],
|
384
|
+
}),
|
385
|
+
},
|
386
|
+
];
|
387
|
+
} else if (style !== "stickyContent") {
|
388
|
+
console.warn(
|
389
|
+
"unsupported value: '",
|
390
|
+
style,
|
391
|
+
"' in SpringScrollView, " +
|
392
|
+
"select one in 'bottoming','stickyScrollView' and 'stickyContent' please!"
|
393
|
+
);
|
394
|
+
}
|
395
|
+
if (this.props.inverted) transform.push({ scaleY: -1 });
|
396
|
+
return {
|
397
|
+
position: "absolute",
|
398
|
+
right: 0,
|
399
|
+
top:
|
400
|
+
this._height > this._contentHeight ? this._height : this._contentHeight,
|
401
|
+
height: fHeight,
|
402
|
+
left: 0,
|
403
|
+
transform,
|
404
|
+
};
|
405
|
+
}
|
406
|
+
|
407
|
+
_onWrapperLayoutChange = ({
|
408
|
+
nativeEvent: {
|
409
|
+
layout: { x, y, width, height },
|
410
|
+
},
|
411
|
+
}) => {
|
412
|
+
if (this._height !== height || this._width !== width) {
|
413
|
+
this.props.onSizeChange && this.props.onSizeChange({ width, height });
|
414
|
+
this._height = height;
|
415
|
+
this._width = width;
|
416
|
+
this._startSizeChangeInterval();
|
417
|
+
}
|
418
|
+
};
|
419
|
+
|
420
|
+
_onContentLayoutChange = ({
|
421
|
+
nativeEvent: {
|
422
|
+
layout: { x, y, width, height },
|
423
|
+
},
|
424
|
+
}) => {
|
425
|
+
if (this._contentHeight !== height || this._contentWidth !== width) {
|
426
|
+
this.props.onContentSizeChange &&
|
427
|
+
this.props.onContentSizeChange({ width, height });
|
428
|
+
this._contentHeight = height;
|
429
|
+
this._contentWidth = width;
|
430
|
+
this._startSizeChangeInterval();
|
431
|
+
}
|
432
|
+
};
|
433
|
+
|
434
|
+
_startSizeChangeInterval = () => {
|
435
|
+
if (this._sizeChangeInterval) clearInterval(this._sizeChangeInterval);
|
436
|
+
this._sizeChangeInterval = setInterval(() => {
|
437
|
+
if (!this._height || !this._contentHeight) return;
|
438
|
+
if (this._contentHeight < this._height)
|
439
|
+
this._contentHeight = this._height;
|
440
|
+
let { x: maxX, y: maxY } = this._contentOffset;
|
441
|
+
if (this._contentOffset.y > this._contentHeight - this._height) {
|
442
|
+
maxY = this._contentHeight - this._height;
|
443
|
+
if (maxY < 0) maxY = 0;
|
444
|
+
}
|
445
|
+
if (this._contentOffset.x > this._contentWidth - this._width) {
|
446
|
+
maxX = this._contentWidth - this._width;
|
447
|
+
if (maxX < 0) maxX = 0;
|
448
|
+
}
|
449
|
+
if (maxX !== this._contentOffset.x || maxY !== this._contentOffset.y) {
|
450
|
+
Platform.OS === "android" && this.scrollTo({ x: maxX, y: maxY }, false);
|
451
|
+
}
|
452
|
+
this.forceUpdate();
|
453
|
+
clearInterval(this._sizeChangeInterval);
|
454
|
+
this._sizeChangeInterval = 0;
|
455
|
+
}, Platform.select({ ios: 10, android: 30 }));
|
456
|
+
};
|
457
|
+
|
458
|
+
render() {
|
459
|
+
return (
|
460
|
+
<View/>
|
461
|
+
);
|
462
|
+
};
|
463
|
+
|
464
|
+
_onTouchBegin = (e) => {
|
465
|
+
this._touching = true;
|
466
|
+
this.props.onTouchBegin && this.props.onTouchBegin(e);
|
467
|
+
};
|
468
|
+
|
469
|
+
_onTouchEnd = (e) => {
|
470
|
+
this._touching = false;
|
471
|
+
this.props.onTouchEnd && this.props.onTouchEnd(e);
|
472
|
+
};
|
473
|
+
|
474
|
+
_onMomentumScrollEnd = () => {
|
475
|
+
this._touching = false;
|
476
|
+
this._dragging = false;
|
477
|
+
this._beginIndicatorDismissAnimation();
|
478
|
+
this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd();
|
479
|
+
};
|
480
|
+
|
481
|
+
_onScrollBeginDrag = () => {
|
482
|
+
this._dragging = true;
|
483
|
+
if (this.props.dragToHideKeyboard) Keyboard.dismiss();
|
484
|
+
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag();
|
485
|
+
};
|
486
|
+
|
487
|
+
_onScrollEndDrag = () => {
|
488
|
+
this._dragging = false;
|
489
|
+
this.props.onScrollEndDrag && this.props.onScrollEndDrag();
|
490
|
+
};
|
491
|
+
|
492
|
+
static defaultProps = {
|
493
|
+
bounces: true,
|
494
|
+
showHeader: false,
|
495
|
+
showFooter: false,
|
496
|
+
textInputRefs: [],
|
497
|
+
decelerationRate: 0.997,
|
498
|
+
inputToolBarHeight: 44,
|
499
|
+
dragToHideKeyboard: true,
|
500
|
+
keyboardShouldPersistTaps: "handled",
|
501
|
+
showsVerticalScrollIndicator: true,
|
502
|
+
showsHorizontalScrollIndicator: true,
|
503
|
+
initialContentOffset: { x: 0, y: 0 },
|
504
|
+
alwaysBounceVertical: true,
|
505
|
+
pagingEnabled: false,
|
506
|
+
pageWidth: Dimensions.get('window').width,
|
507
|
+
scrollEnabled: true
|
508
|
+
};
|
509
|
+
}
|
package/README.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
|
-
# Security holding package
|
2
1
|
|
3
|
-
|
2
|
+
# react-native-scrollpageviewtest
|
4
3
|
|
5
|
-
|
4
|
+
## Getting started
|
5
|
+
|
6
|
+
`$ npm install react-native-scrollpageviewtest --save`
|
7
|
+
|
8
|
+
### Mostly automatic installation
|
9
|
+
|
10
|
+
`$ react-native link react-native-scrollpageviewtest`
|
11
|
+
|
12
|
+
### Manual installation
|
13
|
+
|
14
|
+
|
15
|
+
#### iOS
|
16
|
+
|
17
|
+
1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
18
|
+
2. Go to `node_modules` ➜ `react-native-scrollpageviewtest` and add `RNScrollpageviewtest.xcodeproj`
|
19
|
+
3. In XCode, in the project navigator, select your project. Add `libRNScrollpageviewtest.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
20
|
+
4. Run your project (`Cmd+R`)<
|
21
|
+
|
22
|
+
#### Android
|
23
|
+
|
24
|
+
1. Open up `android/app/src/main/java/[...]/MainActivity.java`
|
25
|
+
- Add `import com.rncomp.scrollpageviewtest.RNScrollpageviewtestPackage;` to the imports at the top of the file
|
26
|
+
- Add `new RNScrollpageviewtestPackage()` to the list returned by the `getPackages()` method
|
27
|
+
2. Append the following lines to `android/settings.gradle`:
|
28
|
+
```
|
29
|
+
include ':react-native-scrollpageviewtest'
|
30
|
+
project(':react-native-scrollpageviewtest').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-scrollpageviewtest/android')
|
31
|
+
```
|
32
|
+
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
33
|
+
```
|
34
|
+
compile project(':react-native-scrollpageviewtest')
|
35
|
+
```
|
36
|
+
|
37
|
+
|
38
|
+
## Usage
|
39
|
+
```javascript
|
40
|
+
import RNScrollpageviewtest from 'react-native-scrollpageviewtest';
|
41
|
+
|
42
|
+
// TODO: What to do with the module?
|
43
|
+
RNScrollpageviewtest;
|
44
|
+
```
|
45
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import {Animated, ViewProps, ViewStyle} from 'react-native';
|
2
|
+
import PropTypes from "prop-types";
|
3
|
+
import {PanGestureHandlerGestureEvent} from "react-native-gesture-handler";
|
4
|
+
// import {RefreshHeader} from './RefreshHeader';
|
5
|
+
// import {LoadingFooter} from './LoadingFooter';
|
6
|
+
|
7
|
+
export interface PageIndexPath {
|
8
|
+
section: number;
|
9
|
+
row: number;
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface PageOffset {
|
13
|
+
x: number;
|
14
|
+
y: number;
|
15
|
+
}
|
16
|
+
|
17
|
+
export interface PageNativeContentOffset {
|
18
|
+
x?: Animated.Value;
|
19
|
+
y?: Animated.Value;
|
20
|
+
}
|
21
|
+
|
22
|
+
export type RefreshStyle = 'topping' | 'stickyScrollView' | 'stickyContent';
|
23
|
+
|
24
|
+
export type LoadingStyle = 'bottoming' | 'stickyScrollView' | 'stickyContent';
|
25
|
+
|
26
|
+
export interface PageScrollEvent {
|
27
|
+
nativeEvent: {
|
28
|
+
contentOffset: {
|
29
|
+
x: number,
|
30
|
+
y: number,
|
31
|
+
},
|
32
|
+
};
|
33
|
+
}
|
34
|
+
|
35
|
+
export interface ScrollPageViewPropType extends ViewProps {
|
36
|
+
style?: ViewStyle;
|
37
|
+
contentStyle?: ViewStyle;
|
38
|
+
bounces?: boolean;
|
39
|
+
pagingEnabled?: boolean;
|
40
|
+
decelerationRate?: number;
|
41
|
+
directionalLockEnabled?: boolean;
|
42
|
+
initialContentOffset?: Offset;
|
43
|
+
showsVerticalScrollIndicator?: boolean;
|
44
|
+
showsHorizontalScrollIndicator?: boolean;
|
45
|
+
onRefresh?: () => any;
|
46
|
+
onLoading?: () => any;
|
47
|
+
allLoaded?: boolean;
|
48
|
+
textInputRefs?: any[];
|
49
|
+
inputToolBarHeight?: number;
|
50
|
+
tapToHideKeyboard?: boolean;
|
51
|
+
onTouchBegin?: () => any;
|
52
|
+
onTouchEnd?: () => any;
|
53
|
+
inverted?: boolean;
|
54
|
+
onScroll?: (evt: ScrollEvent) => any;
|
55
|
+
keyboardShouldPersistTaps?: 'always' | 'never' | 'handled';
|
56
|
+
onNativeContentOffsetExtract?: NativeContentOffset;
|
57
|
+
onSizeChange?: ({width: number, height: number}) => any;
|
58
|
+
onContentSizeChange?: ({width: number, height: number}) => any;
|
59
|
+
pageWidth?: number;
|
60
|
+
children: any;
|
61
|
+
pageSize?: number;
|
62
|
+
onMomentumScrollEnd?: () => any;
|
63
|
+
onMomentumScrollBegin?: () => any;
|
64
|
+
onMomentumScrollActive?: () => any;
|
65
|
+
onStateChange: () => any;
|
66
|
+
onGestureEvent?: any;
|
67
|
+
scrollEnabled?: boolean;
|
68
|
+
activeOffset: number;
|
69
|
+
activeVelocity: number;
|
70
|
+
}
|
package/index.js
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
export * from "./GesturePageView";
|
2
|
+
export * from "./GesturePropType";
|
3
|
+
export * from "./GestureRefreshHeader";
|
4
|
+
export * from "./GestureLoadingFooter";
|
5
|
+
export * from "./GestureNormalHeader";
|
6
|
+
export * from "./GestureNormalFooter";
|
7
|
+
export * from "./GestureScrollView";
|
package/package.json
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-scrollpageviewtest",
|
3
|
-
"version": "
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "1.5.5",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"keywords": [
|
10
|
+
"react-native"
|
11
|
+
],
|
12
|
+
"author": "",
|
13
|
+
"license": "",
|
14
|
+
"peerDependencies": {
|
15
|
+
"react-native": "^0.41.2"
|
16
|
+
}
|
6
17
|
}
|