Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/quantizor/angular-backgroundsizer

💗 angular 1 directive to automatically apply background sizing once an image is loaded
https://github.com/quantizor/angular-backgroundsizer

Last synced: 3 days ago
JSON representation

💗 angular 1 directive to automatically apply background sizing once an image is loaded

Awesome Lists containing this project

README

        

angular-backgroundSizer
=======================

A directive to automatically apply background sizing once an image is loaded. Useful for dynamic images
without predefined aspect ratios.

It will discreetly load the image into the DOM (invisible and absolute, so it doesn't jump the page),
take height measurements and then apply background-size 'contain', 'cover' or nothing. It also listens
to the window 'resize' event and appropriately adjusts the background-size if needed.

Load it into your AngularJS app by including it in your module's dependency array like so:
````javascript
var app = angular.module('myModule', ['backgroundSizer']);
````

Then use it like this:
````html

````