Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo-mod-jslibs-dist.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'popperjs/package/dist/esm/dom-utils/getLayoutRect.js')
-rw-r--r--popperjs/package/dist/esm/dom-utils/getLayoutRect.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/popperjs/package/dist/esm/dom-utils/getLayoutRect.js b/popperjs/package/dist/esm/dom-utils/getLayoutRect.js
new file mode 100644
index 0000000..c3b421e
--- /dev/null
+++ b/popperjs/package/dist/esm/dom-utils/getLayoutRect.js
@@ -0,0 +1,25 @@
+import getBoundingClientRect from "./getBoundingClientRect.js"; // Returns the layout rect of an element relative to its offsetParent. Layout
+// means it doesn't take into account transforms.
+
+export default function getLayoutRect(element) {
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
+
+ var width = element.offsetWidth;
+ var height = element.offsetHeight;
+
+ if (Math.abs(clientRect.width - width) <= 1) {
+ width = clientRect.width;
+ }
+
+ if (Math.abs(clientRect.height - height) <= 1) {
+ height = clientRect.height;
+ }
+
+ return {
+ x: element.offsetLeft,
+ y: element.offsetTop,
+ width: width,
+ height: height
+ };
+} \ No newline at end of file