@flourish/smooth-resize

0.2.1 • Public • Published

Smooth animations while the window is being resized

Responsive online graphics may need to update in response to changes in window size. It’s common to do this by listening for the resize event on the window object, but this results in a choppy effect since the resize event is not triggered frequently enough for a smooth animation.

This module makes it easy to implement smooth resize animations. While the window is being resized it uses requestAnimationFrame to run your drawing function at a (hopefully) decent frame rate.

It’s designed to be used with an ES6 module bundler such as rollup.js with rollup-plugin-node-resolve:

import smoothResize from "smooth-resize";

smoothresize(function(width, height) {
	// Redraw at the specified size
});

or you can include a self-contained version directly in your HTML:

<script src="https://cdn.flourish.rocks/smooth-resize-v0.min.js"></script>

It’s self-contained and tiny. Even the non-minified version is smaller than 1k.

It was developed for use in Flourish templates, but it’s open source and you can use it for anything.

Readme

Keywords

none

Package Sidebar

Install

npm i @flourish/smooth-resize

Weekly Downloads

1

Version

0.2.1

License

BSD-3-Clause

Last publish

Collaborators

  • jontyt
  • rushlet
  • winna_canva
  • bruno-riddy
  • libruca
  • jwitcombe
  • katietannercanva
  • b3n-canva
  • caletilford
  • florin.oprina
  • robinhouston
  • duncanclark
  • daanlouter
  • hughsk
  • mark-kiln
  • animateddata
  • larsvers
  • luptilu
  • bobbysebolao
  • hrobertson
  • oampo