@g4rcez/components 2.2.1 → 2.2.2

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/lib/dom.d.ts CHANGED
@@ -15,4 +15,5 @@ export declare const getCoords: (elem: HTMLElement, docEl: HTMLElement) => {
15
15
  top: number;
16
16
  left: number;
17
17
  };
18
+ export declare const isChildVisible: (container: HTMLElement, child: HTMLElement, partial?: boolean) => boolean;
18
19
  //# sourceMappingURL=dom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/lib/dom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3D,eAAO,MAAM,SAAS,GACjB,CAAC,EAAE,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KAAG,WAAW,CAAC,CAAC,CAS3E,CAAC;AAEN,eAAO,MAAM,gBAAgB,GAAI,GAAG,GAAG,KAAG,CAAC,IAAI,KAAK,CAAC,YAQpD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,GAAG,GAAG,gCAAmB,CAAC;AAEpD,eAAO,MAAM,GAAG,GAAI,GAAG,QAAQ,UAAU,EAAE,WAA0B,CAAC;AAEtE,eAAO,MAAM,aAAa,GAAI,OAAO,gBAAgB,GAAG,SAAS,GAAG,IAAI;;;CAIvE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,gBAAgB,GAAG,mBAAmB,GAAG,iBAAiB,eAIvG,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,WAAW,YAAwD,CAAC;AAEnH,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,EAAE,YAAY,MA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Coords = (elem, docEl) => {
42
42
  const parent = docEl.getBoundingClientRect();
43
43
  return { top: Math.round(box.top - parent.top), left: Math.round(box.left - parent.left) };
44
44
  };
45
+ export const isChildVisible = (container, child, partial = true) => {
46
+ const containerRect = container.getBoundingClientRect();
47
+ const childRect = child.getBoundingClientRect();
48
+ const isWithinTop = childRect.top >= containerRect.top;
49
+ const isWithinBottom = childRect.bottom <= containerRect.bottom;
50
+ const isWithinLeft = childRect.left >= containerRect.left;
51
+ const isWithinRight = childRect.right <= containerRect.right;
52
+ if (partial) {
53
+ return (childRect.top < containerRect.bottom &&
54
+ childRect.bottom > containerRect.top &&
55
+ childRect.left < containerRect.right &&
56
+ childRect.right > containerRect.left);
57
+ }
58
+ return isWithinTop && isWithinBottom && isWithinLeft && isWithinRight;
59
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@g4rcez/components",
3
3
  "description": "Customizable react components.",
4
- "version": "2.2.1",
4
+ "version": "2.2.2",
5
5
  "sideEffects": false,
6
6
  "private": false,
7
7
  "packageManager": "pnpm@10.12.3",