Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
canvas-fit
Advanced tools
Readme
Small module for fitting a canvas element within the bounds of its parent. Useful, for example, for making a canvas fill the screen. Works with SVG elements too!
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)
You might want to override the parent
element that the canvas should be
fitting within: in which case, pass that element in as your second argument:
window.addEventListener('resize'
, fit(canvas, window)
, false
)
You can also set the scale of the canvas element relative to its styled size
on the page using the scale
argument – for example, passing in
window.devicePixelRatio
here will scale the canvas resolution up on retina
displays.
resize.scale = <Number>
Dynamically change the canvas' target scale
. Note that you still need to
manually trigger a resize after doing this.
resize.parent = <DOMElement>
Dynamically change the canvas' parent
element. Note that you still need
to manually trigger a resize after doing this.
resize.parent = () => [width, height]
Instead of filling a given element, explicitly set the width and height
of the canvas. Note that this value will still be scaled up according
to resize.scale
resize.parent = function() {
return [ window.innerWidth - 300, window.innerHeight ]
}
MIT. See LICENSE.md for details.
FAQs
Small module for fitting a canvas element within the bounds of its parent.
The npm package canvas-fit receives a total of 165,457 weekly downloads. As such, canvas-fit popularity was classified as popular.
We found that canvas-fit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.