@randy.tarampi/jsx
Version:
Some common JSX components for www.randytarampi.ca
38 lines (30 loc) • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.computePostHeight = exports.WINDOW_LARGE_PHOTO_SCALE = exports.WINDOW_LARGE_BREAKPOINT = void 0;
var WINDOW_LARGE_BREAKPOINT = 992;
exports.WINDOW_LARGE_BREAKPOINT = WINDOW_LARGE_BREAKPOINT;
var WINDOW_LARGE_PHOTO_SCALE = 8 / 12;
exports.WINDOW_LARGE_PHOTO_SCALE = WINDOW_LARGE_PHOTO_SCALE;
var computePostHeight = function computePostHeight(containerWidth) {
return function (post, cachedPostHeight) {
if (post.height && post.width) {
var scaledHeight = containerWidth * (post.height / post.width);
if (window.innerWidth >= WINDOW_LARGE_BREAKPOINT) {
scaledHeight = scaledHeight * WINDOW_LARGE_PHOTO_SCALE;
}
return Math.round(scaledHeight);
}
if (typeof document !== "undefined" && document.getElementById(post.uid)) {
return document.getElementById(post.uid).clientHeight;
}
if (cachedPostHeight) {
return cachedPostHeight;
}
return typeof window !== "undefined" && window.innerHeight || 1000;
};
};
exports.computePostHeight = computePostHeight;
var _default = computePostHeight;
exports["default"] = _default;