import { Dimension } from "../../../.." ; import ResizeDebugHandler from "./ResizeDebugHandler" ; export default class DefaultResizeDebugHandler implements ResizeDebugHandler { private readonly relaxation : Dimension ; private readonly onRelaxationViolation : ( expectedDim : Dimension , actualDim : Dimension , index : number ) => void ; public constructor ( relaxation , onRelaxationViolation ) { this . relaxation = relaxation ; this . onRelaxationViolation = onRelaxationViolation ; } public resizeDebug ( oldDim , newDim , index ) { let isViolated = false ; if ( this . relaxation . height >= 0 && Math . abs ( newDim . height - oldDim . height ) >= this . relaxation . height ) { isViolated = true ; } if ( ! isViolated && this . relaxation . width >= 0 && Math . abs ( newDim . width - oldDim . width ) >= this . relaxation . width ) { isViolated = true ; } if ( isViolated ) { this . onRelaxationViolation ( oldDim , newDim , index ) ; } } }