@artsy/palette-charts 39.0.0-canary.1408.31249.0 → 39.0.0-canary.1408.31348.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.
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useIntersectionObserver = void 0;
|
|
7
|
+
var _palette = require("@artsy/palette");
|
|
7
8
|
var _react = require("react");
|
|
8
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
10
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -21,6 +22,7 @@ var useIntersectionObserver = function useIntersectionObserver(_ref) {
|
|
|
21
22
|
} : _ref$options,
|
|
22
23
|
onIntersection = _ref.onIntersection,
|
|
23
24
|
onOffIntersection = _ref.onOffIntersection;
|
|
25
|
+
var isClient = (0, _palette.useDidMount)();
|
|
24
26
|
var ref = (0, _react.useRef)(null);
|
|
25
27
|
var handleIntersect = function handleIntersect(entries) {
|
|
26
28
|
if (!observer) return;
|
|
@@ -47,7 +49,7 @@ var useIntersectionObserver = function useIntersectionObserver(_ref) {
|
|
|
47
49
|
onIntersection === null || onIntersection === void 0 ? void 0 : onIntersection(entries);
|
|
48
50
|
};
|
|
49
51
|
var _useState = (0, _react.useState)(function () {
|
|
50
|
-
return
|
|
52
|
+
return isClient ? new IntersectionObserver(handleIntersect, options) : undefined;
|
|
51
53
|
}),
|
|
52
54
|
_useState2 = _slicedToArray(_useState, 1),
|
|
53
55
|
observer = _useState2[0];
|
|
@@ -63,5 +65,4 @@ var useIntersectionObserver = function useIntersectionObserver(_ref) {
|
|
|
63
65
|
};
|
|
64
66
|
};
|
|
65
67
|
exports.useIntersectionObserver = useIntersectionObserver;
|
|
66
|
-
var isClientSide = typeof window !== "undefined";
|
|
67
68
|
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionObserver.js","names":["
|
|
1
|
+
{"version":3,"file":"useIntersectionObserver.js","names":["_palette","require","_react","_slicedToArray","arr","i","_arrayWithHoles","_iterableToArrayLimit","_unsupportedIterableToArray","_nonIterableRest","TypeError","o","minLen","_arrayLikeToArray","n","Object","prototype","toString","call","slice","constructor","name","Array","from","test","len","length","arr2","_i","Symbol","iterator","_s","_e","_x","_r","_arr","_n","_d","next","done","push","value","err","return","isArray","useIntersectionObserver","_ref","_ref$once","once","_ref$options","options","threshold","onIntersection","onOffIntersection","isClient","useDidMount","ref","useRef","handleIntersect","entries","observer","hasIntersected","some","_ref2","isIntersecting","disconnect","_useState","useState","IntersectionObserver","undefined","_useState2","useEffect","current","observe","exports"],"sources":["../../../src/elements/DataVis/useIntersectionObserver.ts"],"sourcesContent":["import { useDidMount } from \"@artsy/palette\"\nimport { RefObject, useEffect, useRef, useState } from \"react\"\n\ninterface UseIntersectionObserverProperties {\n ref?: RefObject<Element> | null\n once?: boolean\n options?: {\n threshold: number | number[]\n root?: Element\n rootMargin?: string\n }\n onIntersection?: (entries: IntersectionObserverEntry[]) => void\n onOffIntersection?: (entries: IntersectionObserverEntry[]) => void\n}\n\n// tslint:disable-next-line:completed-docs\nexport const useIntersectionObserver = ({\n once = true,\n options = { threshold: 0 },\n onIntersection,\n onOffIntersection,\n}: UseIntersectionObserverProperties) => {\n const isClient = useDidMount()\n\n const ref = useRef<HTMLElement | null>(null)\n\n const handleIntersect = (entries: IntersectionObserverEntry[]) => {\n if (!observer) return\n\n if (once) {\n const hasIntersected = entries.some(\n // tslint:disable-next-line:no-shadowed-variable\n ({ isIntersecting }) => isIntersecting\n )\n\n if (hasIntersected) {\n onIntersection?.(entries)\n observer.disconnect()\n } else {\n onOffIntersection?.(entries)\n }\n\n return\n }\n\n const isIntersecting = entries[entries.length - 1].isIntersecting\n\n if (!isIntersecting) {\n onOffIntersection?.(entries)\n return\n }\n\n onIntersection?.(entries)\n }\n\n const [observer] = useState(() =>\n isClient ? new IntersectionObserver(handleIntersect, options) : undefined\n )\n\n useEffect(() => {\n if (!ref.current || !observer) return\n\n observer.observe(ref.current)\n\n return () => {\n observer.disconnect()\n }\n }, [ref, observer])\n\n return { ref }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA8D,SAAAE,eAAAC,GAAA,EAAAC,CAAA,WAAAC,eAAA,CAAAF,GAAA,KAAAG,qBAAA,CAAAH,GAAA,EAAAC,CAAA,KAAAG,2BAAA,CAAAJ,GAAA,EAAAC,CAAA,KAAAI,gBAAA;AAAA,SAAAA,iBAAA,cAAAC,SAAA;AAAA,SAAAF,4BAAAG,CAAA,EAAAC,MAAA,SAAAD,CAAA,qBAAAA,CAAA,sBAAAE,iBAAA,CAAAF,CAAA,EAAAC,MAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,CAAAC,QAAA,CAAAC,IAAA,CAAAP,CAAA,EAAAQ,KAAA,aAAAL,CAAA,iBAAAH,CAAA,CAAAS,WAAA,EAAAN,CAAA,GAAAH,CAAA,CAAAS,WAAA,CAAAC,IAAA,MAAAP,CAAA,cAAAA,CAAA,mBAAAQ,KAAA,CAAAC,IAAA,CAAAZ,CAAA,OAAAG,CAAA,+DAAAU,IAAA,CAAAV,CAAA,UAAAD,iBAAA,CAAAF,CAAA,EAAAC,MAAA;AAAA,SAAAC,kBAAAT,GAAA,EAAAqB,GAAA,QAAAA,GAAA,YAAAA,GAAA,GAAArB,GAAA,CAAAsB,MAAA,EAAAD,GAAA,GAAArB,GAAA,CAAAsB,MAAA,WAAArB,CAAA,MAAAsB,IAAA,OAAAL,KAAA,CAAAG,GAAA,GAAApB,CAAA,GAAAoB,GAAA,EAAApB,CAAA,MAAAsB,IAAA,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CAACgB,OAAO,IAAI,CAACZ,QAAQ,EAAE;IAE/BA,QAAQ,CAACa,OAAO,CAACjB,GAAG,CAACgB,OAAO,CAAC;IAE7B,OAAO,YAAM;MACXZ,QAAQ,CAACK,UAAU,EAAE;IACvB,CAAC;EACH,CAAC,EAAE,CAACT,GAAG,EAAEI,QAAQ,CAAC,CAAC;EAEnB,OAAO;IAAEJ,GAAG,EAAHA;EAAI,CAAC;AAChB,CAAC;AAAAkB,OAAA,CAAA7B,uBAAA,GAAAA,uBAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artsy/palette-charts",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "39.0.0-canary.1408.
|
|
4
|
+
"version": "39.0.0-canary.1408.31348.0",
|
|
5
5
|
"description": "Design system library for react components",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"publishConfig": {
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"typescript-styled-plugin": "0.10.0"
|
|
115
115
|
},
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"@artsy/palette": "40.0.0-canary.1408.
|
|
117
|
+
"@artsy/palette": "40.0.0-canary.1408.31348.0",
|
|
118
118
|
"@seznam/compose-react-refs": "^1.0.6",
|
|
119
119
|
"@styled-system/theme-get": "^5.1.2",
|
|
120
120
|
"d3-interpolate": "^1.3.2",
|
|
@@ -179,5 +179,5 @@
|
|
|
179
179
|
"url": "http://localhost"
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
"gitHead": "
|
|
182
|
+
"gitHead": "e97f1fbcc2508cd4dda7e142c85fd030c8bf7759"
|
|
183
183
|
}
|