JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 346320
  • Score
    100M100P100Q166730F
  • License MIT

Small module for fitting a canvas element within the bounds of its parent.

Package Exports

  • canvas-fit

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 (canvas-fit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

canvas-fit experimental

Small module for fitting a canvas element within the bounds of its parent. Useful, for example, for making a canvas fill the screen.

Usage

NPM

resize = fit(canvas)

Creates a resize function for your canvas element. Calling this function will resize the canvas to fit its parent element.

Here's a simple example to make your canvas update its dimensions when resizing the window:

var fit = require('canvas-fit')
var canvas = document.createElement('canvas')

window.addEventListener('resize', fit(canvas), false)

License

MIT. See LICENSE.md for details.