@searchspring/snap-preact-components 0.66.1 → 0.66.3
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/dist/cjs/hooks/useIntersectionAdvanced.d.ts +2 -3
- package/dist/cjs/hooks/useIntersectionAdvanced.d.ts.map +1 -1
- package/dist/cjs/hooks/useIntersectionAdvanced.js +14 -11
- package/dist/cjs/providers/withTracking.d.ts.map +1 -1
- package/dist/cjs/providers/withTracking.js +20 -4
- package/dist/cjs/utilities/createImpressionObserver.d.ts +2 -3
- package/dist/cjs/utilities/createImpressionObserver.d.ts.map +1 -1
- package/dist/cjs/utilities/createImpressionObserver.js +14 -6
- package/dist/esm/hooks/useIntersectionAdvanced.d.ts +2 -3
- package/dist/esm/hooks/useIntersectionAdvanced.d.ts.map +1 -1
- package/dist/esm/hooks/useIntersectionAdvanced.js +14 -2
- package/dist/esm/providers/withTracking.d.ts.map +1 -1
- package/dist/esm/providers/withTracking.js +19 -4
- package/dist/esm/utilities/createImpressionObserver.d.ts +2 -3
- package/dist/esm/utilities/createImpressionObserver.d.ts.map +1 -1
- package/dist/esm/utilities/createImpressionObserver.js +5 -3
- package/package.json +11 -11
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MutableRef } from 'preact/hooks';
|
|
2
|
-
interface UseIntersectionOptions {
|
|
2
|
+
export interface UseIntersectionOptions {
|
|
3
3
|
rootMargin?: string;
|
|
4
4
|
fireOnce?: boolean;
|
|
5
5
|
threshold?: number | number[];
|
|
6
6
|
minVisibleTime?: number;
|
|
7
|
-
|
|
7
|
+
resetKey?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const useIntersectionAdvanced: (ref: MutableRef<HTMLElement | null>, options?: UseIntersectionOptions) => boolean;
|
|
10
|
-
export {};
|
|
11
10
|
//# sourceMappingURL=useIntersectionAdvanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionAdvanced.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIntersectionAdvanced.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,
|
|
1
|
+
{"version":3,"file":"useIntersectionAdvanced.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIntersectionAdvanced.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,uBAAuB,QAAS,WAAW,WAAW,GAAG,IAAI,CAAC,YAAW,sBAAsB,KAAQ,OA+FnH,CAAC"}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.useIntersectionAdvanced = void 0;
|
|
13
4
|
var hooks_1 = require("preact/hooks");
|
|
14
5
|
var useIntersectionAdvanced = function (ref, options) {
|
|
15
6
|
if (options === void 0) { options = {}; }
|
|
16
|
-
var _a = options.rootMargin, rootMargin = _a === void 0 ? '0px' : _a, _b = options.fireOnce, fireOnce = _b === void 0 ? false : _b, _c = options.threshold, threshold = _c === void 0 ? 0 : _c, _d = options.minVisibleTime, minVisibleTime = _d === void 0 ? 0 : _d;
|
|
7
|
+
var _a = options.rootMargin, rootMargin = _a === void 0 ? '0px' : _a, _b = options.fireOnce, fireOnce = _b === void 0 ? false : _b, _c = options.threshold, threshold = _c === void 0 ? 0 : _c, _d = options.minVisibleTime, minVisibleTime = _d === void 0 ? 0 : _d, resetKey = options.resetKey;
|
|
17
8
|
// State and setter for storing whether element is visible
|
|
18
9
|
var _e = (0, hooks_1.useState)(false), isIntersecting = _e[0], setIntersecting = _e[1];
|
|
19
10
|
// Timer reference to track visibility duration
|
|
20
11
|
var visibleTimerRef = (0, hooks_1.useRef)(null);
|
|
21
12
|
// Track when the element started being visible
|
|
22
13
|
var visibleStartRef = (0, hooks_1.useRef)(null);
|
|
14
|
+
// Track the last reset key to detect changes
|
|
15
|
+
var lastResetKeyRef = (0, hooks_1.useRef)(resetKey);
|
|
16
|
+
// Reset state if resetKey has changed
|
|
17
|
+
if (resetKey !== lastResetKeyRef.current) {
|
|
18
|
+
setIntersecting(false);
|
|
19
|
+
if (visibleTimerRef.current) {
|
|
20
|
+
window.clearTimeout(visibleTimerRef.current);
|
|
21
|
+
visibleTimerRef.current = null;
|
|
22
|
+
}
|
|
23
|
+
visibleStartRef.current = null;
|
|
24
|
+
lastResetKeyRef.current = resetKey;
|
|
25
|
+
}
|
|
23
26
|
(0, hooks_1.useEffect)(function () {
|
|
24
27
|
setIntersecting(false);
|
|
25
28
|
var observer = null;
|
|
@@ -79,7 +82,7 @@ var useIntersectionAdvanced = function (ref, options) {
|
|
|
79
82
|
observer.unobserve(ref.current);
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
|
-
},
|
|
85
|
+
}, [ref, resetKey]);
|
|
83
86
|
return isIntersecting;
|
|
84
87
|
};
|
|
85
88
|
exports.useIntersectionAdvanced = useIntersectionAdvanced;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTracking.d.ts","sourceRoot":"","sources":["../../../src/providers/withTracking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIxH,UAAU,iBAAiB;IAC1B,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"withTracking.d.ts","sourceRoot":"","sources":["../../../src/providers/withTracking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIxH,UAAU,iBAAiB;IAC1B,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,4BA8DnG"}
|
|
@@ -28,6 +28,7 @@ var utilities_1 = require("../utilities");
|
|
|
28
28
|
var hooks_1 = require("preact/hooks");
|
|
29
29
|
function withTracking(WrappedComponent) {
|
|
30
30
|
var WithTracking = function (props) {
|
|
31
|
+
var _a;
|
|
31
32
|
var controller = props.controller, result = props.result, restProps = __rest(props, ["controller", "result"]);
|
|
32
33
|
if (!controller) {
|
|
33
34
|
console.warn('Warning: No controller provided to withTracking');
|
|
@@ -35,11 +36,26 @@ function withTracking(WrappedComponent) {
|
|
|
35
36
|
if (!result) {
|
|
36
37
|
console.warn('Warning: No result provided to withTracking');
|
|
37
38
|
}
|
|
38
|
-
var
|
|
39
|
-
if ((controller === null || controller === void 0 ? void 0 : controller.type) === 'autocomplete') {
|
|
40
|
-
|
|
39
|
+
var resetKey;
|
|
40
|
+
if ((controller === null || controller === void 0 ? void 0 : controller.type) === 'search' || (controller === null || controller === void 0 ? void 0 : controller.type) === 'autocomplete') {
|
|
41
|
+
var urlManager = controller.urlManager;
|
|
42
|
+
resetKey = JSON.stringify({
|
|
43
|
+
q: urlManager.state.query,
|
|
44
|
+
p: urlManager.state.page,
|
|
45
|
+
ps: urlManager.state.pageSize,
|
|
46
|
+
s: urlManager.state.sort,
|
|
47
|
+
f: urlManager.state.filter,
|
|
48
|
+
});
|
|
41
49
|
}
|
|
42
|
-
|
|
50
|
+
else if ((controller === null || controller === void 0 ? void 0 : controller.type) === 'recommendation') {
|
|
51
|
+
// For recommendations, use a combination of tag and other relevant state
|
|
52
|
+
var recStore = controller.store;
|
|
53
|
+
resetKey = JSON.stringify({
|
|
54
|
+
tag: (_a = recStore.profile) === null || _a === void 0 ? void 0 : _a.tag,
|
|
55
|
+
ids: recStore.results.map(function (result) { return result.id; }).join(','),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
var _b = (0, utilities_1.createImpressionObserver)({ resetKey: resetKey }), ref = _b.ref, inViewport = _b.inViewport;
|
|
43
59
|
if (inViewport) {
|
|
44
60
|
// TODO: add support for disabling tracking events via config like in ResultTracker
|
|
45
61
|
if ((result === null || result === void 0 ? void 0 : result.type) === 'product') {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Ref } from 'preact/hooks';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}): {
|
|
2
|
+
import { UseIntersectionOptions } from '../hooks';
|
|
3
|
+
export declare function createImpressionObserver(options?: UseIntersectionOptions): {
|
|
5
4
|
ref: Ref<HTMLElement | null>;
|
|
6
5
|
inViewport: boolean;
|
|
7
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createImpressionObserver.d.ts","sourceRoot":"","sources":["../../../src/utilities/createImpressionObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"createImpressionObserver.d.ts","sourceRoot":"","sources":["../../../src/utilities/createImpressionObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAU,MAAM,cAAc,CAAC;AAChD,OAAO,EAA2B,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAI3E,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG;IAC3E,GAAG,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;CACpB,CAYA"}
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.createImpressionObserver = void 0;
|
|
4
15
|
var hooks_1 = require("preact/hooks");
|
|
5
16
|
var hooks_2 = require("../hooks");
|
|
17
|
+
var IMPRESSION_VISIBILITY_THRESHOLD = 0.7;
|
|
18
|
+
var IMPRESSION_MIN_VISIBLE_TIME = 1000;
|
|
6
19
|
function createImpressionObserver(options) {
|
|
7
20
|
var ref = (0, hooks_1.useRef)(null);
|
|
8
|
-
var inViewport = (0, hooks_2.useIntersectionAdvanced)(ref, {
|
|
9
|
-
fireOnce: true,
|
|
10
|
-
threshold: 0.75,
|
|
11
|
-
minVisibleTime: 1000,
|
|
12
|
-
additionalEffectKeys: (options === null || options === void 0 ? void 0 : options.additionalEffectKeys) || [],
|
|
13
|
-
});
|
|
21
|
+
var inViewport = (0, hooks_2.useIntersectionAdvanced)(ref, __assign(__assign({}, options), { fireOnce: true, threshold: IMPRESSION_VISIBILITY_THRESHOLD, minVisibleTime: IMPRESSION_MIN_VISIBLE_TIME }));
|
|
14
22
|
return {
|
|
15
23
|
ref: ref,
|
|
16
24
|
inViewport: inViewport,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { MutableRef } from 'preact/hooks';
|
|
2
|
-
interface UseIntersectionOptions {
|
|
2
|
+
export interface UseIntersectionOptions {
|
|
3
3
|
rootMargin?: string;
|
|
4
4
|
fireOnce?: boolean;
|
|
5
5
|
threshold?: number | number[];
|
|
6
6
|
minVisibleTime?: number;
|
|
7
|
-
|
|
7
|
+
resetKey?: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const useIntersectionAdvanced: (ref: MutableRef<HTMLElement | null>, options?: UseIntersectionOptions) => boolean;
|
|
10
|
-
export {};
|
|
11
10
|
//# sourceMappingURL=useIntersectionAdvanced.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionAdvanced.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIntersectionAdvanced.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,
|
|
1
|
+
{"version":3,"file":"useIntersectionAdvanced.d.ts","sourceRoot":"","sources":["../../../src/hooks/useIntersectionAdvanced.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,uBAAuB,QAAS,WAAW,WAAW,GAAG,IAAI,CAAC,YAAW,sBAAsB,KAAQ,OA+FnH,CAAC"}
|
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { useState, useEffect, useRef } from 'preact/hooks';
|
|
2
2
|
export const useIntersectionAdvanced = (ref, options = {}) => {
|
|
3
|
-
const { rootMargin = '0px', fireOnce = false, threshold = 0, minVisibleTime = 0 } = options;
|
|
3
|
+
const { rootMargin = '0px', fireOnce = false, threshold = 0, minVisibleTime = 0, resetKey } = options;
|
|
4
4
|
// State and setter for storing whether element is visible
|
|
5
5
|
const [isIntersecting, setIntersecting] = useState(false);
|
|
6
6
|
// Timer reference to track visibility duration
|
|
7
7
|
const visibleTimerRef = useRef(null);
|
|
8
8
|
// Track when the element started being visible
|
|
9
9
|
const visibleStartRef = useRef(null);
|
|
10
|
+
// Track the last reset key to detect changes
|
|
11
|
+
const lastResetKeyRef = useRef(resetKey);
|
|
12
|
+
// Reset state if resetKey has changed
|
|
13
|
+
if (resetKey !== lastResetKeyRef.current) {
|
|
14
|
+
setIntersecting(false);
|
|
15
|
+
if (visibleTimerRef.current) {
|
|
16
|
+
window.clearTimeout(visibleTimerRef.current);
|
|
17
|
+
visibleTimerRef.current = null;
|
|
18
|
+
}
|
|
19
|
+
visibleStartRef.current = null;
|
|
20
|
+
lastResetKeyRef.current = resetKey;
|
|
21
|
+
}
|
|
10
22
|
useEffect(() => {
|
|
11
23
|
setIntersecting(false);
|
|
12
24
|
let observer = null;
|
|
@@ -65,6 +77,6 @@ export const useIntersectionAdvanced = (ref, options = {}) => {
|
|
|
65
77
|
observer.unobserve(ref.current);
|
|
66
78
|
}
|
|
67
79
|
};
|
|
68
|
-
}, [ref,
|
|
80
|
+
}, [ref, resetKey]);
|
|
69
81
|
return isIntersecting;
|
|
70
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTracking.d.ts","sourceRoot":"","sources":["../../../src/providers/withTracking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIxH,UAAU,iBAAiB;IAC1B,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"withTracking.d.ts","sourceRoot":"","sources":["../../../src/providers/withTracking.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAK,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIxH,UAAU,iBAAiB;IAC1B,UAAU,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,GAAG,wBAAwB,CAAC;IAClF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,KAAK,SAAS,iBAAiB,EAAE,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC,4BA8DnG"}
|
|
@@ -10,11 +10,26 @@ export function withTracking(WrappedComponent) {
|
|
|
10
10
|
if (!result) {
|
|
11
11
|
console.warn('Warning: No result provided to withTracking');
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
if (controller?.type === 'autocomplete') {
|
|
15
|
-
|
|
13
|
+
let resetKey;
|
|
14
|
+
if (controller?.type === 'search' || controller?.type === 'autocomplete') {
|
|
15
|
+
const urlManager = controller.urlManager;
|
|
16
|
+
resetKey = JSON.stringify({
|
|
17
|
+
q: urlManager.state.query,
|
|
18
|
+
p: urlManager.state.page,
|
|
19
|
+
ps: urlManager.state.pageSize,
|
|
20
|
+
s: urlManager.state.sort,
|
|
21
|
+
f: urlManager.state.filter,
|
|
22
|
+
});
|
|
16
23
|
}
|
|
17
|
-
|
|
24
|
+
else if (controller?.type === 'recommendation') {
|
|
25
|
+
// For recommendations, use a combination of tag and other relevant state
|
|
26
|
+
const recStore = controller.store;
|
|
27
|
+
resetKey = JSON.stringify({
|
|
28
|
+
tag: recStore.profile?.tag,
|
|
29
|
+
ids: recStore.results.map((result) => result.id).join(','),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const { ref, inViewport } = createImpressionObserver({ resetKey });
|
|
18
33
|
if (inViewport) {
|
|
19
34
|
// TODO: add support for disabling tracking events via config like in ResultTracker
|
|
20
35
|
if (result?.type === 'product') {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Ref } from 'preact/hooks';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}): {
|
|
2
|
+
import { UseIntersectionOptions } from '../hooks';
|
|
3
|
+
export declare function createImpressionObserver(options?: UseIntersectionOptions): {
|
|
5
4
|
ref: Ref<HTMLElement | null>;
|
|
6
5
|
inViewport: boolean;
|
|
7
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createImpressionObserver.d.ts","sourceRoot":"","sources":["../../../src/utilities/createImpressionObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"createImpressionObserver.d.ts","sourceRoot":"","sources":["../../../src/utilities/createImpressionObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAU,MAAM,cAAc,CAAC;AAChD,OAAO,EAA2B,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAI3E,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG;IAC3E,GAAG,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;CACpB,CAYA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useRef } from 'preact/hooks';
|
|
2
2
|
import { useIntersectionAdvanced } from '../hooks';
|
|
3
|
+
const IMPRESSION_VISIBILITY_THRESHOLD = 0.7;
|
|
4
|
+
const IMPRESSION_MIN_VISIBLE_TIME = 1000;
|
|
3
5
|
export function createImpressionObserver(options) {
|
|
4
6
|
const ref = useRef(null);
|
|
5
7
|
const inViewport = useIntersectionAdvanced(ref, {
|
|
8
|
+
...options,
|
|
6
9
|
fireOnce: true,
|
|
7
|
-
threshold:
|
|
8
|
-
minVisibleTime:
|
|
9
|
-
additionalEffectKeys: options?.additionalEffectKeys || [],
|
|
10
|
+
threshold: IMPRESSION_VISIBILITY_THRESHOLD,
|
|
11
|
+
minVisibleTime: IMPRESSION_MIN_VISIBLE_TIME,
|
|
10
12
|
});
|
|
11
13
|
return {
|
|
12
14
|
ref,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchspring/snap-preact-components",
|
|
3
|
-
"version": "0.66.
|
|
3
|
+
"version": "0.66.3",
|
|
4
4
|
"description": "Snap Preact Component Library",
|
|
5
5
|
"author": "Searchspring",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@cypress/react": "^8.0.0",
|
|
31
31
|
"@emotion/react": "11.9.0",
|
|
32
|
-
"@searchspring/snap-toolbox": "^0.66.
|
|
32
|
+
"@searchspring/snap-toolbox": "^0.66.3",
|
|
33
33
|
"classnames": "^2.3.2",
|
|
34
34
|
"cypress": "^13.7.1",
|
|
35
35
|
"cypress-wait-until": "^1.7.2",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"@babel/preset-env": "^7.21.4",
|
|
53
53
|
"@babel/preset-react": "^7.18.6",
|
|
54
54
|
"@babel/runtime": "^7.21.0",
|
|
55
|
-
"@searchspring/snap-client": "^0.66.
|
|
56
|
-
"@searchspring/snap-controller": "^0.66.
|
|
57
|
-
"@searchspring/snap-event-manager": "^0.66.
|
|
58
|
-
"@searchspring/snap-logger": "^0.66.
|
|
59
|
-
"@searchspring/snap-profiler": "^0.66.
|
|
60
|
-
"@searchspring/snap-store-mobx": "^0.66.
|
|
61
|
-
"@searchspring/snap-tracker": "^0.66.
|
|
62
|
-
"@searchspring/snap-url-manager": "^0.66.
|
|
55
|
+
"@searchspring/snap-client": "^0.66.3",
|
|
56
|
+
"@searchspring/snap-controller": "^0.66.3",
|
|
57
|
+
"@searchspring/snap-event-manager": "^0.66.3",
|
|
58
|
+
"@searchspring/snap-logger": "^0.66.3",
|
|
59
|
+
"@searchspring/snap-profiler": "^0.66.3",
|
|
60
|
+
"@searchspring/snap-store-mobx": "^0.66.3",
|
|
61
|
+
"@searchspring/snap-tracker": "^0.66.3",
|
|
62
|
+
"@searchspring/snap-url-manager": "^0.66.3",
|
|
63
63
|
"@storybook/addon-actions": "6.4.22",
|
|
64
64
|
"@storybook/addon-controls": "6.4.22",
|
|
65
65
|
"@storybook/addon-docs": "6.4.22",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"webpack-merge": "^5.8.0"
|
|
85
85
|
},
|
|
86
86
|
"sideEffects": false,
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "200c5a8f94b21f28c3c440917650665a516fd9c6"
|
|
88
88
|
}
|