@folklore/hooks 0.0.28 → 0.0.29

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.js CHANGED
@@ -1038,10 +1038,11 @@ const useObserver = function (Observer) {
1038
1038
  const {
1039
1039
  root = null,
1040
1040
  rootMargin = null,
1041
- threshold = null,
1041
+ threshold: defaultThreshold = null,
1042
1042
  disabled = false
1043
1043
  } = opts;
1044
1044
  const [entry, setEntry] = react.useState(initialEntry);
1045
+ const threshold = react.useMemo(() => defaultThreshold, [defaultThreshold]);
1045
1046
  const nodeRef = react.useRef(null);
1046
1047
  const currentElement = react.useRef(null);
1047
1048
  const elementChanged = nodeRef.current !== currentElement.current;
@@ -1093,6 +1094,7 @@ const useObserver = function (Observer) {
1093
1094
  * Intersection Observer
1094
1095
  */
1095
1096
 
1097
+ const defaultThreshold = [0, 1.0];
1096
1098
  const intersectionObserverInitialEntry = {
1097
1099
  target: null,
1098
1100
  time: null,
@@ -1107,7 +1109,7 @@ const useIntersectionObserver = function () {
1107
1109
  let {
1108
1110
  root = null,
1109
1111
  rootMargin = '0px',
1110
- threshold = [0, 1.0],
1112
+ threshold = defaultThreshold,
1111
1113
  disabled = false
1112
1114
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1113
1115
  return useObserver(IntersectionObserver, {
package/dist/es.js CHANGED
@@ -1027,10 +1027,11 @@ const useObserver = function (Observer) {
1027
1027
  const {
1028
1028
  root = null,
1029
1029
  rootMargin = null,
1030
- threshold = null,
1030
+ threshold: defaultThreshold = null,
1031
1031
  disabled = false
1032
1032
  } = opts;
1033
1033
  const [entry, setEntry] = useState(initialEntry);
1034
+ const threshold = useMemo(() => defaultThreshold, [defaultThreshold]);
1034
1035
  const nodeRef = useRef(null);
1035
1036
  const currentElement = useRef(null);
1036
1037
  const elementChanged = nodeRef.current !== currentElement.current;
@@ -1082,6 +1083,7 @@ const useObserver = function (Observer) {
1082
1083
  * Intersection Observer
1083
1084
  */
1084
1085
 
1086
+ const defaultThreshold = [0, 1.0];
1085
1087
  const intersectionObserverInitialEntry = {
1086
1088
  target: null,
1087
1089
  time: null,
@@ -1096,7 +1098,7 @@ const useIntersectionObserver = function () {
1096
1098
  let {
1097
1099
  root = null,
1098
1100
  rootMargin = '0px',
1099
- threshold = [0, 1.0],
1101
+ threshold = defaultThreshold,
1100
1102
  disabled = false
1101
1103
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1102
1104
  return useObserver(IntersectionObserver, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folklore/hooks",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "React hooks",
5
5
  "keywords": [
6
6
  "javascript",
@@ -48,7 +48,7 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "a8406b4ff188934ed49c13826cf577968669ed4e",
51
+ "gitHead": "61748b478ab945f855a51499efb51c0cbcf3d880",
52
52
  "dependencies": {
53
53
  "@folklore/events": "^0.0.3",
54
54
  "@folklore/services": "^0.1.36",