import { ComputeLayout } from './interface' ; import { calculateOneStepTransform , calculateCenteredTranslate } from './utils' ; export default ( overlap ) : ComputeLayout => { const containerScale = 2 - overlap ; return ( containerSize , imageSize ) => { const autoScale = containerSize . height * containerScale / imageSize . height ; const scale = ( imageSize . width * autoScale > containerSize . width ) ? containerSize . width / imageSize . width : autoScale ; if ( imageSize . height * scale <= containerSize . height ) { return calculateOneStepTransform ( scale , containerSize , imageSize ) ; } const left = calculateCenteredTranslate ( scale , containerSize . width , imageSize . width ) ; return [ { scale : scale , translateX : left , translateY : 0 } , { scale : scale , translateX : left , translateY : ( containerSize . height - imageSize . height * scale ) / scale } , ] ; } ; } ;