import $ from 'jquery' ; param margin export const elementContains = ( el , x , y , margin ? ) : boolean => { margin = margin || 0 ; const { top , left , width , height } = el . getBoundingClientRect ( ) ; return x >= left - margin && x <= left + width + margin && y >= top - margin && y <= top + height + margin ; } ; /**
 * Gets the offset of an element "e1" relative to another element "e2".
 */ export const elementOffset = ( e1 , e2 ) : JQuery . Coordinates => { const offset1 = e1 . offset ( ) as JQuery . Coordinates ; const offset2 = e2 . offset ( ) as JQuery . Coordinates ; return { left : offset1 . left - offset2 . left , top : offset1 . top - offset2 . top } ; } ; /**
 * Gets the offset of a mouse event relative to a given element.
 */ export const mouseOffset = ( evt , e ) : JQuery . Coordinates => { const offset = e . offset ( ) as JQuery . Coordinates ; const paddingLeft = parseInt ( e . css ( 'padding-left' ) , 10 ) ; const paddingTop = parseInt ( e . css ( 'padding-top' ) , 10 ) ; return { left : evt . pageX - offset . left - paddingLeft , top : evt . pageY - offset . top - paddingTop } ; } ; /**
 * Checks if two boxes (rectangles) are equal.
 */ export const areBoxesEqual = ( a , b ) : boolean => { return a . x === b . x && a . y === b . y && a . width === b . width && a . height === b . height ; } ;