UNPKG

react-native-zoom-toolkit

Version:

Most complete set of pinch to zoom utilites for React Native

27 lines (26 loc) 893 B
export const getVisibleRect = options => { 'worklet'; const { scale, translation, itemSize, containerSize } = options; const offsetX = (itemSize.width * scale - containerSize.width) / 2; const offsetY = (itemSize.height * scale - containerSize.height) / 2; const clampedX = Math.max(offsetX, 0); const clampedY = Math.max(offsetY, 0); const reducerX = (-1 * translation.x + clampedX) / (itemSize.width * scale); const reducerY = (-1 * translation.y + clampedY) / (itemSize.height * scale); const x = itemSize.width * reducerX; const y = itemSize.height * reducerY; const width = itemSize.width * Math.min(1, containerSize.width / (itemSize.width * scale)); const height = itemSize.height * Math.min(1, containerSize.height / (itemSize.height * scale)); return { x, y, width, height }; }; //# sourceMappingURL=getVisibleRect.js.map