UNPKG

@visactor/vtable

Version:

canvas table width high performance

18 lines (15 loc) 721 B
"use strict"; function calcKeepAspectRatioSize(width, height, maxWidth, maxHeight) { const rectRatio = width / height; let newWidth, newHeight, offsetX, offsetY; return rectRatio > maxWidth / maxHeight ? (newWidth = maxWidth, newHeight = newWidth / rectRatio, offsetX = 0, offsetY = (maxHeight - newHeight) / 2) : (newHeight = maxHeight, newWidth = newHeight * rectRatio, offsetY = 0, offsetX = (maxWidth - newWidth) / 2), { width: newWidth, height: newHeight }; } Object.defineProperty(exports, "__esModule", { value: !0 }), exports.calcKeepAspectRatioSize = void 0, exports.calcKeepAspectRatioSize = calcKeepAspectRatioSize; //# sourceMappingURL=keep-aspect-ratio.js.map