this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Simplify natural aspect ratio math

+6 -14
+6 -14
src/components/media.jsx
··· 372 372 ) { 373 373 $media.dataset.hasSmallDimension = true; 374 374 } else { 375 - const naturalAspectRatio = ( 376 - naturalWidth / naturalHeight 377 - ).toFixed(2); 378 - const displayAspectRatio = ( 379 - clientWidth / clientHeight 380 - ).toFixed(2); 381 - const similarThreshold = 0.05; 382 - if ( 383 - naturalAspectRatio === displayAspectRatio || 384 - Math.abs(naturalAspectRatio - displayAspectRatio) < 385 - similarThreshold 386 - ) { 387 - // $media.dataset.hasNaturalAspectRatio = true; 375 + const displayNaturalHeight = 376 + (naturalHeight * clientWidth) / naturalWidth; 377 + const almostSimilarHeight = 378 + Math.abs(displayNaturalHeight - clientHeight) < 2; 379 + 380 + if (almostSimilarHeight) { 388 381 setHasNaturalAspectRatio(true); 389 382 } 390 - // $media.dataset.aspectRatios = `${naturalAspectRatio} ${displayAspectRatio}`; 391 383 } 392 384 } 393 385 }