plotline-engage 3.0.9 → 3.1.1

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 CHANGED
@@ -13,7 +13,7 @@ class PFlatList extends Component {
13
13
 
14
14
  render() {
15
15
  return (
16
- <FlatList {...this.props} onScroll={this.handleScroll}>
16
+ <FlatList {...this.props} onScroll={this.handleScroll} scrollEventThrottle={16}>
17
17
  {this.props.children}
18
18
  </FlatList>
19
19
  );
package/PScrollView.js CHANGED
@@ -13,7 +13,7 @@ class PScrollView extends Component {
13
13
 
14
14
  render() {
15
15
  return (
16
- <ScrollView {...this.props} onScroll={this.handleScroll}>
16
+ <ScrollView {...this.props} onScroll={this.handleScroll} scrollEventThrottle={16}>
17
17
  {this.props.children}
18
18
  </ScrollView>
19
19
  );
package/index.js CHANGED
@@ -8,18 +8,26 @@ import PFlatList from './PFlatList';
8
8
  class plotline {
9
9
  constructor() {
10
10
  this.throttledNotifyScroll = this.throttle(this.handleScroll, 250);
11
+ this.lastInvokeTime = 0;
12
+ this.timeoutId = null;
11
13
  }
12
14
 
13
15
  throttle(func, limit) {
14
- let inThrottle = false;
15
16
  return function () {
16
- if (!inThrottle) {
17
- func.apply(this, arguments);
18
- inThrottle = true;
19
- setTimeout(() => {
20
- inThrottle = false;
17
+ const now = Date.now();
18
+ const timeSinceLastInvoke = now - this.lastInvokeTime;
19
+
20
+ if (timeSinceLastInvoke >= limit) {
21
+ func.apply(this, arguments);
22
+ this.lastInvokeTime = now;
23
+ } else if (this.timeoutId != null) {
24
+ clearTimeout(this.timeoutId);
25
+ }
26
+
27
+ this.timeoutId = setTimeout(() => {
28
+ func.apply(this, arguments);
29
+ this.lastInvokeTime = now;
21
30
  }, limit);
22
- }
23
31
  };
24
32
  }
25
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "3.0.9",
3
+ "version": "3.1.1",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"