react-image-magnify
Version:
A responsive image zoom component designed for shopping sites.
13 lines (11 loc) • 574 B
JavaScript
import { getLargeToSmallImageRatio } from './imageRatio';
export function getLensCursorOffset(smallImage, largeImage, enlargedImageContainerDimensions) {
var ratio = getLargeToSmallImageRatio(smallImage, largeImage);
return {
x: getLensCursorOffsetDimension(enlargedImageContainerDimensions.width, ratio.x),
y: getLensCursorOffsetDimension(enlargedImageContainerDimensions.height, ratio.y)
};
}
function getLensCursorOffsetDimension(enlargedImageContainerDimension, ratio) {
return Math.round(enlargedImageContainerDimension * ratio / 2);
}