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

resizilla

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resizilla

Window resize with debounce. e.g., window.resizilla(handler, delay, inception)

  • 0.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20
increased by1900%
Maintainers
1
Weekly downloads
 
Created
Source

img

resizilla

A Better Window Resize

Why?
  • When the user resizes a range of events are fired when using: window.onresize & window.addEventListener(). Resizilla allows you to reduce and control the frequency of calls using a debounce algorithm. TLDR It performs better.
  • Resizilla uses the next available animation frame ( requestAnimationFrame ) rather than setTimeout for better optimization.
  • Support for orientation change.
  • AMD compliant.
  • Built in destroy method.

How?

resizilla(handler, delay, incept);

  • handler: Function to execute on resize
  • delay: Delay of the function call in ms on resize
  • incept: If true the function call at the beginning of the detection period, if false the call will be at the end of the detection period (false by default)

or

resizilla({ handler: Function, delay: Milliseconds, incept: Boolean, orientationChange: Boolean, useCapture: Boolean });

  • useCapture: Register the event handler for the capturing/ bubbling phase.
  • orientationChange: See below...

For general use, use a moderate delay e.g. incept: 200


Tested browsers:
Chrome 14+Safari 5.1+Firefox 4+Opera 10.6+IE9+EdgeIE8

| iPhone 3GS+| iPad 2+ | Android 2.2+ | Windows Phone 8.1+ | |:-----------|:------------|:------------|:------------|:------------|:------------|:------------| |✓ |✓|✓|✓|


Mobile:

By default, resizilla calls the handler when the "orientationchange" event is fired. This can be disabled using

resizilla({ handler: () => { // do something }, delay: 250, incept: true, orientationChange: false });


Destroy:

Remove the event listener by using the below:

resizilla.destroy();


The example:

The current example only needs to reveal the transition of the debounce to satisfy as working.

So no element resize support?

Nope, and with good reason. Elements resize detection is a different paradigm, to detect changes that occur with elements checkout getComputedStyle, transitionEnd & MutationObserver.

(Original ASCII art by Mozilla)

Big thanks to BrowsreStack for sponsoring this project via cross browser testing.

MIT License

Copyright (c) 2015 Julien Etienne

Keywords

FAQs

Package last updated on 12 Jul 2016

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