Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

element-resize-detector

> 编程语言
Open source

Optimized cross-browser resize listener for elements.

1.3K stars0 likes1 views
WebsiteGitHub

About

Optimized cross-browser resize listener for elements.

element-resize-detector

Optimized cross-browser resize listener for elements. Up to 37x faster than related approaches (read section 5 of the article).

npm install element-resize-detector

Usage

Include the script in the browser:

This will create a global function elementResizeDetectorMaker, which is the maker function that makes an element resize detector instance.

You can also require it like so:

var elementResizeDetectorMaker = require("element-resize-detector");

Create instance

// With default options (will use the object-based approach).
var erd = elementResizeDetectorMaker();

// With the ultra fast scroll-based approach.
// This is the recommended strategy.
var erdUltraFast = elementResizeDetectorMaker({
  strategy: "scroll" // y -> x resizes.

#### 1.1.16

* Fix bug that could happen during uninstall when waiting for unrendered objects. See #117.

#### 1.1.15

* ADA compliance fix for object approach. See #105.

#### 1.1.14

* Explicit use of window.getComputedStyle everywhere.

#### 1.1.13

* Only notify listeners when actual size change happened (in the rare case when multiple scroll events happens for the same resize). See #86.

#### 1.1.12

* Fixed an issue with embedded WebView's on Android and iOS (when getComputedStyle.width = null). See #74.
* Fixed an issue with unrendered iframe in FireFox. See #68.

#### 1.1.11

* Cleaned up the development build tools.
* Updated dev dependencies.
* Fixed an issue when uninstalling an element, and then calling listenTo in the middle of an old resize event. See #61.

#### 1.1.10

* Fixed so that injected scroll elements are `flex: none`. See #64.
* Fixed so that injected object element is not focusable. See #67.

#### 1.1.9

* Fixed uninstall issue when `callOnAdd` being true. Also now removing `onAnimationStart` listener when uninstalling. See #49.

#### 1.1.8

* Fixed a compatability issue with `options.idHandler.get`.

#### 1.1.7

* Fixed some rare issues with uninstalling elements while preparing/resizing.

#### 1.1.6

* Fixed an issue with the resize detector changing the dimensions of the target element in some browsers (e.g., IE and FireFox).

#### 1.1.5

* Fixed an issue with having parent elements `dir=RTL`.

#### 1.1.4

* Added extra safety styles to injected elements to make them more resilient to global CSS affecting them.

#### 1.1.3

* Now `uninstall` supports being called with elements that haven't been initialized. `uninstall` simply ignores non-erd elements.
* `uninstall` now also supports a collection of elements.

#### 1.1.2

* Fixed so that `uninstall` may be called directly after a `listenTo` call.
* Fixed a typo in the readme.
* Fixed an invalid test.

#### 1.1.1

* Using `window.getComputedStyle` instead of relying on the method being available in the global scope. This enables this library to be used in simulated browser environments such as jsdom.

#### 1.1.0

* Supporting inline elements
* Event-based solution for detecting attached/rendered events so that detached/unrendered elements can be listened to without polling
* Now all changes that affects the offset size of an element are properly detected (such as padding and font-size).
* Scroll is stabilized, and is the preferred strategy to use. The object strategy will be deprecated (and is currently only used for some legacy browsers such as IE9 and Opera 12).

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Fix bug that could happen during uninstall when waiting for unrendered objects. See #117.
  • •ADA compliance fix for object approach. See #105.
  • •Explicit use of window.getComputedStyle everywhere.
  • •Only notify listeners when actual size change happened (in the rare case when multiple scroll events happens for the same resize). See #86.
  • •Fixed an issue with embedded WebView's on Android and iOS (when getComputedStyle.width = null). See #74.
  • •Fixed an issue with unrendered iframe in FireFox. See #68.
  • •Cleaned up the development build tools.
  • •Updated dev dependencies.
  • •Fixed an issue when uninstalling an element, and then calling listenTo in the middle of an old resize event. See #61.
  • •Fixed so that injected scroll elements are flex: none. See #64.

> Tags

JavaScriptdomjavascriptonresizeresize

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言