plotline-engage 3.0.6 → 3.0.8
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/src/main/java/com/reactnativeplotline/RNPlotline.java +5 -0
- package/index.d.ts +1 -0
- package/index.js +28 -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/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -2,8 +2,27 @@
|
|
|
2
2
|
import { NativeModules, Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
const { RNPlotline } = NativeModules;
|
|
5
|
+
import PScrollView from './PScrollView';
|
|
6
|
+
import PFlatList from './PFlatList';
|
|
5
7
|
|
|
6
8
|
class plotline {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.throttledNotifyScroll = this.throttle(this.handleScroll, 250);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
throttle(func, limit) {
|
|
14
|
+
let inThrottle = false;
|
|
15
|
+
return function () {
|
|
16
|
+
if (!inThrottle) {
|
|
17
|
+
func.apply(this, arguments);
|
|
18
|
+
inThrottle = true;
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
inThrottle = false;
|
|
21
|
+
}, limit);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
7
26
|
track (eventName, properties) {
|
|
8
27
|
if (properties)
|
|
9
28
|
RNPlotline.track(eventName, properties);
|
|
@@ -38,8 +57,17 @@ class plotline {
|
|
|
38
57
|
debug () {
|
|
39
58
|
RNPlotline.debug();
|
|
40
59
|
}
|
|
60
|
+
|
|
61
|
+
handleScroll() {
|
|
62
|
+
RNPlotline.notifyScroll();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
notifyScroll() {
|
|
66
|
+
this.throttledNotifyScroll();
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
|
|
43
70
|
const Plotline = new plotline();
|
|
44
71
|
|
|
45
72
|
export default Plotline;
|
|
73
|
+
export {PScrollView, PFlatList};
|
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];
|