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

Commit 7acb9da

Browse files
committed
- Enabled polyfill to initialize after load when being fetched asynchronously
Signed-off-by: Christian Schepp Schaefer <[email protected]>
1 parent 1302d61 commit 7acb9da

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3-
### 0.2.0 (November 24th, 2013)
3+
### 0.3.1 (January 23rd, 2014)
4+
5+
* Enabled polyfill to initialize after load when being fetched asynchronously
6+
7+
### 0.3.0 (November 24th, 2013)
48

59
* Initial Release

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "object-fit",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"main": "polyfill.object-fit.js",
55
"ignore": [
66
"**/.*",

dist/polyfill.object-fit.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @author: Anselm Hannemann <[email protected]>
66
* @author: Christian "Schepp" Schaefer <[email protected]>
7-
* @version: 0.3.0
7+
* @version: 0.3.1
88
*
99
*/
1010

dist/polyfill.object-fit.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
*
195195
* @author: Anselm Hannemann <[email protected]>
196196
* @author: Christian "Schepp" Schaefer <[email protected]>
197-
* @version: 0.3.0
197+
* @version: 0.3.1
198198
*
199199
*/
200200

@@ -543,15 +543,21 @@
543543
if (objectFit._debug && window.console) {
544544
console.log('object-fit not natively supported');
545545
}
546-
if (window.addEventListener) {
547-
window.addEventListener('load', function(){
548-
objectFit.init(args);
549-
}, false);
550-
} else {
551-
window.attachEvent('onload', function(){
552-
objectFit.init(args);
553-
});
554-
}
546+
// If the library is loaded after document onload event
547+
if(document.readyState === 'complete') {
548+
objectFit.init(args);
549+
} else {
550+
// Otherwise attach event listeners
551+
if (window.addEventListener) {
552+
window.addEventListener('load', function(){
553+
objectFit.init(args);
554+
}, false);
555+
} else {
556+
window.attachEvent('onload', function(){
557+
objectFit.init(args);
558+
});
559+
}
560+
}
555561
} else {
556562
if (objectFit._debug && window.console) {
557563
console.log('object-fit natively supported');

dist/polyfill.object-fit.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "object-fit",
33
"title": "object-fit polyfill",
44
"description": "Polyfill for the CSS object-fit property to fit images into containers",
5-
"version": "0.3.0",
5+
"version": "0.3.1",
66
"homepage": "https://github.com/anselmh/object-fit",
77
"repository": {
88
"type": "git",

src/polyfill.object-fit.core.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,21 @@
353353
if (objectFit._debug && window.console) {
354354
console.log('object-fit not natively supported');
355355
}
356-
if (window.addEventListener) {
357-
window.addEventListener('load', function(){
358-
objectFit.init(args);
359-
}, false);
360-
} else {
361-
window.attachEvent('onload', function(){
362-
objectFit.init(args);
363-
});
364-
}
356+
// If the library is loaded after document onload event
357+
if(document.readyState === 'complete') {
358+
objectFit.init(args);
359+
} else {
360+
// Otherwise attach event listeners
361+
if (window.addEventListener) {
362+
window.addEventListener('load', function(){
363+
objectFit.init(args);
364+
}, false);
365+
} else {
366+
window.attachEvent('onload', function(){
367+
objectFit.init(args);
368+
});
369+
}
370+
}
365371
} else {
366372
if (objectFit._debug && window.console) {
367373
console.log('object-fit natively supported');

0 commit comments

Comments
 (0)