0.0.3 • Published 7 years ago

object-fit-picture-tag-polyfill v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Object Fit Picture Tag Polyfill badge-size npm version

Cross browser CSS object-fit support for picture tags

  • Fast and lightweight
  • No framework dependencies
  • Works with both <picture> and <img> tags

Installation

However you like:

<script src="dist/object-fit-picture-tag-polyfill.min.js"></script>
npm install --save object-fit-picture-tag-polyfill

Usage

  1. Append your <picture> tags with either data-object-fit-cover or data-object-fit-contain

  2. Import the plugin

        import objectFitPolyfill from 'object-fit-picture-tag-polyfill';
  3. Instantiate the class and pass it any options
        new objectFitPolyfill({
            fitPosition: 'center center'
        });
  4. (optional) if you want to reinitialise the script you can call the init() method directly (after the class has been initialised)

        let polyfill = new objectFitPolyfill();
    
        polyfill.init();

Parameters

(fitPosition, addContainer)

MIT © Chris Boakes