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

Commit 39f8b4d

Browse files
committed
Account for rounding errors in pixel ratio style.
1 parent 9d50be7 commit 39f8b4d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

js/load-image-scale.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,12 @@
235235
pixelRatio = options.pixelRatio
236236
if (
237237
pixelRatio > 1 &&
238-
// Check if image has not yet device pixel ratio applied:
239-
parseFloat(img.style.width, 10) !== width / pixelRatio
238+
// Check if the image has not yet had the device pixel ratio applied:
239+
!(
240+
img.style.width &&
241+
Math.floor(parseFloat(img.style.width, 10)) ===
242+
Math.floor(width / pixelRatio)
243+
)
240244
) {
241245
destWidth *= pixelRatio
242246
destHeight *= pixelRatio

0 commit comments

Comments
 (0)