Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/etiennetremel/fit-image-to-container-jquery
Allow you to fit an image to its parent.
https://github.com/etiennetremel/fit-image-to-container-jquery
Last synced: about 19 hours ago
JSON representation
Allow you to fit an image to its parent.
- Host: GitHub
- URL: https://github.com/etiennetremel/fit-image-to-container-jquery
- Owner: etiennetremel
- Created: 2012-03-26T10:56:02.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-05-01T01:08:04.000Z (over 11 years ago)
- Last Synced: 2023-03-23T02:02:20.149Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 402 KB
- Stars: 9
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
jQuery Fit Image to Container (fitc)
====================================Version 1.1
Author: Etienne Tremel
Author URL: http://www.etiennetremel.net
Description
-----------Allow you to fit an image to its parent.
Browser compatibility
---------------------Tested on IE8+, Chrome, FF 15+ (early version not tested yet), Safari 5.1+ (early version not tested yet)
Usage
-------
Check the example folder to set it up!### HTML
### CSS
.thumb {
width:100px;
height:100px;
overflow:hidden;
}### Javascript
$(document).ready(function() {
$('.thumb').fitc({
fit: false, // Fit image to parent, fill if false
before: function(element) { // Called when done
// do something before the image is loaded
// element return the parent of the image
},
complete: function(element) { // Called when done
// do something when image is loaded and fit to its container
// element return the parent of the image completed
}
});
});Changelog
-------
V1.1: Remove image attribute width & height before fitting imageV1.0:
* New name: Fitc instead of the old ugly long name "Fit Image To Container"
* Tabs converted to 2 spaces
* New examples
* New function before
* jsLint test passedV0.3: Image load event listener function switched to "one();" instead of "bind();"
V0.2: console.log() removed from the onComplete function.