@parafin/react 7.2.0 → 7.2.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/out/index.js +12 -2
- package/package.json +2 -2
package/out/index.js
CHANGED
|
@@ -139,6 +139,7 @@ const emptyMetadata = {
|
|
|
139
139
|
const initializeParafinWidget = (iframe, props) => {
|
|
140
140
|
let initStartTime = Date.now();
|
|
141
141
|
let hasLoadedOnce = false;
|
|
142
|
+
let wasEverHidden = document.hidden;
|
|
142
143
|
// @ts-ignore
|
|
143
144
|
const url = new URL(props.widgetUrlOverride ?? 'https://widget.parafin.com');
|
|
144
145
|
const query = {
|
|
@@ -218,7 +219,7 @@ const initializeParafinWidget = (iframe, props) => {
|
|
|
218
219
|
}
|
|
219
220
|
break;
|
|
220
221
|
case 'widget-load-complete':
|
|
221
|
-
if (props.onEvent && !hasLoadedOnce) {
|
|
222
|
+
if (props.onEvent && !hasLoadedOnce && !wasEverHidden) {
|
|
222
223
|
const timeToLoadInMs = Date.now() - initStartTime;
|
|
223
224
|
props.onEvent('widget_loaded', { timeToLoadInMs });
|
|
224
225
|
}
|
|
@@ -227,8 +228,17 @@ const initializeParafinWidget = (iframe, props) => {
|
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
};
|
|
231
|
+
const visibilityHandler = () => {
|
|
232
|
+
if (document.hidden) {
|
|
233
|
+
wasEverHidden = true;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
230
236
|
window.addEventListener('message', messageListener);
|
|
231
|
-
|
|
237
|
+
document.addEventListener('visibilitychange', visibilityHandler);
|
|
238
|
+
return () => {
|
|
239
|
+
window.removeEventListener('message', messageListener);
|
|
240
|
+
document.removeEventListener('visibilitychange', visibilityHandler);
|
|
241
|
+
};
|
|
232
242
|
};
|
|
233
243
|
|
|
234
244
|
const ParafinWidget = (props) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parafin/react",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.1",
|
|
4
4
|
"description": "Parafin React widget",
|
|
5
5
|
"author": "Parafin (https://www.parafin.com)",
|
|
6
6
|
"main": "./out/index.js",
|
|
@@ -34,6 +34,6 @@
|
|
|
34
34
|
"typescript": "^4.9.5"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@parafin/core": "^3.2.
|
|
37
|
+
"@parafin/core": "^3.2.1"
|
|
38
38
|
}
|
|
39
39
|
}
|