plotline-engage 3.1.4 → 3.1.6
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 +19 -5
- package/PScrollView.js +19 -5
- package/index.js +1 -22
- package/package.json +1 -1
package/PFlatList.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { FlatList } from 'react-native';
|
|
3
|
-
|
|
2
|
+
import { NativeModules, FlatList } from 'react-native';
|
|
3
|
+
const { RNPlotline } = NativeModules;
|
|
4
4
|
|
|
5
5
|
class PFlatList extends Component {
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
}
|
|
8
22
|
|
|
9
23
|
if (this.props.onScroll) {
|
|
10
24
|
this.props.onScroll(event);
|
|
11
25
|
}
|
|
12
|
-
}
|
|
26
|
+
}
|
|
13
27
|
|
|
14
28
|
render() {
|
|
15
29
|
return (
|
package/PScrollView.js
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
|
-
import { ScrollView } from 'react-native';
|
|
3
|
-
|
|
2
|
+
import { NativeModules, ScrollView } from 'react-native';
|
|
3
|
+
const { RNPlotline } = NativeModules;
|
|
4
4
|
|
|
5
5
|
class PScrollView extends Component {
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
}
|
|
8
22
|
|
|
9
23
|
if (this.props.onScroll) {
|
|
10
24
|
this.props.onScroll(event);
|
|
11
25
|
}
|
|
12
|
-
}
|
|
26
|
+
}
|
|
13
27
|
|
|
14
28
|
render() {
|
|
15
29
|
return (
|
package/index.js
CHANGED
|
@@ -6,23 +6,6 @@ import PScrollView from './PScrollView';
|
|
|
6
6
|
import PFlatList from './PFlatList';
|
|
7
7
|
|
|
8
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
|
-
|
|
26
9
|
track (eventName, properties) {
|
|
27
10
|
if (properties)
|
|
28
11
|
RNPlotline.track(eventName, properties);
|
|
@@ -58,12 +41,8 @@ class plotline {
|
|
|
58
41
|
RNPlotline.debug();
|
|
59
42
|
}
|
|
60
43
|
|
|
61
|
-
handleScroll() {
|
|
62
|
-
RNPlotline.notifyScroll();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
44
|
notifyScroll() {
|
|
66
|
-
|
|
45
|
+
RNPlotline.notifyScroll();
|
|
67
46
|
}
|
|
68
47
|
}
|
|
69
48
|
|