@@ -340,16 +340,16 @@ export default class Preview extends PreviewCollection {
340
340
341
341
// Determine which old neighbour we should modify
342
342
const oldWidth = sourceLinePreview . getResizeUtils ( ) . getColumnWidth ( column ) ;
343
+ let direction = "+1" ;
343
344
344
345
// Retrieve the adjacent column either +1 or -1
345
346
if ( getAdjacentColumn ( column , "+1" ) ) {
346
347
modifyOldNeighbour = getAdjacentColumn ( column , "+1" ) ;
347
348
} else if ( getAdjacentColumn ( column , "-1" ) ) {
349
+ direction = "-1" ;
348
350
modifyOldNeighbour = getAdjacentColumn ( column , "-1" ) ;
349
351
}
350
352
351
- // Set the column to it's smallest column width
352
- updateColumnWidth ( column , this . resizeUtils . getSmallestColumnWidth ( ) ) ;
353
353
// Modify the old neighbour
354
354
let oldNeighbourWidth = 100 ;
355
355
if ( modifyOldNeighbour ) {
@@ -378,19 +378,50 @@ export default class Preview extends PreviewCollection {
378
378
379
379
} ) ;
380
380
} else {
381
- // @todo evaluate if this else is needed
382
381
moveContentType ( column , movePosition . insertIndex , this . contentType ) ;
383
382
if ( modifyOldNeighbour ) {
384
383
updateColumnWidth ( modifyOldNeighbour , oldNeighbourWidth ) ;
385
384
}
386
- const newNeighbourWidth = this . resizeUtils . getAcceptedColumnWidth (
385
+ let newNeighbourWidth = this . resizeUtils . getAcceptedColumnWidth (
387
386
( this . resizeUtils . getColumnWidth ( movePosition . affectedColumn ) -
388
- this . resizeUtils . getSmallestColumnWidth ( ) ) . toString ( ) ,
387
+ oldWidth ) . toString ( ) ,
389
388
) ;
389
+ let newNeighbour = movePosition . affectedColumn ;
390
+ let totalWidthAdjusted = 0 ;
391
+ let newNeighbourIndex = getColumnIndexInLine ( newNeighbour ) ;
392
+ updateColumnWidth ( column , oldWidth ) ;
393
+ while ( true ) {
394
+ //take width from all neighbours in one direction till the entire width is obtained
395
+ if ( newNeighbourWidth <= 0 ) {
396
+ newNeighbourWidth = this . resizeUtils . getSmallestColumnWidth ( ) ;
397
+ let originalWidthOfNeighbour = this . resizeUtils . getColumnWidth ( newNeighbour ) ;
398
+ updateColumnWidth ( newNeighbour , newNeighbourWidth ) ;
399
+ totalWidthAdjusted += ( originalWidthOfNeighbour - newNeighbourWidth ) ;
400
+ } else {
401
+ updateColumnWidth ( newNeighbour , newNeighbourWidth ) ;
402
+ break ;
403
+ }
390
404
391
- // Reduce the affected columns width by the smallest column width
392
- updateColumnWidth ( movePosition . affectedColumn , newNeighbourWidth ) ;
405
+ newNeighbour = getAdjacentColumn ( newNeighbour , direction ) ;
406
+ if ( ! newNeighbour ) {
407
+ updateColumnWidth ( column , oldWidth - totalWidthAdjusted ) ;
408
+ break ;
409
+ }
410
+ let neighbourExistingWidth = this . resizeUtils . getColumnWidth ( newNeighbour ) ;
411
+ newNeighbourWidth = neighbourExistingWidth - ( oldWidth - totalWidthAdjusted ) ;
412
+ if ( newNeighbourWidth < 0.001 ) {
413
+ newNeighbourWidth = 0 ;
414
+ }
393
415
416
+ }
417
+ let totalWidth = 0 ;
418
+ this . contentType . children ( ) . forEach ( ( column : ContentTypeCollectionInterface < ColumnPreview > ) => {
419
+ totalWidth += this . resizeUtils . getColumnWidth ( column ) ;
420
+ } ) ;
421
+ if ( totalWidth > 100 ) {
422
+ //take extra width from newly moved column
423
+ updateColumnWidth ( column , this . resizeUtils . getColumnWidth ( column ) - ( totalWidth - 100 ) ) ;
424
+ }
394
425
}
395
426
396
427
}
0 commit comments