merchi_product_editor
Version:
A React component for editing product images using Fabric.js
34 lines (33 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDeviceAdjustedDimensions = void 0;
var getDeviceAdjustedDimensions = function (defaultWidth, defaultHeight) {
if (defaultWidth === void 0) { defaultWidth = 800; }
if (defaultHeight === void 0) { defaultHeight = 600; }
if (typeof window === 'undefined') {
return {
isMobile: false,
width: defaultWidth,
height: defaultHeight
};
}
var isMobile = window.innerWidth < 480;
// Use default dimensions for desktop
if (!isMobile) {
return {
isMobile: false,
width: defaultWidth,
height: defaultHeight
};
}
// Calculate mobile dimensions
var mobileWidth = Math.min(window.innerWidth * 0.9 - 32, 400);
var aspectRatio = defaultWidth / defaultHeight;
var mobileHeight = mobileWidth / aspectRatio;
return {
isMobile: true,
width: mobileWidth,
height: mobileHeight
};
};
exports.getDeviceAdjustedDimensions = getDeviceAdjustedDimensions;