background-cover
v0.1.1
Published
Simulate 'background-size: cover' on HTMLVideoElement and HTMLImageElement.
Maintainers
Readme
background-cover
Simulate 'background-size: cover' on HTMLVideoElement and HTMLImageElement.
Syntax
BackgroundCover(element, container [, horizontalAlign, verticalAlign]);- element:
HTMLVideoElement, orHTMLImageElement, or other dom element (e.g.HTMLCanvasElement) - horizontalAlign:
Numberfrom 0 to 1, where 0 means aligned to the left. Default value is 0.5 (centered); - verticalAlign:
Numberfrom 0 to 1, where 0 means aligned to the top. Default value is 0.5 (centered);
Example
var BackgroundCover = require('background-cover');
var videoContainer = document.getElementById('video-container');
var video = document.getElementById('video');
video.addEventListener('loadedmetadata', function() {
BackgroundCover(video, videoContainer);
);Check out tests for more examples.
Install
npm install background-cover --saveTests
npm run test-video
npm run test-imageLicense
MIT, see LICENSE.md for details.
