Package Exports
- window-resizeto
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (window-resizeto) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
window-resizeto
A window.resizeTo
polyfill for test environments like Jest & JSDOM.
Installation
npm i -D window-resizeto
Usage
There are a few different ways you can use window-resizeto
:
With Jest:
// jest.config.js module.exports = { setupFilesAfterEnv: [ // polyfill window.resizeTo 'window-resizeto/polyfill' ] }
// some-test.spec.js window.resizeTo(500, 500) // window is now resize to 500x500
Standalone with the polyfill:
import 'window-resizeto/polyfill' window.resizeTo(500, 500) // window is now resized to 500x500
With the ponyfill:
import { resizeTo } from 'window-resizeto' resizeTo(window, 500, 500) // window is now resized to 500x500
How it works
Basically just sets the window
's outerWidth
, outerHeight
, innerWidth
, innerHeight
, and fires a resize
event.
The source code is currently just <10 LoC, so take a look under the hood! :)
Credits
Inspiration for creating this came from mq-polyfill
and a few other code samples that are nearly exact replicas.
I wanted a package I could re-use in my projects' tests instead of having to constantly create a helper file, and so window-resizeto
was born!