{"name":"canvas-fit","version":"1.5.0","description":"Small module for fitting a canvas element within the bounds of its parent.","main":"index.js","scripts":{"test":"beefy test.js --open"},"repository":{"type":"git","url":"git://github.com/hughsk/canvas-fit.git"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"license":"MIT","bugs":{"url":"https://github.com/hughsk/canvas-fit/issues"},"homepage":"https://github.com/hughsk/canvas-fit","dependencies":{"element-size":"^1.1.1"},"devDependencies":{"beefy":"^1.1.0","raf":"^0.1.3"},"keywords":["canvas","fit","screen","window","browser","stretch","resize"],"gitHead":"55ba4fa0261168779b8e2c0e7d177f22688adbb3","_id":"canvas-fit@1.5.0","_shasum":"ae13be66ade42f5be0e487e345fce30a5e5b5e5f","_from":".","_npmVersion":"2.12.1","_nodeVersion":"2.3.4-nightly20150820b1aa3f0247","_npmUser":{"name":"hughsk","email":"hughskennedy@gmail.com"},"dist":{"shasum":"ae13be66ade42f5be0e487e345fce30a5e5b5e5f","tarball":"http://registry-npm.ywwl.com/canvas-fit/download/canvas-fit-1.5.0.tgz","integrity":"sha512-onIcjRpz69/Hx5bB5HGbYKUF2uC6QT6Gp+pfpGm3A7mPfcluSLV5v4Zu+oflDUwLdUw0rLIBhUbi0v8hM4FJQQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCrlZyVBo4XihuLZHHvbCaUU71UASkmOuG3E7PEpuPAmgIhALK/riHE3ErqFOr8kqtjRYKR8CVJ7zH+l7q2qnSAMosy"}],"size":2574,"noattachment":false,"key":"/canvas-fit/-/canvas-fit-1.5.0.tgz"},"maintainers":[{"name":"hughsk","email":"hughskennedy@gmail.com"}],"directories":{},"readme":"# canvas-fit [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\nSmall module for fitting a canvas element within the bounds of its parent.\nUseful, for example, for making a canvas fill the screen. Works with SVG\nelements too!\n\n## Usage\n\n[![NPM](https://nodei.co/npm/canvas-fit.png)](https://nodei.co/npm/canvas-fit/)\n\n### resize = fit(canvas[, parent[, scale]])\n\nCreates a `resize` function for your `canvas` element. Calling this function\nwill resize the canvas to fit its parent element.\n\nHere's a simple example to make your canvas update its dimensions when\nresizing the window:\n\n``` javascript\nvar fit = require('canvas-fit')\nvar canvas = document.createElement('canvas')\n\nwindow.addEventListener('resize', fit(canvas), false)\n```\n\nYou might want to override the `parent` element that the canvas should be\nfitting within: in which case, pass that element in as your second argument:\n\n``` javascript\nwindow.addEventListener('resize'\n  , fit(canvas, window)\n  , false\n)\n```\n\nYou can also set the scale of the canvas element relative to its styled size\non the page using the `scale` argument – for example, passing in\n`window.devicePixelRatio` here will scale the canvas resolution up on retina\ndisplays.\n\n\n### `resize.scale = <Number>`\n\nDynamically change the canvas' target `scale`. Note that you still need to\nmanually trigger a resize after doing this.\n\n\n### `resize.parent = <DOMElement>`\n\nDynamically change the canvas' `parent` element. Note that you still need\nto manually trigger a resize after doing this.\n\n### `resize.parent = () => [width, height]`\n\nInstead of filling a given element, explicitly set the width and height\nof the canvas. Note that this value will still be scaled up according\nto `resize.scale`\n\n``` javascript\nresize.parent = function() {\n  return [ window.innerWidth - 300, window.innerHeight ]\n}\n```\n\n## License\n\nMIT. See [LICENSE.md](http://github.com/hughsk/canvas-fit/blob/master/LICENSE.md) for details.\n","publish_time":1440717471421,"_cnpm_publish_time":1440717471421,"dist-tags":{"latest":"1.5.0"}}