New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.8 to 0.2.9

34

dist/index.d.ts
declare namespace ElementPosition {
function getNestedOffset(el: HTMLElement): {
top: number,
left: number,
right: number,
bottom: number
}
function getNestedScroll(el: HTMLElement): {
x: number,
y: number
}
function getCoordinates(el: HTMLElement): {
top: number,
left: number,
right: number,
bottom: number
}
function getNestedOffset(el: HTMLElement): {
top: number,
left: number,
right: number,
bottom: number
}
function getNestedScroll(el: HTMLElement): {
x: number,
y: number
}
function getCoordinates(el: HTMLElement): {
top: number,
left: number,
right: number,
bottom: number
}
}
export = ElementPosition;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.ElementPosition = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.ElementPosition = factory());
}(this, (function () { 'use strict';
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
};
}
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
};
}
function getNestedScroll(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
};
}
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)
};
}
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 ComputePosition = {
getNestedOffset: getNestedOffset,
getNestedScroll: getNestedScroll,
getCoordinates: getCoordinates
};
var main = {
getNestedOffset: ComputePosition.getNestedOffset,
getNestedScroll: ComputePosition.getNestedScroll,
getCoordinates: ComputePosition.getCoordinates
};
var main = {
getNestedOffset: ComputePosition.getNestedOffset,
getNestedScroll: ComputePosition.getNestedScroll,
getCoordinates: ComputePosition.getCoordinates
};
return main;
return main;
})));
{
"name": "element-position",
"version": "0.2.8",
"version": "0.2.9",
"description": "Calculates the position of the DOM.",

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

# Element Position
[![NPM Version](https://img.shields.io/npm/v/element-position.svg)](https://www.npmjs.com/package/element-position)
[![LICENSE](https://img.shields.io/github/license/TroyTae/element-position.svg)]()
[![LICENSE](https://img.shields.io/github/license/TroyTae/element-position.svg)](https://github.com/TroyTae/element-position/blob/master/LICENSE.md)

@@ -12,20 +12,7 @@ ## Introduction

## Documentation
[Please see the detailed document here!](https://troytae.github.io/element-position/)
[Please see the detailed document here!](https://troytae.github.io/element-position)
## Usage
```js
// ES Module
var el = document.getElementById('id');
var pos = ElementPosition.getCoordinates(el);
## Demo Video
[You can find this demo code in here!](https://troytae.github.io/element-position/compute-position/coordinates.html)
console.log(pos.top, pos.left, pos.right, pos.bottom);
```
```js
// CommonJS or AMD
import * as p from 'element-position';
const el = document.getElementById('id');
const pos = p.getCoordinates(el);
console.log(pos.top, pos.left, pos.right, pos.bottom);
```
[![fade in on scroll down](https://img.youtube.com/vi/vS06JZISJT8/0.jpg)](https://www.youtube.com/watch?v=vS06JZISJT8)
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