UNPKG

react-image-magnify

Version:

A responsive image zoom component designed for shopping sites.

20 lines (16 loc) 703 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLensCursorOffset = getLensCursorOffset; var _imageRatio = require('./imageRatio'); function getLensCursorOffset(smallImage, largeImage, enlargedImageContainerDimensions) { var ratio = (0, _imageRatio.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); }