element-position
Advanced tools
Comparing version 0.1.9 to 0.2.3
@@ -1,2 +0,2 @@ | ||
declare namespace Position { | ||
declare namespace ElementPosition { | ||
function getNestedOffset(el: HTMLElement): { | ||
@@ -8,2 +8,3 @@ top: number, | ||
} | ||
function getNestedScroll(el: HTMLElement): { | ||
@@ -13,2 +14,3 @@ x: number, | ||
} | ||
function getAbsolute(el: HTMLElement): { | ||
@@ -20,3 +22,6 @@ top: number, | ||
} | ||
function maxZIndex(el: HTMLElement): number; | ||
} | ||
export = Position; | ||
export = ElementPosition; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.Position = factory()); | ||
(global.ElementPosition = factory()); | ||
}(this, (function () { 'use strict'; | ||
@@ -51,6 +51,22 @@ | ||
var PROPERTY_NAME = 'z-index'; | ||
var Z_INDEX = { | ||
maxZIndex: function (el) { | ||
var maxZIndex = 0, elements = [el]; | ||
while (elements.length) { | ||
var zIndex = Number(window | ||
.getComputedStyle(el = elements.pop()) | ||
.getPropertyValue(PROPERTY_NAME)); | ||
zIndex > maxZIndex && (maxZIndex = zIndex); | ||
elements.concat(Array.prototype.slice.call(el.children)); | ||
} | ||
return maxZIndex; | ||
} | ||
}; | ||
var main = { | ||
getNestedOffset: OFFSET.getNestedOffset, | ||
getNestedScroll: SCROLL.getNestedScroll, | ||
getAbsolute: ABSOLUTE.getAbsolute | ||
getAbsolute: ABSOLUTE.getAbsolute, | ||
maxZIndex: Z_INDEX.maxZIndex | ||
}; | ||
@@ -57,0 +73,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.Position=e()}(this,function(){"use strict";var o={getNestedOffset:function(t){for(var e=t.offsetLeft,f=t.offsetTop,o=t.offsetLeft+t.offsetWidth,s=t.offsetTop+t.offsetHeight;t=t.offsetParent;)e+=t.offsetLeft,f+=t.offsetTop,o+=t.offsetLeft,s+=t.offsetTop;return{left:e,top:f,right:o,bottom:s}}},s={getNestedScroll:function(t){for(var e=0,f=0;t=t.parentElement;)e+=t.scrollLeft,f+=t.scrollTop;return{x:e,y:f}}},t={getAbsolute:function(t){var e=o.getNestedOffset(t),f=s.getNestedScroll(t);return{left:e.left-f.x,top:e.top-f.y,right:e.right-f.x,bottom:e.bottom-f.y}}};return{getNestedOffset:o.getNestedOffset,getNestedScroll:s.getNestedScroll,getAbsolute:t.getAbsolute}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.ElementPosition=t()}(this,function(){"use strict";var f={getNestedOffset:function(e){for(var t=e.offsetLeft,o=e.offsetTop,f=e.offsetLeft+e.offsetWidth,r=e.offsetTop+e.offsetHeight;e=e.offsetParent;)t+=e.offsetLeft,o+=e.offsetTop,f+=e.offsetLeft,r+=e.offsetTop;return{left:t,top:o,right:f,bottom:r}}},r={getNestedScroll:function(e){for(var t=0,o=0;e=e.parentElement;)t+=e.scrollLeft,o+=e.scrollTop;return{x:t,y:o}}},e={getAbsolute:function(e){var t=f.getNestedOffset(e),o=r.getNestedScroll(e);return{left:t.left-o.x,top:t.top-o.y,right:t.right-o.x,bottom:t.bottom-o.y}}};return{getNestedOffset:f.getNestedOffset,getNestedScroll:r.getNestedScroll,getAbsolute:e.getAbsolute,maxZIndex:{maxZIndex:function(e){for(var t=0,o=[e];o.length;){var f=Number(window.getComputedStyle(e=o.pop()).getPropertyValue("z-index"));t<f&&(t=f),o.concat(Array.prototype.slice.call(e.children))}return t}}.maxZIndex}}); |
{ | ||
"name": "element-position", | ||
"version": "0.1.9", | ||
"version": "0.2.3", | ||
"description": "Calculates the position of the DOM.", | ||
@@ -25,3 +25,3 @@ "main": "dist/index.min.js", | ||
"scripts": { | ||
"build": "rollup --config rollup.config.js" | ||
"build": "rollup --config bin/rollup.config.js" | ||
}, | ||
@@ -28,0 +28,0 @@ "license": "MIT", |
@@ -6,6 +6,3 @@ # Element Position | ||
## Documentation | ||
https://github.com/TroyTae/element-position/wiki | ||
## Issue | ||
https://github.com/TroyTae/element-position/issues |
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
5901
92
8