plotline-engage 3.0.5 → 3.0.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/PFlatList.js +23 -0
- package/PScrollView.js +23 -0
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativeplotline/RNPlotline.java +5 -0
- package/index.d.ts +1 -0
- package/index.js +25 -0
- package/ios/RNPlotline.m +5 -0
- package/package.json +1 -1
package/PFlatList.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { FlatList } from 'react-native';
|
|
3
|
+
import Plotline from '.';
|
|
4
|
+
|
|
5
|
+
class PFlatList extends Component {
|
|
6
|
+
handleScroll = (event) => {
|
|
7
|
+
Plotline.notifyScroll();
|
|
8
|
+
|
|
9
|
+
if (this.props.onScroll) {
|
|
10
|
+
this.props.onScroll(event);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
return (
|
|
16
|
+
<FlatList {...this.props} onScroll={this.handleScroll}>
|
|
17
|
+
{this.props.children}
|
|
18
|
+
</FlatList>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default PFlatList;
|
package/PScrollView.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
|
+
import Plotline from '.';
|
|
4
|
+
|
|
5
|
+
class PScrollView extends Component {
|
|
6
|
+
handleScroll = (event) => {
|
|
7
|
+
Plotline.notifyScroll();
|
|
8
|
+
|
|
9
|
+
if (this.props.onScroll) {
|
|
10
|
+
this.props.onScroll(event);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
return (
|
|
16
|
+
<ScrollView {...this.props} onScroll={this.handleScroll}>
|
|
17
|
+
{this.props.children}
|
|
18
|
+
</ScrollView>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default PScrollView;
|
package/android/build.gradle
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -4,6 +4,23 @@ import { NativeModules, Platform } from 'react-native';
|
|
|
4
4
|
const { RNPlotline } = NativeModules;
|
|
5
5
|
|
|
6
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
|
+
|
|
7
24
|
track (eventName, properties) {
|
|
8
25
|
if (properties)
|
|
9
26
|
RNPlotline.track(eventName, properties);
|
|
@@ -38,6 +55,14 @@ class plotline {
|
|
|
38
55
|
debug () {
|
|
39
56
|
RNPlotline.debug();
|
|
40
57
|
}
|
|
58
|
+
|
|
59
|
+
handleScroll() {
|
|
60
|
+
RNPlotline.notifyScroll();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
notifyScroll() {
|
|
64
|
+
this.throttledNotifyScroll();
|
|
65
|
+
}
|
|
41
66
|
}
|
|
42
67
|
|
|
43
68
|
const Plotline = new plotline();
|
package/ios/RNPlotline.m
CHANGED
|
@@ -48,6 +48,11 @@ RCT_EXPORT_METHOD(debug)
|
|
|
48
48
|
[Plotline debugWithShouldDebug:true];
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
RCT_EXPORT_METHOD(notifyScroll)
|
|
52
|
+
{
|
|
53
|
+
[Plotline notifyScroll];
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
RCT_EXPORT_METHOD(trackPage:(NSString *)pageName)
|
|
52
57
|
{
|
|
53
58
|
[Plotline trackPageWithPageName:pageName];
|