plotline-engage 3.1.6 → 3.1.7
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.
- package/index.js +53 -4
- package/package.json +1 -1
- package/PFlatList.js +0 -37
- package/PScrollView.js +0 -37
package/index.js
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
|
|
2
2
|
import { NativeModules, Platform } from 'react-native';
|
|
3
|
-
|
|
3
|
+
import { ScrollView, FlatList } from 'react-native';
|
|
4
4
|
const { RNPlotline } = NativeModules;
|
|
5
|
-
import PScrollView from './PScrollView';
|
|
6
|
-
import PFlatList from './PFlatList';
|
|
7
5
|
|
|
8
6
|
class plotline {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.throttledNotifyScroll = this.throttle(this.handleScroll, 250);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
throttle(func, limit) {
|
|
12
|
+
let inThrottle = false;
|
|
13
|
+
return function () {
|
|
14
|
+
if (!inThrottle) {
|
|
15
|
+
func.apply(this, arguments);
|
|
16
|
+
inThrottle = true;
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
inThrottle = false;
|
|
19
|
+
}, limit);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
9
24
|
track (eventName, properties) {
|
|
10
25
|
if (properties)
|
|
11
26
|
RNPlotline.track(eventName, properties);
|
|
@@ -41,12 +56,46 @@ class plotline {
|
|
|
41
56
|
RNPlotline.debug();
|
|
42
57
|
}
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
handleScroll() {
|
|
45
60
|
RNPlotline.notifyScroll();
|
|
46
61
|
}
|
|
62
|
+
|
|
63
|
+
notifyScroll() {
|
|
64
|
+
this.throttledNotifyScroll();
|
|
65
|
+
}
|
|
47
66
|
}
|
|
48
67
|
|
|
49
68
|
const Plotline = new plotline();
|
|
50
69
|
|
|
70
|
+
const PScrollView = (props) => {
|
|
71
|
+
const handleScroll = (event) => {
|
|
72
|
+
Plotline.notifyScroll();
|
|
73
|
+
if (props.onScroll) {
|
|
74
|
+
props.onScroll(event);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<ScrollView {...props} onScroll={handleScroll} scrollEventThrottle={16}>
|
|
80
|
+
{props.children}
|
|
81
|
+
</ScrollView>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const PFlatList = (props) => {
|
|
86
|
+
const handleScroll = (event) => {
|
|
87
|
+
Plotline.notifyScroll();
|
|
88
|
+
if (props.onScroll) {
|
|
89
|
+
props.onScroll(event);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<FlatList {...props} onScroll={handleScroll} scrollEventThrottle={16}>
|
|
95
|
+
{props.children}
|
|
96
|
+
</FlatList>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
99
|
+
|
|
51
100
|
export default Plotline;
|
|
52
101
|
export {PScrollView, PFlatList};
|
package/package.json
CHANGED
package/PFlatList.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import { NativeModules, FlatList } from 'react-native';
|
|
3
|
-
const { RNPlotline } = NativeModules;
|
|
4
|
-
|
|
5
|
-
class PFlatList extends Component {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.handleScroll = this.handleScroll.bind(this);
|
|
9
|
-
this.throttleTimeout = null;
|
|
10
|
-
this.isThrottled = false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
handleScroll(event) {
|
|
14
|
-
if (!this.isThrottled) {
|
|
15
|
-
RNPlotline.notifyScroll();
|
|
16
|
-
this.isThrottled = true;
|
|
17
|
-
clearTimeout(this.throttleTimeout);
|
|
18
|
-
this.throttleTimeout = setTimeout(() => {
|
|
19
|
-
this.isThrottled = false;
|
|
20
|
-
}, 250);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (this.props.onScroll) {
|
|
24
|
-
this.props.onScroll(event);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
return (
|
|
30
|
-
<FlatList {...this.props} onScroll={this.handleScroll} scrollEventThrottle={16}>
|
|
31
|
-
{this.props.children}
|
|
32
|
-
</FlatList>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default PFlatList;
|
package/PScrollView.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import { NativeModules, ScrollView } from 'react-native';
|
|
3
|
-
const { RNPlotline } = NativeModules;
|
|
4
|
-
|
|
5
|
-
class PScrollView extends Component {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.handleScroll = this.handleScroll.bind(this);
|
|
9
|
-
this.throttleTimeout = null;
|
|
10
|
-
this.isThrottled = false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
handleScroll(event) {
|
|
14
|
-
if (!this.isThrottled) {
|
|
15
|
-
RNPlotline.notifyScroll();
|
|
16
|
-
this.isThrottled = true;
|
|
17
|
-
clearTimeout(this.throttleTimeout);
|
|
18
|
-
this.throttleTimeout = setTimeout(() => {
|
|
19
|
-
this.isThrottled = false;
|
|
20
|
-
}, 250);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (this.props.onScroll) {
|
|
24
|
-
this.props.onScroll(event);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
return (
|
|
30
|
-
<ScrollView {...this.props} onScroll={this.handleScroll} scrollEventThrottle={16}>
|
|
31
|
-
{this.props.children}
|
|
32
|
-
</ScrollView>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default PScrollView;
|