plotline-engage 3.0.6 → 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 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;
@@ -130,4 +130,9 @@ public class RNPlotline extends ReactContextBaseJavaModule {
130
130
  public void debug() {
131
131
  Plotline.debug(true);
132
132
  }
133
+
134
+ @ReactMethod
135
+ public void notifyScroll() {
136
+ Plotline.notifyScroll();
137
+ }
133
138
  }
package/index.d.ts CHANGED
@@ -7,6 +7,7 @@ declare class plotline {
7
7
  setColor(colors: {[key: string]: string}): void;
8
8
  trackPage(pageId: string): void;
9
9
  debug(): void;
10
+ notifyScroll(): void;
10
11
  }
11
12
  declare const Plotline: plotline;
12
13
  export default Plotline;
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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "3.0.6",
3
+ "version": "3.0.7",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"