@@ -47,6 +47,36 @@ describe('gridstack engine:', () => {
4747 } ) ;
4848 } ) ;
4949
50+ describe ( '3447 dragging past an overlapping edge >' , ( ) => {
51+ [
52+ { name : 'up' , target : { x : 0 , y : 0 , w : 10 , h : 2 } , start : { x : 8 , y : 2 , w : 4 , h : 1 } , mid : { x : 8 , y : 1 } , end : { x : 8 , y : 0 } , targetY : 1 } ,
53+ { name : 'down' , target : { x : 2 , y : 1 , w : 10 , h : 2 } , start : { x : 0 , y : 0 , w : 4 , h : 1 } , mid : { x : 0 , y : 1 } , end : { x : 0 , y : 2 } , targetY : 3 } ,
54+ { name : 'left' , target : { x : 0 , y : 0 , w : 2 , h : 10 } , start : { x : 2 , y : 8 , w : 1 , h : 4 } , mid : { x : 1 , y : 8 } , end : { x : 0 , y : 8 } , targetY : 12 } ,
55+ { name : 'right' , target : { x : 1 , y : 2 , w : 2 , h : 10 } , start : { x : 0 , y : 0 , w : 1 , h : 4 } , mid : { x : 1 , y : 0 } , end : { x : 2 , y : 0 } , targetY : 4 } ,
56+ ] . forEach ( ( { name, target, start, mid, end, targetY} ) => {
57+ it ( `can drag ${ name } when the other axis already overlaps` , ( ) => {
58+ e = new GridStackEngine ( { mode : 'float' , column : 12 } ) ;
59+ const other = e . addNode ( { ...target , id : 'target' } ) ;
60+ const move = e . addNode ( { ...start , id : 'move' } ) ;
61+ e . cleanNodes ( ) . beginUpdate ( move ) ;
62+ move . _moving = true ;
63+ e . cacheRects ( 50 , 50 , 0 , 0 , 0 , 0 ) ;
64+
65+ // Exactly half of the target is still too little to push it.
66+ e . moveNodeCheck ( move , { ...mid , rect : { x : mid . x * 50 , y : mid . y * 50 , w : start . w * 50 , h : start . h * 50 } } ) ;
67+ expect ( move ) . toEqual ( expect . objectContaining ( start ) ) ;
68+ expect ( other ) . toEqual ( expect . objectContaining ( target ) ) ;
69+
70+ e . moveNodeCheck ( move , { ...end , rect : { x : end . x * 50 , y : end . y * 50 , w : start . w * 50 , h : start . h * 50 } } ) ;
71+
72+ expect ( move ) . toEqual ( expect . objectContaining ( end ) ) ;
73+ expect ( other . y ) . toBe ( targetY ) ;
74+ expect ( overlaps ( e ) ) . toEqual ( [ ] ) ;
75+ e . endUpdate ( ) ;
76+ } ) ;
77+ } ) ;
78+ } ) ;
79+
5080 describe ( 'test constructor >' , ( ) => {
5181
5282 it ( 'should be setup properly' , ( ) => {
0 commit comments