sirius-common-utils 1.0.12 → 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,13 +984,35 @@ function closetByClassName(elem, classNameList) {
|
|
|
984
984
|
return null;
|
|
985
985
|
}
|
|
986
986
|
}
|
|
987
|
-
function
|
|
988
|
-
var
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
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
|
+
}
|
|
994
1016
|
return {
|
|
995
1017
|
x: event.clientX - rect.left - marginLeft + scrollX,
|
|
996
1018
|
y: event.clientY - rect.top - marginTop + scrollY
|
|
@@ -1001,7 +1023,8 @@ const DomUtils = {
|
|
|
1001
1023
|
forbidBodyScroll,
|
|
1002
1024
|
syncDomAnimation,
|
|
1003
1025
|
closetByClassName,
|
|
1004
|
-
getDomElemMouseRelativePosition
|
|
1026
|
+
getDomElemMouseRelativePosition,
|
|
1027
|
+
offset
|
|
1005
1028
|
};
|
|
1006
1029
|
function isIOS() {
|
|
1007
1030
|
return [
|
|
@@ -985,13 +985,35 @@
|
|
|
985
985
|
return null;
|
|
986
986
|
}
|
|
987
987
|
}
|
|
988
|
-
function
|
|
989
|
-
var
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
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
|
+
}
|
|
995
1017
|
return {
|
|
996
1018
|
x: event.clientX - rect.left - marginLeft + scrollX,
|
|
997
1019
|
y: event.clientY - rect.top - marginTop + scrollY
|
|
@@ -1002,7 +1024,8 @@
|
|
|
1002
1024
|
forbidBodyScroll,
|
|
1003
1025
|
syncDomAnimation,
|
|
1004
1026
|
closetByClassName,
|
|
1005
|
-
getDomElemMouseRelativePosition
|
|
1027
|
+
getDomElemMouseRelativePosition,
|
|
1028
|
+
offset
|
|
1006
1029
|
};
|
|
1007
1030
|
function isIOS() {
|
|
1008
1031
|
return [
|