2017-09-19 06:20:44 +08:00
|
|
|
|
|
|
|
const calculateSlideData = (slideData) => {
|
2019-08-01 03:10:41 +08:00
|
|
|
const {
|
|
|
|
width, height, xOffset, yOffset, widthRatio, heightRatio,
|
|
|
|
} = slideData;
|
2017-09-19 06:20:44 +08:00
|
|
|
|
|
|
|
// calculating viewBox and offsets for the current presentation
|
2023-03-20 19:43:27 +08:00
|
|
|
const maxImageWidth = 1440;
|
|
|
|
const maxImageHeight = 1080;
|
2023-02-15 00:27:51 +08:00
|
|
|
|
|
|
|
const ratio = Math.min(maxImageWidth / width, maxImageHeight / height);
|
|
|
|
const scaledWidth = width * ratio;
|
|
|
|
const scaledHeight = height * ratio;
|
|
|
|
const scaledViewBoxWidth = width * widthRatio / 100 * ratio;
|
|
|
|
const scaledViewBoxHeight = height * heightRatio / 100 * ratio;
|
|
|
|
|
2017-09-19 06:20:44 +08:00
|
|
|
return {
|
2023-02-15 00:27:51 +08:00
|
|
|
width: scaledWidth,
|
|
|
|
height: scaledHeight,
|
2022-08-16 20:12:43 +08:00
|
|
|
x: xOffset,
|
|
|
|
y: yOffset,
|
2023-02-15 00:27:51 +08:00
|
|
|
viewBoxWidth: scaledViewBoxWidth,
|
|
|
|
viewBoxHeight: scaledViewBoxHeight,
|
2017-09-19 06:20:44 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default calculateSlideData;
|