# object-fit-videos

> Polyfill for object-fit and object-position CSS properties on video elements

Latest version **1.0.4** (published 2017-12-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install object-fit-videos
pnpm add object-fit-videos
yarn add object-fit-videos
bun add object-fit-videos
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-12-06 |
| First published | 2016-08-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 103 |
| Author | Todd Miller |
| Maintainers | toddses |
| Keywords | object-fit, object-position, javascript, polyfill, covers, contains, css, styles, internet, explorer, ies, shim, shiv, fills, videos, backgrounds |

## Links

- npm: https://www.npmjs.com/package/object-fit-videos
- Repository: https://github.com/TricomB2B/object-fit-videos
- Homepage: https://github.com/TricomB2B/object-fit-videos#readme
- Issues: https://github.com/TricomB2B/object-fit-videos/issues
- npm.io page: https://npm.io/package/object-fit-videos

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2017-12-06
- 1.0.3 — 2017-09-26
- 1.0.2 — 2016-12-05
- 1.0.1 — 2016-11-28
- 1.0.0 — 2016-10-14
- 0.0.5 — 2016-09-21
- 0.0.4 — 2016-08-22
- 0.0.3 — 2016-08-19
- 0.0.2 — 2016-08-19
- 0.0.1 — 2016-08-19

## README

# object-fit-videos

An open-source polyfill for CSS `object-fit` and `object-position` on videos. Supports IE9-11, Edge, and Safari <10 (and more?). Does nothing on browsers that support these properties.

### Installation

```sh
$ npm install --save object-fit-videos
```

Or [yarn](https://yarnpkg.com/)!

```sh
$ yarn add object-fit-videos
```

### Usage

Include the polyfill in your markup

```html
<script src="path/to/object-fit-videos/dist/object-fit-videos.min.js"></script>
```

Add a special font-family CSS property for targeting IE/Edge or Safari

```css
video {
  object-fit: cover;
  font-family: 'object-fit: cover;';
}
```

`object-position` can be used similarly. Note that `object-position` only supports keyword positioning at this time. That's `top`, `bottom`, `left`, `right`, and `center`

```css
video {
  object-fit: cover;
  object-position: left top;
  font-family: 'object-fit: cover; object-position: left top;';
}
```

Make the JavaScript call to initialize the videos with the special CSS property

```js
objectFitVideos();
```

You can make the call before the closing `</body>` tag or whenever the DOM is ready. The polyfill will do the rest.

### Polyfilling Specific Elements

You can also pass elements to the `objectFitVideos()` function to only polyfill specific videos. A couple examples:

```js
objectFitVideos(document.querySelectorAll('.videos'));
```

```js
objectFitVideos(document.getElementById('vid'));
```

So on and so forth.

### Contributions

Feel free to open Pull Requests, bug reports, feature requests.

Special thanks to these folks to who have contributed code:

[msorensson](https://github.com/msorensson)  
[oncode](https://github.com/oncode)  
[richtr](https://github.com/richtr)

### License

Copyright (c) 2016 TricomB2B

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/object-fit-videos · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
