@thecb/components 7.7.8-beta.4 → 7.7.8-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "7.7.8-beta.4",
3
+ "version": "7.7.8-beta.5",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -4,14 +4,11 @@ import { useEffect, useState } from "react";
4
4
  Hook that determines whether every element in an array of DOM selectors is fully present
5
5
  within the user's current viewport.
6
6
 
7
- (elements: Array<String>, Function) => undefined;
7
+ (elements: Array<String>) => Boolean;
8
8
 
9
9
  Takes an array of strings that correspond to DOM selectors. Examples:
10
10
  "#submit-button", ".module-small", "h2.alert-title"
11
11
 
12
- Also takes a handler function (such as a useState updater) to receive the Boolean
13
- that the hook generates
14
-
15
12
  The document query function will return the *first* element in the document that matches
16
13
  the string given.
17
14
 
@@ -21,11 +18,9 @@ import { useEffect, useState } from "react";
21
18
  This will return the first element that matches *any* of the provided selectors
22
19
 
23
20
  If every element in the array is fully within the viewport, function returns true
24
-
25
- Calls the provided handler function with the Boolean result
26
21
  */
27
22
 
28
- const useCheckElementsInViewport = (elements = [], handler) => {
23
+ const useCheckElementsInViewport = (elements = []) => {
29
24
  const [elementsVisible, setElementsVisible] = useState(false);
30
25
  const viewportWidth =
31
26
  window.innerWidth || document.documentElement.clientWidth;
@@ -48,7 +43,7 @@ const useCheckElementsInViewport = (elements = [], handler) => {
48
43
  });
49
44
  }, [elements, viewportWidth, viewportHeight]);
50
45
 
51
- handler(elementsVisible);
46
+ return elementsVisible;
52
47
  };
53
48
 
54
49
  export default useCheckElementsInViewport;