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

Commit 9a032eb

Browse files
committed
Merge pull request #20 from kaigth/master
fixed loading issue in responsive image to support img tag width after i...
2 parents 6df9e68 + 939de8d commit 9a032eb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

core/responsive-image.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function ResponsiveImage() {
1919
this.src = null;
2020
this.isFlexible = false;
2121
this.hasRetina = false;
22+
this.hasRunOnce = false;
2223
this.preserveAspectRatio = false;
2324
this.knownDimensions = null;
2425
this.hasLoaded = false;
@@ -151,7 +152,7 @@ function update(image) {
151152
foundBreakpoint = image.knownSizes[0];
152153
}
153154

154-
if (foundBreakpoint !== image.currentBreakpoint) {
155+
if (foundBreakpoint !== image.currentBreakpoint || !image.hasRunOnce) {
155156
image.currentBreakpoint = foundBreakpoint;
156157
loadImageForBreakpoint(image, image.currentBreakpoint);
157158
}
@@ -181,6 +182,9 @@ function loadImageForBreakpoint(image, s) {
181182
img.onload = function() {
182183
image.loadedSizes[s] = img;
183184
setImage(image, img);
185+
update(image);
186+
187+
image.hasRunOnce = true;
184188
};
185189

186190
// If requesting retina fails

0 commit comments

Comments
 (0)