-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
56 lines (48 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import {
ScrollView,
requireNativeComponent,
findNodeHandle,
UIManager
} from 'react-native';
class LockableScrollView extends ScrollView {
constructor(props) {
super(props);
this.scrollResponderScrollTo = ({x, y, animated}) => {
UIManager.dispatchViewManagerCommand(
this.scrollResponderGetScrollableNode(),
UIManager.TWLockableScrollView.Commands.scrollTo,
[x || 0, y || 0, animated !== false],
);
};
}
render() {
const element = super.render();
return (
<TWLockableScrollView
{...element.props}
ref={element.ref}
/>
);
}
lockBottomScrollOffset() {
UIManager.dispatchViewManagerCommand(
findNodeHandle(this),
UIManager.TWLockableScrollView.Commands.lockBottomScrollOffset,
[]
);
}
}
LockableScrollView.propTypes = ScrollView.propTypes;
const TWLockableScrollView = requireNativeComponent(
'TWLockableScrollView',
LockableScrollView, {
nativeOnly: {
onMomentumScrollBegin: true,
onMomentumScrollEnd : true,
onScrollBeginDrag: true,
onScrollEndDrag: true,
}
}
);
export default LockableScrollView;