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.5 to 0.2.6

2

dist/index.d.ts

@@ -14,3 +14,3 @@ declare namespace ElementPosition {

function getAbsolute(el: HTMLElement): {
function getCoordinates(el: HTMLElement): {
top: number,

@@ -17,0 +17,0 @@ left: number,

@@ -7,3 +7,3 @@ (function (global, factory) {

var OFFSET = {
var Offset = {
getNestedOffset: function (el) {

@@ -26,3 +26,3 @@ var left = el.offsetLeft, top = el.offsetTop, right = el.offsetLeft + el.offsetWidth, bottom = el.offsetTop + el.offsetHeight;

var SCROLL = {
var Scroll = {
getNestedScroll: function (el) {

@@ -41,5 +41,5 @@ var x = 0, y = 0;

var ABSOLUTE = {
getAbsolute: function (el) {
var offset = OFFSET.getNestedOffset(el), scroll = SCROLL.getNestedScroll(el);
var Coordinates = {
getCoordinates: function (el) {
var offset = Offset.getNestedOffset(el), scroll = Scroll.getNestedScroll(el);
return {

@@ -55,5 +55,5 @@ left: (offset.left - scroll.x),

var main = {
getNestedOffset: OFFSET.getNestedOffset,
getNestedScroll: SCROLL.getNestedScroll,
getAbsolute: ABSOLUTE.getAbsolute
getNestedOffset: Offset.getNestedOffset,
getNestedScroll: Scroll.getNestedScroll,
getCoordinates: Coordinates.getCoordinates
};

@@ -60,0 +60,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 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(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}});
{
"name": "element-position",
"version": "0.2.5",
"version": "0.2.6",
"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)]()
## Introduction

@@ -16,3 +18,3 @@ This is a library that can calculate html element's position.

var el = document.getElementById('id');
var pos = ElementPosition.getAbsolute(el);
var pos = ElementPosition.getCoordinates(el);

@@ -26,5 +28,5 @@ console.log(pos.top, pos.left, pos.right, pos.bottom);

const el = document.getElementById('id');
const pos = p.getAbsolute(el);
const pos = p.getCoordinates(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