sirius-common-utils 1.0.11 → 1.0.13

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.
@@ -984,11 +984,47 @@ function closetByClassName(elem, classNameList) {
984
984
  return null;
985
985
  }
986
986
  }
987
+ function offset(node) {
988
+ var offest = {
989
+ top: 0,
990
+ left: 0
991
+ };
992
+ if (!node.getClientRects().length) {
993
+ return offest;
994
+ }
995
+ if (window.getComputedStyle(node)["display"] === "none") {
996
+ return offest;
997
+ }
998
+ offest = node.getBoundingClientRect();
999
+ var docElement = node.ownerDocument.documentElement;
1000
+ return {
1001
+ top: offest.top + window.pageYOffset - docElement.clientTop,
1002
+ left: offest.left + window.pageXOffset - docElement.clientLeft
1003
+ };
1004
+ }
1005
+ function getDomElemMouseRelativePosition(domElem, event, withWindowScrollFlag = false) {
1006
+ let rect = domElem.getBoundingClientRect();
1007
+ let style = getComputedStyle(domElem);
1008
+ let marginLeft = parseInt(style.marginLeft);
1009
+ let marginTop = parseInt(style.marginTop);
1010
+ let scrollX = 0;
1011
+ let scrollY = 0;
1012
+ if (withWindowScrollFlag) {
1013
+ scrollX = window.scrollX || window.pageXOffset;
1014
+ scrollY = window.scrollY || window.pageYOffset;
1015
+ }
1016
+ return {
1017
+ x: event.clientX - rect.left - marginLeft + scrollX,
1018
+ y: event.clientY - rect.top - marginTop + scrollY
1019
+ };
1020
+ }
987
1021
  const DomUtils = {
988
1022
  resetBodyScroll,
989
1023
  forbidBodyScroll,
990
1024
  syncDomAnimation,
991
- closetByClassName
1025
+ closetByClassName,
1026
+ getDomElemMouseRelativePosition,
1027
+ offset
992
1028
  };
993
1029
  function isIOS() {
994
1030
  return [
@@ -985,11 +985,47 @@
985
985
  return null;
986
986
  }
987
987
  }
988
+ function offset(node) {
989
+ var offest = {
990
+ top: 0,
991
+ left: 0
992
+ };
993
+ if (!node.getClientRects().length) {
994
+ return offest;
995
+ }
996
+ if (window.getComputedStyle(node)["display"] === "none") {
997
+ return offest;
998
+ }
999
+ offest = node.getBoundingClientRect();
1000
+ var docElement = node.ownerDocument.documentElement;
1001
+ return {
1002
+ top: offest.top + window.pageYOffset - docElement.clientTop,
1003
+ left: offest.left + window.pageXOffset - docElement.clientLeft
1004
+ };
1005
+ }
1006
+ function getDomElemMouseRelativePosition(domElem, event, withWindowScrollFlag = false) {
1007
+ let rect = domElem.getBoundingClientRect();
1008
+ let style = getComputedStyle(domElem);
1009
+ let marginLeft = parseInt(style.marginLeft);
1010
+ let marginTop = parseInt(style.marginTop);
1011
+ let scrollX = 0;
1012
+ let scrollY = 0;
1013
+ if (withWindowScrollFlag) {
1014
+ scrollX = window.scrollX || window.pageXOffset;
1015
+ scrollY = window.scrollY || window.pageYOffset;
1016
+ }
1017
+ return {
1018
+ x: event.clientX - rect.left - marginLeft + scrollX,
1019
+ y: event.clientY - rect.top - marginTop + scrollY
1020
+ };
1021
+ }
988
1022
  const DomUtils = {
989
1023
  resetBodyScroll,
990
1024
  forbidBodyScroll,
991
1025
  syncDomAnimation,
992
- closetByClassName
1026
+ closetByClassName,
1027
+ getDomElemMouseRelativePosition,
1028
+ offset
993
1029
  };
994
1030
  function isIOS() {
995
1031
  return [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sirius-common-utils",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "./dist/sirius-common-utils.umd.cjs",
6
6
  "module": "./dist/sirius-common-utils.js",