import { RefObject } from 'react' ; import { IframeOffsetType } from '../interface' ; const useIframeOffset = ( iframeRef ) : IframeOffsetType | undefined => { const iframeRect = iframeRef . current ?. getBoundingClientRect ( ) ; let iframeOffset ; if ( iframeRect ?. x !== undefined && iframeRect ?. y !== undefined ) { iframeOffset = { x : iframeRect . x , y : iframeRect . y } ; } return iframeOffset ; } ; export default useIframeOffset ;