element-position
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -7,50 +7,50 @@ (function (global, factory) { | ||
var Offset = { | ||
getNestedOffset: function (el) { | ||
var left = el.offsetLeft, top = el.offsetTop, right = el.offsetLeft + el.offsetWidth, bottom = el.offsetTop + el.offsetHeight; | ||
while (el = el.offsetParent) { | ||
left += el.offsetLeft; | ||
top += el.offsetTop; | ||
right += el.offsetLeft; | ||
bottom += el.offsetTop; | ||
} | ||
return { | ||
left: left, | ||
top: top, | ||
right: right, | ||
bottom: bottom | ||
}; | ||
function getNestedOffset(el) { | ||
var left = el.offsetLeft, top = el.offsetTop, right = el.offsetLeft + el.offsetWidth, bottom = el.offsetTop + el.offsetHeight; | ||
while (el = el.offsetParent) { | ||
left += el.offsetLeft; | ||
top += el.offsetTop; | ||
right += el.offsetLeft; | ||
bottom += el.offsetTop; | ||
} | ||
}; | ||
return { | ||
left: left, | ||
top: top, | ||
right: right, | ||
bottom: bottom | ||
}; | ||
} | ||
var Scroll = { | ||
getNestedScroll: function (el) { | ||
var x = 0, y = 0; | ||
while (el = el.parentElement) { | ||
x += el.scrollLeft; | ||
y += el.scrollTop; | ||
} | ||
return { | ||
x: x, | ||
y: y | ||
}; | ||
function getNestedScroll(el) { | ||
var x = 0, y = 0; | ||
while (el = el.parentElement) { | ||
x += el.scrollLeft; | ||
y += el.scrollTop; | ||
} | ||
}; | ||
return { | ||
x: x, | ||
y: y | ||
}; | ||
} | ||
var Coordinates = { | ||
getCoordinates: function (el) { | ||
var offset = Offset.getNestedOffset(el), scroll = Scroll.getNestedScroll(el); | ||
return { | ||
left: (offset.left - scroll.x), | ||
top: (offset.top - scroll.y), | ||
right: (offset.right - scroll.x), | ||
bottom: (offset.bottom - scroll.y) | ||
}; | ||
} | ||
function getCoordinates(el) { | ||
var offset = getNestedOffset(el), scroll = getNestedScroll(el); | ||
return { | ||
left: (offset.left - scroll.x), | ||
top: (offset.top - scroll.y), | ||
right: (offset.right - scroll.x), | ||
bottom: (offset.bottom - scroll.y) | ||
}; | ||
} | ||
var ComputePosition = { | ||
getNestedOffset: getNestedOffset, | ||
getNestedScroll: getNestedScroll, | ||
getCoordinates: getCoordinates | ||
}; | ||
var main = { | ||
getNestedOffset: Offset.getNestedOffset, | ||
getNestedScroll: Scroll.getNestedScroll, | ||
getCoordinates: Coordinates.getCoordinates | ||
getNestedOffset: ComputePosition.getNestedOffset, | ||
getNestedScroll: ComputePosition.getNestedScroll, | ||
getCoordinates: ComputePosition.getCoordinates | ||
}; | ||
@@ -57,0 +57,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ElementPosition=e()}(this,function(){"use strict";var f={getNestedOffset:function(t){for(var e=t.offsetLeft,o=t.offsetTop,f=t.offsetLeft+t.offsetWidth,s=t.offsetTop+t.offsetHeight;t=t.offsetParent;)e+=t.offsetLeft,o+=t.offsetTop,f+=t.offsetLeft,s+=t.offsetTop;return{left:e,top:o,right:f,bottom:s}}},s={getNestedScroll:function(t){for(var e=0,o=0;t=t.parentElement;)e+=t.scrollLeft,o+=t.scrollTop;return{x:e,y:o}}},t={getCoordinates:function(t){var e=f.getNestedOffset(t),o=s.getNestedScroll(t);return{left:e.left-o.x,top:e.top-o.y,right:e.right-o.x,bottom:e.bottom-o.y}}};return{getNestedOffset:f.getNestedOffset,getNestedScroll:s.getNestedScroll,getCoordinates:t.getCoordinates}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ElementPosition=e()}(this,function(){"use strict";function f(t){for(var e=t.offsetLeft,o=t.offsetTop,f=t.offsetLeft+t.offsetWidth,s=t.offsetTop+t.offsetHeight;t=t.offsetParent;)e+=t.offsetLeft,o+=t.offsetTop,f+=t.offsetLeft,s+=t.offsetTop;return{left:e,top:o,right:f,bottom:s}}function s(t){for(var e=0,o=0;t=t.parentElement;)e+=t.scrollLeft,o+=t.scrollTop;return{x:e,y:o}}var t={getNestedOffset:f,getNestedScroll:s,getCoordinates:function(t){var e=f(t),o=s(t);return{left:e.left-o.x,top:e.top-o.y,right:e.right-o.x,bottom:e.bottom-o.y}}};return{getNestedOffset:t.getNestedOffset,getNestedScroll:t.getNestedScroll,getCoordinates:t.getCoordinates}}); |
{ | ||
"name": "element-position", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Calculates the position of the DOM.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.min.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9039
75