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

element-measurer

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

element-measurer

A javascript class that provides convenience for measuring size to target such as element or document.

  • 1.4.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ElementMeasurer

Build Status npm version Downloads

A javascript class that provides convenience for measuring size to target such as element or document.

Install

npm install element-measurer

Usage

import ElementMeasurer from 'element-measurer';

// Measures on an element.
// target: HTMLElement | 'selector' | document | window
const targetSize = new ElementMeasurer('#target');
let max = targetSize.maxScrollTop; // get maxScrollTop.

// Measures on the whole Document.
const docSize = new ElementMeasurer();
docSize.scrollTop = 200; // set scrollTop.

API

Image: element-and-client

Properties

  • clientWidth: ReadOnly Returns inner width of an element in pixels.
  • clientHeight: ReadOnly Returns inner height of an element in pixels.
  • scrollTop: Gets or sets of pixels that an element's content is scrolled vertically.
  • scrollLeft: Gets or sets the number of pixels that an element's content is scrolled to the left.
  • scrollWidth: ReadOnly Returns the width of the entire content of an element.
  • scrollHeight: ReadOnly Returns the height of the entire content of an element.
  • maxScrollTop: ReadOnly Returns maximum top scroll offset possible for the element.
  • maxScrollLeft: ReadOnly Returns maximum left scroll offset possible for the element.

Methods

setTarget

Set target element.

Syntax

elementMeasurer.setTarget(target);
  • @param Element|String|Window|Document target
  • @returns ElementMeasurer
getOffset

Returns top and left values that indicates offset distance to html document.

Syntax

let obj = elementMeasurer.getOffset();
  • @returns Object { top, left }
getRect

Returns DOMRect object of the target element.

Syntax

let domRect = elementMeasurer.getRect();

License

MIT License

Keywords

FAQs

Package last updated on 15 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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