Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

element-position

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-position - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

docs/_config.yml

2

dist/index.d.ts

@@ -20,6 +20,4 @@ declare namespace ElementPosition {

}
function maxZIndex(el: HTMLElement): number;
}
export = ElementPosition;

@@ -51,22 +51,6 @@ (function (global, factory) {

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,
maxZIndex: Z_INDEX.maxZIndex
getAbsolute: ABSOLUTE.getAbsolute
};

@@ -73,0 +57,0 @@

@@ -1,1 +0,1 @@

!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}});
!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 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}});
{
"name": "element-position",
"version": "0.2.4",
"version": "0.2.5",
"description": "Calculates the position of the DOM.",

@@ -5,0 +5,0 @@ "main": "dist/index.min.js",

@@ -9,15 +9,14 @@ # Element Position

## Issue
[Please register your issue here!](https://github.com/TroyTae/element-position/issues)
## Documentation
[Please see the detailed document here!](https://troytae.github.io/element-position/)
## Usage
```javascript
```js
// ES Module
const el = document.getElementById('id');
ElementPosition.maxZIndex(el);
ElementPosition.getAbsolute(el);
ElementPosition.getNestedOffset(el);
ElementPosition.getNestedScroll(el);
var el = document.getElementById('id');
var pos = ElementPosition.getAbsolute(el);
console.log(pos.top, pos.left, pos.right, pos.bottom);
```
```javascript
```js
// CommonJS or AMD

@@ -27,8 +26,5 @@ import * as p from 'element-position';

const el = document.getElementById('id');
console.log(
p.maxZIndex(el),
p.getAbsolute(el),
p.getNestedOffset(el),
p.getNestedScroll(el)
);
const pos = p.getAbsolute(el);
console.log(pos.top, pos.left, pos.right, pos.bottom);
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc