plotline-engage 3.0.8 → 3.1.0
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/index.d.ts +7 -1
- package/index.js +15 -7
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -9,5 +9,11 @@ declare class plotline {
|
|
|
9
9
|
debug(): void;
|
|
10
10
|
notifyScroll(): void;
|
|
11
11
|
}
|
|
12
|
+
declare class PScrollView extends React.Component<ScrollViewProps> {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare class PFlatList<T> extends React.Component<FlatListProps<T>> {
|
|
16
|
+
}
|
|
12
17
|
declare const Plotline: plotline;
|
|
13
|
-
export
|
|
18
|
+
export { PScrollView, PFlatList };
|
|
19
|
+
export default Plotline;
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|