timse / srcset-loader

Flexible srcset-loader for webpack
46 stars 14 forks source link

Use unresized image to calculate ratio of placeholder image #10

Closed xeophin closed 7 years ago

xeophin commented 7 years ago

When using placeholders, the page may still jump slightly when the ratio has been calculated using the resized placeholder image instead of the original image. In my use case, this led to a size difference of several pixels and ugly artefacts.

E.g.

Image Size Ratio
Original Image 2255 x 2701 px 1.1977827051
Placeholder Image 20 x 24 px  1.2
Displayed Image Width Calculated Height using Original Image Ratio Calculated Height using Placeholder Image Ratio
1200 px 1437 px 1440 px

This pull request should fix that by calculating the ratio using the original image.

timse commented 7 years ago

thanks :)!

timse commented 7 years ago

published as 2.0.2