“use strict”;
var positionImage = function positionImage(imageEl) {
var imageDimensions = imageEl.dataset.imageDimensions.split(‘x’);
var originalWidth = imageDimensions[0];
var originalHeight = imageDimensions[1];
var focalPoint = imageEl.dataset.imageFocalPoint.split(‘,’);
var focalPointX = focalPoint[0];
var focalPointY = focalPoint[1];
var parentNode = imageEl.parentNode;
var scale = function () {
var imageRatio = originalWidth / originalHeight;
var parentClientSize = {
height: parentNode.clientHeight,
width: parentNode.clientWidth
};
var parentRatio = parentClientSize.width / parentClientSize.height;
if (imageRatio > parentRatio) {
return parentClientSize.height / originalHeight;
}
return parentClientSize.width / originalWidth;
}();
var getRelativeOffset = function getRelativeOffset() {
var targetWidth = Math.ceil(originalWidth * scale);
var targetHeight = Math.ceil(originalHeight * scale);
var parentDimensionWidth = parentNode.offsetWidth;
var parentDimensionHeight = parentNode.offsetHeight;
var overflowWidth = targetWidth – parentDimensionWidth;
var overflowHeight = targetHeight – parentDimensionHeight;
var valueX;
if (overflowWidth === 0) {
valueX = focalPointX;
} else {
valueX = Math.max(Math.min(targetWidth * focalPointX – parentDimensionWidth * 0.5, overflowWidth), 0) / overflowWidth;
}
var valueY;
if (overflowHeight === 0) {
valueY = focalPointY;
} else {
valueY = Math.max(Math.min(targetHeight * focalPointY – parentDimensionHeight * 0.5, overflowHeight), 0) / overflowHeight;
}
return {
valueX: valueX,
valueY: valueY
};
};
var relativeOffset = getRelativeOffset();
var valueX = relativeOffset.valueX;
var valueY = relativeOffset.valueY;
imageEl.style.objectPosition = “”.concat(valueX * 100, “% “).concat(valueY * 100, “%”);
Object.assign(imageEl.style, {
height: ‘100%’,
width: ‘100%’,
objectFit: ‘cover’,
});
};
-
February 2020
-
Feb 10, 2020
-
-
March 2020
-
May 2020
-
May 23, 2020
-
-
June 2020
-
Jun 11, 2020
-
-
July 2020
-
August 2020
-
Aug 13, 2020
-
Aug 13, 2020
-
Aug 17, 2020
-
Aug 30, 2020
-
-
September 2020
-
Sep 23, 2020
-
-
October 2020
-
Oct 14, 2020
-
-
November 2020
-
Nov 9, 2020
-
-
December 2020
-
Dec 4, 2020
-
-
January 2021
-
Jan 4, 2021
-
Jan 4, 2021
-
Jan 16, 2021
-
-
April 2021
-
Apr 15, 2021
-
Apr 21, 2021
-
Apr 27, 2021
How George Washington Used Vaccines to Help Win the Revolutionary War
-
Apr 28, 2021
-
-
May 2021
-
May 25, 2021
-
-
July 2021
-
Jul 8, 2021
-
Jul 15, 2021
-
-
August 2021
-
Aug 13, 2021
-
-
April 2022
-
Apr 2, 2022
-
Apr 22, 2022
Unfortunately, this is a horror story, but its true. Part 1.
-
-
May 2022
-
May 3, 2022
-
May 11, 2022
-
May 21, 2022
-
May 26, 2022
-
May 30, 2022
-
-
June 2022
-
Jun 7, 2022
-
Jun 12, 2022
-
Jun 15, 2022
-
Jun 26, 2022
-
-
July 2022
-
Jul 6, 2022
-
Jul 9, 2022
-
-
August 2022
-
Aug 10, 2022
-
Aug 29, 2022
-
-
September 2022
-
Sep 11, 2022
-
Sep 20, 2022
-
-
November 2022
-
Nov 16, 2022
-