@@ -15,7 +15,7 @@ import {
15
15
import cn from 'classnames/bind' ;
16
16
import dayjs from 'dayjs' ;
17
17
import { observer } from 'mobx-react' ;
18
- import Draggable from 'react-draggable' ;
18
+ import Draggable , { DraggableData , DraggableEvent } from 'react-draggable' ;
19
19
20
20
import Block from 'components/GBlock/Block' ;
21
21
import Modal from 'components/Modal/Modal' ;
@@ -106,6 +106,10 @@ const RotationForm = observer((props: RotationFormProps) => {
106
106
107
107
const [ errors , setErrors ] = useState < { [ key : string ] : string [ ] } > ( { } ) ;
108
108
109
+ const [ bounds , setDraggableBounds ] = useState < { left : number ; right : number ; top : number ; bottom : number } > (
110
+ undefined
111
+ ) ;
112
+
109
113
const [ rotationName , setRotationName ] = useState < string > ( `[L${ layerPriority } ] Rotation` ) ;
110
114
const [ isOpen , setIsOpen ] = useState < boolean > ( false ) ;
111
115
const [ offsetTop , setOffsetTop ] = useState < number > ( 0 ) ;
@@ -423,7 +427,8 @@ const RotationForm = observer((props: RotationFormProps) => {
423
427
handle = ".drag-handler"
424
428
defaultClassName = { cx ( 'draggable' ) }
425
429
positionOffset = { { x : 0 , y : offsetTop } }
426
- bounds = { { top : 0 } }
430
+ bounds = { bounds || 'body' }
431
+ onStart = { onDraggableInit }
427
432
>
428
433
< div { ...props } > { children } </ div >
429
434
</ Draggable >
@@ -457,7 +462,7 @@ const RotationForm = observer((props: RotationFormProps) => {
457
462
</ HorizontalGroup >
458
463
</ HorizontalGroup >
459
464
</ div >
460
- < div className = { cx ( 'body ' ) } >
465
+ < div className = { cx ( 'container ' ) } >
461
466
< div className = { cx ( 'content' ) } >
462
467
< VerticalGroup spacing = "none" >
463
468
{ hasUpdatedShift && (
@@ -684,6 +689,20 @@ const RotationForm = observer((props: RotationFormProps) => {
684
689
) }
685
690
</ >
686
691
) ;
692
+
693
+ function onDraggableInit ( _e : DraggableEvent , data : DraggableData ) {
694
+ if ( ! data ) {
695
+ return ;
696
+ }
697
+
698
+ const scrollbarView = document . querySelector ( '.scrollbar-view' ) ?. getBoundingClientRect ( ) ;
699
+
700
+ const x = data . node . offsetLeft ;
701
+ const top = - data . node . offsetTop + ( scrollbarView ?. top || 100 ) ;
702
+ const bottom = window . innerHeight - ( data . node . offsetTop + data . node . offsetHeight ) ;
703
+
704
+ setDraggableBounds ( { left : - x , right : x , top : top - offsetTop , bottom : bottom - offsetTop } ) ;
705
+ }
687
706
} ) ;
688
707
689
708
interface ShiftPeriodProps {
0 commit comments