@@ -360,8 +360,7 @@ export default class Preview extends PreviewCollection {
360
360
}
361
361
362
362
// Move the content type
363
- if ( this . columnLineDropPlaceholder . hasClass ( "active" )
364
- || this . columnLineBottomDropPlaceholder . hasClass ( "active" ) ) {
363
+ if ( this . columnLineDropPlaceholder . hasClass ( "active" ) ) {
365
364
// if new column line placeholders are visible, add new column line and move column there
366
365
createColumnLine (
367
366
this . contentType . parentContentType ,
@@ -377,7 +376,23 @@ export default class Preview extends PreviewCollection {
377
376
this . fireMountEvent ( this . contentType , column ) ;
378
377
379
378
} ) ;
380
- } else {
379
+ } else if ( this . columnLineBottomDropPlaceholder . hasClass ( "active" ) ) {
380
+ // if new column line placeholders are visible, add new column line and move column there
381
+ createColumnLine (
382
+ this . contentType . parentContentType ,
383
+ this . resizeUtils . getSmallestColumnWidth ( ) ,
384
+ this . getNewColumnLineIndex ( ) ,
385
+ ) . then ( ( columnLine ) => {
386
+
387
+ moveContentType ( column , 0 , columnLine ) ;
388
+ updateColumnWidth ( column , 100 ) ;
389
+ if ( modifyOldNeighbour ) {
390
+ updateColumnWidth ( modifyOldNeighbour , oldNeighbourWidth ) ;
391
+ }
392
+ this . fireMountEvent ( this . contentType , column ) ;
393
+
394
+ } ) ;
395
+ } else {
381
396
moveContentType ( column , movePosition . insertIndex , this . contentType ) ;
382
397
if ( modifyOldNeighbour ) {
383
398
updateColumnWidth ( modifyOldNeighbour , oldNeighbourWidth ) ;
@@ -388,38 +403,42 @@ export default class Preview extends PreviewCollection {
388
403
) ;
389
404
let newNeighbour = movePosition . affectedColumn ;
390
405
let totalWidthAdjusted = 0 ;
391
- let newNeighbourIndex = getColumnIndexInLine ( newNeighbour ) ;
392
406
updateColumnWidth ( column , oldWidth ) ;
393
407
while ( true ) {
394
- //take width from all neighbours in one direction till the entire width is obtained
408
+ // take width from all neighbours in one direction till the entire width is obtained
395
409
if ( newNeighbourWidth <= 0 ) {
396
- newNeighbourWidth = this . resizeUtils . getSmallestColumnWidth ( ) ;
397
- let originalWidthOfNeighbour = this . resizeUtils . getColumnWidth ( newNeighbour ) ;
410
+ newNeighbourWidth = this . resizeUtils . getSmallestColumnWidth ( ) ;
411
+ const originalWidthOfNeighbour = this . resizeUtils . getColumnWidth ( newNeighbour ) ;
398
412
updateColumnWidth ( newNeighbour , newNeighbourWidth ) ;
399
413
totalWidthAdjusted += ( originalWidthOfNeighbour - newNeighbourWidth ) ;
400
414
} else {
401
415
updateColumnWidth ( newNeighbour , newNeighbourWidth ) ;
402
416
break ;
403
417
}
404
418
405
- newNeighbour = getAdjacentColumn ( newNeighbour , direction ) ;
419
+ if ( direction === "+1" ) {
420
+ newNeighbour = getAdjacentColumn ( newNeighbour , "+1" ) ;
421
+ } else {
422
+ newNeighbour = getAdjacentColumn ( newNeighbour , "-1" ) ;
423
+ }
424
+
406
425
if ( ! newNeighbour ) {
407
426
updateColumnWidth ( column , totalWidthAdjusted ) ;
408
427
break ;
409
428
}
410
- let neighbourExistingWidth = this . resizeUtils . getColumnWidth ( newNeighbour ) ;
429
+ const neighbourExistingWidth = this . resizeUtils . getColumnWidth ( newNeighbour ) ;
411
430
newNeighbourWidth = neighbourExistingWidth - ( oldWidth - totalWidthAdjusted ) ;
412
431
if ( newNeighbourWidth < 0.001 ) {
413
432
newNeighbourWidth = 0 ;
414
433
}
415
434
416
435
}
417
436
let totalWidth = 0 ;
418
- this . contentType . children ( ) . forEach ( ( column : ContentTypeCollectionInterface < ColumnPreview > ) => {
419
- totalWidth += this . resizeUtils . getColumnWidth ( column ) ;
437
+ this . contentType . children ( ) . forEach ( ( columnChild : ContentTypeCollectionInterface < ColumnPreview > ) => {
438
+ totalWidth += this . resizeUtils . getColumnWidth ( columnChild ) ;
420
439
} ) ;
421
440
if ( totalWidth > 100 ) {
422
- //take extra width from newly moved column
441
+ // take extra width from newly moved column
423
442
updateColumnWidth ( column , this . resizeUtils . getColumnWidth ( column ) - ( totalWidth - 100 ) ) ;
424
443
}
425
444
}
@@ -784,8 +803,8 @@ export default class Preview extends PreviewCollection {
784
803
// show column line drop placeholder only for top column line in a group
785
804
786
805
return ( this . dropOverElement || draggedColumn ) &&
787
- event . pageY > linePosition . top &&
788
- event . pageY < linePosition . top + this . lineDropperHeight ;
806
+ event . pageY > linePosition . top + 15 &&
807
+ event . pageY < linePosition . top + 15 + this . lineDropperHeight ;
789
808
}
790
809
791
810
/**
@@ -801,8 +820,8 @@ export default class Preview extends PreviewCollection {
801
820
802
821
const draggedColumn = getDragColumn ( ) ;
803
822
return ( this . dropOverElement || draggedColumn ) &&
804
- ( event . pageY < linePosition . top + this . element . outerHeight ( ) &&
805
- event . pageY > linePosition . top + this . element . outerHeight ( ) - this . lineDropperHeight ) ;
823
+ ( event . pageY < linePosition . top + 15 + this . element . outerHeight ( ) &&
824
+ event . pageY > linePosition . top + 15 + this . element . outerHeight ( ) - this . lineDropperHeight ) ;
806
825
807
826
}
808
827
@@ -816,8 +835,8 @@ export default class Preview extends PreviewCollection {
816
835
817
836
const draggedColumn = getDragColumn ( ) ;
818
837
return ( this . dropOverElement || draggedColumn ) &&
819
- event . pageY > linePosition . top + this . lineDropperHeight &&
820
- event . pageY < linePosition . top + linePosition . outerHeight - this . lineDropperHeight ;
838
+ event . pageY > linePosition . top + 15 + this . lineDropperHeight &&
839
+ event . pageY < linePosition . top + 15 + linePosition . outerHeight - this . lineDropperHeight ;
821
840
}
822
841
/**
823
842
* Handle mouse move events on when dropping elements
0 commit comments