@@ -129,7 +129,7 @@ export interface Props {
129129 } ;
130130 size ?: Size ;
131131 resizeGrid ?: Grid ;
132- bounds ?: string ;
132+ bounds ?: string | Element ;
133133 onMouseDown ?: ( e : MouseEvent ) => void ;
134134 onMouseUp ?: ( e : MouseEvent ) => void ;
135135 onResizeStart ?: RndResizeStartCallback ;
@@ -330,8 +330,10 @@ export class Rnd extends React.PureComponent<Props, State> {
330330 const right = ( window . innerWidth - this . resizable . size . width * scale ) / scale + left ;
331331 const bottom = ( window . innerHeight - this . resizable . size . height * scale ) / scale + top ;
332332 return this . setState ( { bounds : { top, right, bottom, left } } ) ;
333- } else {
333+ } else if ( typeof this . props . bounds === "string" ) {
334334 boundary = document . querySelector ( this . props . bounds ) ;
335+ } else if ( this . props . bounds instanceof HTMLElement ) {
336+ boundary = this . props . bounds ;
335337 }
336338 if ( ! ( boundary instanceof HTMLElement ) || ! ( parent instanceof HTMLElement ) ) {
337339 return ;
@@ -405,8 +407,10 @@ export class Rnd extends React.PureComponent<Props, State> {
405407 boundary = document . body ;
406408 } else if ( this . props . bounds === "window" ) {
407409 boundary = window ;
408- } else {
410+ } else if ( typeof this . props . bounds === "string" ) {
409411 boundary = document . querySelector ( this . props . bounds ) ;
412+ } else if ( this . props . bounds instanceof HTMLElement ) {
413+ boundary = this . props . bounds ;
410414 }
411415
412416 const self = this . getSelfElement ( ) ;
@@ -566,7 +570,6 @@ export class Rnd extends React.PureComponent<Props, State> {
566570 left : selfRect . left - parentLeft + scrollLeft - position . x * scale ,
567571 top : selfRect . top - parentTop + scrollTop - position . y * scale ,
568572 } ;
569-
570573 }
571574
572575 refDraggable = ( c : $TODO ) => {
0 commit comments