react-native-zoom-toolkit
Version:
Smoothly zoom any image, video or component you want!
40 lines (38 loc) • 1.53 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCropRotatedSize = void 0;
var _getAspectRatioSize = require("../../utils/getAspectRatioSize");
const getCropRotatedSize = options => {
'worklet';
const {
crop,
angle,
resolution
} = options;
const cropAspectRatio = crop.width / crop.height;
let base = crop;
const flipped = angle % Math.PI === 0;
const aspectRatio = resolution.width / resolution.height;
const inverseAspectRatio = resolution.height / resolution.width;
base = (0, _getAspectRatioSize.getAspectRatioSize)({
aspectRatio: flipped ? aspectRatio : inverseAspectRatio,
width: cropAspectRatio >= 1 ? undefined : crop.width,
height: cropAspectRatio >= 1 ? crop.height : undefined
});
let sizeModifier = 1;
if (base.height < crop.height) sizeModifier = crop.height / base.height;
if (base.width < crop.width) sizeModifier = crop.width / base.width;
base.width = base.width * sizeModifier;
base.height = base.height * sizeModifier;
const maxWidth = Math.abs(base.height * Math.sin(angle)) + Math.abs(base.width * Math.cos(angle));
const maxHeight = Math.abs(base.height * Math.cos(angle)) + Math.abs(base.width * Math.sin(angle));
return (0, _getAspectRatioSize.getAspectRatioSize)({
aspectRatio: aspectRatio,
width: aspectRatio >= 1 ? undefined : maxWidth,
height: aspectRatio >= 1 ? maxHeight : undefined
});
};
exports.getCropRotatedSize = getCropRotatedSize;
//# sourceMappingURL=getCropRotatedSize.js.map