@patternfly/pfe-core 2.0.0-next.10 → 2.0.0-next.11

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.
@@ -0,0 +1,12 @@
1
+ /**
2
+ * This function returns whether or not an element is within the viewable area of a container. If partial is true,
3
+ * then this function will return true even if only part of the element is in view.
4
+ *
5
+ * @param container The container to check if the element is in view of.
6
+ * @param element The element to check if it is view
7
+ * @param partial true if partial view is allowed
8
+ * @param strict true if strict mode is set, never consider the container width and element width
9
+ *
10
+ * @returns True if the component is in View.
11
+ */
12
+ export declare function isElementInView(container: HTMLElement, element: HTMLElement, partial?: boolean, strict?: boolean): boolean;
@@ -0,0 +1,2 @@
1
+ function d(s,c,a=!1,r=!1){if(!s||!c)return!1;let t=s.getBoundingClientRect(),n=c.getBoundingClientRect(),e=Math.ceil(t.left),o=Math.floor(t.right),i=Math.ceil(n.left),l=Math.floor(n.right),f=i>=e&&l<=o,u=(a||!r&&t.width<n.width)&&(i<e&&l>e||l>o&&i<o);return f||u}export{d as isElementInView};
2
+ //# sourceMappingURL=isElementInView.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["isElementInView.ts"],
4
+ "sourcesContent": ["/**\n * This function returns whether or not an element is within the viewable area of a container. If partial is true,\n * then this function will return true even if only part of the element is in view.\n *\n * @param container The container to check if the element is in view of.\n * @param element The element to check if it is view\n * @param partial true if partial view is allowed\n * @param strict true if strict mode is set, never consider the container width and element width\n *\n * @returns True if the component is in View.\n */\nexport function isElementInView(\n container: HTMLElement,\n element: HTMLElement,\n partial = false,\n strict = false\n): boolean {\n if (!container || !element) {\n return false;\n }\n const containerBounds = container.getBoundingClientRect();\n const elementBounds = element.getBoundingClientRect();\n const containerBoundsLeft = Math.ceil(containerBounds.left);\n const containerBoundsRight = Math.floor(containerBounds.right);\n const elementBoundsLeft = Math.ceil(elementBounds.left);\n const elementBoundsRight = Math.floor(elementBounds.right);\n\n // Check if in view\n const isTotallyInView =\n elementBoundsLeft >= containerBoundsLeft &&\n elementBoundsRight <= containerBoundsRight;\n const isPartiallyInView =\n (partial || (!strict && containerBounds.width < elementBounds.width)) &&\n ((elementBoundsLeft < containerBoundsLeft && elementBoundsRight > containerBoundsLeft) ||\n (elementBoundsRight > containerBoundsRight && elementBoundsLeft < containerBoundsRight));\n\n // Return outcome\n return isTotallyInView || isPartiallyInView;\n}\n"],
5
+ "mappings": "AAWO,SAASA,EACdC,EACAC,EACAC,EAAU,GACVC,EAAS,GACA,CACT,GAAI,CAACH,GAAa,CAACC,EACjB,MAAO,GAET,IAAMG,EAAkBJ,EAAU,sBAAsB,EAClDK,EAAgBJ,EAAQ,sBAAsB,EAC9CK,EAAsB,KAAK,KAAKF,EAAgB,IAAI,EACpDG,EAAuB,KAAK,MAAMH,EAAgB,KAAK,EACvDI,EAAoB,KAAK,KAAKH,EAAc,IAAI,EAChDI,EAAqB,KAAK,MAAMJ,EAAc,KAAK,EAGnDK,EACJF,GAAqBF,GACrBG,GAAsBF,EAClBI,GACHT,GAAY,CAACC,GAAUC,EAAgB,MAAQC,EAAc,SAC5DG,EAAoBF,GAAuBG,EAAqBH,GAC/DG,EAAqBF,GAAwBC,EAAoBD,GAGtE,OAAOG,GAAmBC,CAC5B",
6
+ "names": ["isElementInView", "container", "element", "partial", "strict", "containerBounds", "elementBounds", "containerBoundsLeft", "containerBoundsRight", "elementBoundsLeft", "elementBoundsRight", "isTotallyInView", "isPartiallyInView"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/pfe-core",
3
- "version": "2.0.0-next.10",
3
+ "version": "2.0.0-next.11",
4
4
  "license": "MIT",
5
5
  "description": "PatternFly Elements Core Library",
6
6
  "customElements": "custom-elements.json",
@@ -34,7 +34,8 @@
34
34
  "./decorators/trace.js": "./decorators/trace.js",
35
35
  "./functions/debounce.js": "./functions/debounce.js",
36
36
  "./functions/deprecatedCustomEvent.js": "./functions/deprecatedCustomEvent.js",
37
- "./functions/random.js": "./functions/random.js"
37
+ "./functions/random.js": "./functions/random.js",
38
+ "./functions/isElementInView.js": "./functions/isElementInView.js"
38
39
  },
39
40
  "publishConfig": {
40
41
  "access": "public",