Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

watch-element-resize

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watch-element-resize

A (yet another) cross-browser, event-based, element resize watcher.

latest
Source
npmnpm
Version
2.0.6
Version published
Maintainers
1
Created
Source

watch-element-resize.js

Build Status

A (yet another) cross-browser, event-based, element resize watcher. This is kind of a (improved) fork of sdecima/javascript-detect-element-resize.

Demo

See here a demo.

How to use it?

CDN Hosted - jsDelivr

Load Javascript:

<script src="//cdn.jsdelivr.net/watch-element-resize.js/latest/watch-element-resize.min.js"></script>
Self hosted

Download latest release.

Instantiate with some options and listen to changes
var watchResize = new WatchElementResize(['field1', 'field2']);
watchResize.on('resize', function(evt){
  console.info(evt);
  
  // the DOM element
  var resized_element = evt.element.target;
  
  // the element offset (width, height, top, left) 
  var offset = evt.element.offset;
  
  // the window dimensions -- just in case you need
  var window_size = evt.window;
});

API

Constructor

new WatchElementResize(target)

target can be:

{String|Array<String>|Element|Array<Element>} String or array of string, DOM node or array of nodes.

Methods

watchResize.reAddListener()

watchResize.removeListener()

Events

watchResize.on('resize', function(evt){

});

Keywords

resize

FAQs

Package last updated on 31 Oct 2017

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