Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.

Commit

Permalink
- Enabled polyfill to initialize after load when being fetched asynch…
Browse files Browse the repository at this point in the history
…ronously

Signed-off-by: Christian Schepp Schaefer <[email protected]>
  • Loading branch information
Schepp committed Jan 23, 2014
1 parent 1302d61 commit 7acb9da
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 24 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 0.2.0 (November 24th, 2013)
### 0.3.1 (January 23rd, 2014)

* Enabled polyfill to initialize after load when being fetched asynchronously

### 0.3.0 (November 24th, 2013)

* Initial Release
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "object-fit",
"version": "0.3.0",
"version": "0.3.1",
"main": "polyfill.object-fit.js",
"ignore": [
"**/.*",
Expand Down
2 changes: 1 addition & 1 deletion dist/polyfill.object-fit.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @author: Anselm Hannemann <[email protected]>
* @author: Christian "Schepp" Schaefer <[email protected]>
* @version: 0.3.0
* @version: 0.3.1
*
*/

Expand Down
26 changes: 16 additions & 10 deletions dist/polyfill.object-fit.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
*
* @author: Anselm Hannemann <[email protected]>
* @author: Christian "Schepp" Schaefer <[email protected]>
* @version: 0.3.0
* @version: 0.3.1
*
*/

Expand Down Expand Up @@ -543,15 +543,21 @@
if (objectFit._debug && window.console) {
console.log('object-fit not natively supported');
}
if (window.addEventListener) {
window.addEventListener('load', function(){
objectFit.init(args);
}, false);
} else {
window.attachEvent('onload', function(){
objectFit.init(args);
});
}
// If the library is loaded after document onload event
if(document.readyState === 'complete') {
objectFit.init(args);
} else {
// Otherwise attach event listeners
if (window.addEventListener) {
window.addEventListener('load', function(){
objectFit.init(args);
}, false);
} else {
window.attachEvent('onload', function(){
objectFit.init(args);
});
}
}
} else {
if (objectFit._debug && window.console) {
console.log('object-fit natively supported');
Expand Down
2 changes: 1 addition & 1 deletion dist/polyfill.object-fit.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "object-fit",
"title": "object-fit polyfill",
"description": "Polyfill for the CSS object-fit property to fit images into containers",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/anselmh/object-fit",
"repository": {
"type": "git",
Expand Down
24 changes: 15 additions & 9 deletions src/polyfill.object-fit.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,21 @@
if (objectFit._debug && window.console) {
console.log('object-fit not natively supported');
}
if (window.addEventListener) {
window.addEventListener('load', function(){
objectFit.init(args);
}, false);
} else {
window.attachEvent('onload', function(){
objectFit.init(args);
});
}
// If the library is loaded after document onload event
if(document.readyState === 'complete') {
objectFit.init(args);
} else {
// Otherwise attach event listeners
if (window.addEventListener) {
window.addEventListener('load', function(){
objectFit.init(args);
}, false);
} else {
window.attachEvent('onload', function(){
objectFit.init(args);
});
}
}
} else {
if (objectFit._debug && window.console) {
console.log('object-fit natively supported');
Expand Down

0 comments on commit 7acb9da

Please sign in to comment.