@@ -117,6 +117,18 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
117117
118118 ////
119119
120+ private _restrictMove : boolean = false ;
121+
122+ @Input ( ) set restrictMove ( v : boolean ) {
123+ this . _restrictMove = getInputBoolean ( v ) ;
124+ }
125+
126+ get restrictMove ( ) : boolean {
127+ return this . _restrictMove ;
128+ }
129+
130+ ////
131+
120132 private _useTransition : boolean = false ;
121133
122134 @Input ( ) set useTransition ( v : boolean ) {
@@ -349,7 +361,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
349361 this . displayedAreas . forEach ( area => {
350362 area . size = area . component . size ;
351363
352- // Set min/max to area.size if size provided less than min/ more than max
364+ // Set min/max to area.size if size provided ' less than min'/' more than max'
353365 area . minSize = ( area . component . minSize === null ) ? null : ( area . size !== null && area . component . minSize > area . size ? area . size : area . component . minSize ) ;
354366 area . maxSize = ( area . component . maxSize === null ) ? null : ( area . size !== null && area . component . maxSize < area . size ? area . size : area . component . maxSize ) ;
355367 } ) ;
@@ -444,13 +456,23 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
444456 } ;
445457
446458 if ( area . order < gutterOrder ) {
447- this . snapshot . areasBeforeGutter . unshift ( areaSnapshot ) ;
459+ if ( this . restrictMove === true ) {
460+ this . snapshot . areasBeforeGutter = [ areaSnapshot ] ;
461+ }
462+ else {
463+ this . snapshot . areasBeforeGutter . unshift ( areaSnapshot ) ;
464+ }
448465 }
449466 else if ( area . order > gutterOrder ) {
450- this . snapshot . areasAfterGutter . push ( areaSnapshot ) ;
467+ if ( this . restrictMove === true ) {
468+ if ( this . snapshot . areasAfterGutter . length === 0 ) this . snapshot . areasAfterGutter = [ areaSnapshot ] ;
469+ }
470+ else {
471+ this . snapshot . areasAfterGutter . push ( areaSnapshot ) ;
472+ }
451473 }
452474 } ) ;
453- console . log ( 'START' , this . displayedAreas . map ( a => a . size ) , ' TOTAL > ' , this . displayedAreas . map ( a => a . size ) . reduce ( ( t , s ) => t + s , 0 ) , this . snapshot ) ;
475+ // console.log('START', this.displayedAreas.map(a=>a.size), ' TOTAL > ', this.displayedAreas.map(a=>a.size).reduce((t,s)=>t+s, 0), this.snapshot);
454476
455477 if ( this . snapshot . areasBeforeGutter . length === 0 || this . snapshot . areasAfterGutter . length === 0 ) {
456478 return ;
@@ -503,64 +525,64 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
503525
504526 // Need to know if each gutter side areas could reacts to steppedOffset
505527
506- console . groupCollapsed ( 'steppedOffset' , steppedOffset )
528+ // console.groupCollapsed('steppedOffset', steppedOffset)
507529 let areasBefore = getGutterSideAbsorptionCapacity ( this . unit , this . snapshot . areasBeforeGutter , - steppedOffset , this . snapshot . allAreasSizePixel ) ;
508530 let areasAfter = getGutterSideAbsorptionCapacity ( this . unit , this . snapshot . areasAfterGutter , steppedOffset , this . snapshot . allAreasSizePixel ) ;
509531
510- logMe ( this . unit , '--- > ' , areasBefore , areasAfter )
532+ // logMe(this.unit, '--- > ', areasBefore, areasAfter)
511533
512534 // Each gutter side areas can't absorb all offset
513535 if ( areasBefore . remain !== 0 && areasAfter . remain !== 0 ) {
514536 if ( Math . abs ( areasBefore . remain ) === Math . abs ( areasAfter . remain ) ) {
515- logMe ( this . unit , 'AA1 > ' , areasBefore , areasAfter )
537+ // logMe(this.unit, 'AA1 > ', areasBefore, areasAfter)
516538 }
517539 else if ( Math . abs ( areasBefore . remain ) > Math . abs ( areasAfter . remain ) ) {
518540 areasAfter = getGutterSideAbsorptionCapacity ( this . unit , this . snapshot . areasAfterGutter , steppedOffset + areasBefore . remain , this . snapshot . allAreasSizePixel ) ;
519- logMe ( this . unit , 'AA2 > ' , areasBefore , areasAfter )
541+ // logMe(this.unit, 'AA2 > ', areasBefore, areasAfter)
520542 }
521543 else {
522544 areasBefore = getGutterSideAbsorptionCapacity ( this . unit , this . snapshot . areasBeforeGutter , - ( steppedOffset - areasAfter . remain ) , this . snapshot . allAreasSizePixel ) ;
523- logMe ( this . unit , 'AA3 > ' , areasBefore , areasAfter )
545+ // logMe(this.unit, 'AA3 > ', areasBefore, areasAfter)
524546 }
525547 }
526548 // Areas before gutter can't absorbs all offset > need to recalculate sizes for areas after gutter.
527549 else if ( areasBefore . remain !== 0 ) {
528550 areasAfter = getGutterSideAbsorptionCapacity ( this . unit , this . snapshot . areasAfterGutter , steppedOffset + areasBefore . remain , this . snapshot . allAreasSizePixel ) ;
529- logMe ( this . unit , 'BBB > ' , areasBefore , areasAfter )
551+ // logMe(this.unit, 'BBB > ', areasBefore, areasAfter)
530552 }
531553 // Areas after gutter can't absorbs all offset > need to recalculate sizes for areas before gutter.
532554 else if ( areasAfter . remain !== 0 ) {
533555 areasBefore = getGutterSideAbsorptionCapacity ( this . unit , this . snapshot . areasBeforeGutter , - ( steppedOffset - areasAfter . remain ) , this . snapshot . allAreasSizePixel ) ;
534- logMe ( this . unit , 'CCC > ' , areasBefore , areasAfter )
535- }
536- else {
537- logMe ( this . unit , 'DDD > ' , areasBefore , areasAfter )
538- //debugger;
556+ //logMe(this.unit, 'CCC > ', areasBefore, areasAfter)
539557 }
558+ //else {
559+ //logMe(this.unit, 'DDD > ', areasBefore, areasAfter)
560+ //}
540561
541-
562+ /*
542563 function logMe(unit, txt, lBefore, lAfter) {
543564 // PERCENT
544565 if(unit === 'percent') {
545- console . log ( txt , lBefore . remain , ' ¤ ' , lAfter . remain , ' // ' , ...lBefore . list . map ( a => a . percentAfterAbsorption ) . reverse ( ) , ' ¤ ' , ...lAfter . list . map ( a => a . percentAfterAbsorption ) )
566+ // console.log(txt, lBefore.remain, ' ¤ ', lAfter.remain, ' // ', ...lBefore.list.map(a=>a.percentAfterAbsorption).reverse(), ' ¤ ', ...lAfter.list.map(a=>a.percentAfterAbsorption))
546567 }
547568 // PIXEL
548569 else {
549- console . log ( txt , lBefore . remain , ' ¤ ' , lAfter . remain , ' // ' , ...lBefore . list . map ( a => a . pixelAbsorb ) . reverse ( ) , ' ¤ ' , ...lAfter . list . map ( a => a . pixelAbsorb ) )
570+ // console.log(txt, lBefore.remain, ' ¤ ', lAfter.remain, ' // ', ...lBefore.list.map(a=>a.pixelAbsorb).reverse(), ' ¤ ', ...lAfter.list.map(a=>a.pixelAbsorb))
550571 }
551572 }
552-
573+ */
553574
554575 if ( this . unit === 'percent' ) {
555576 // Hack because of browser messing up with sizes using calc(X% - Ypx) -> el.getBoundingClientRect()
556577 // If not there, playing with gutters makes total going down to 99.99875% then 99.99286%, 99.98986%,..
557578 const all = [ ...areasBefore . list , ...areasAfter . list ] ;
579+ const allPercent = all . reduce ( ( t , a ) => t + a . areaSnapshot . sizePercentAtStart , 0 ) ;
558580 const areaToReset = all . find ( a => a . percentAfterAbsorption !== 0 && a . percentAfterAbsorption !== a . areaSnapshot . area . minSize && a . percentAfterAbsorption !== a . areaSnapshot . area . maxSize )
559581
560582 if ( areaToReset ) {
561583 const x = areaToReset . percentAfterAbsorption ;
562- areaToReset . percentAfterAbsorption = 100 - all . filter ( a => a !== areaToReset ) . reduce ( ( total , a ) => total + a . percentAfterAbsorption , 0 ) ;
563- console . log ( 'ZZZZZZZ areaToReset' , areaToReset , 'before=' , x , ' after=' , areaToReset . percentAfterAbsorption )
584+ areaToReset . percentAfterAbsorption = allPercent - all . filter ( a => a !== areaToReset ) . reduce ( ( total , a ) => total + a . percentAfterAbsorption , 0 ) ;
585+ // console.log('ZZZZZZZ areaToReset', areaToReset, 'before=', x, ' after=', areaToReset.percentAfterAbsorption)
564586 }
565587 }
566588
@@ -571,12 +593,12 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
571593 areasAfter . list . forEach ( item => updateAreaSize ( this . unit , item ) ) ;
572594
573595 const ttt = this . displayedAreas . map ( a => a . size ) . reduce ( ( t , s ) => t + s , 0 ) ;
574- console . log ( 'all a.size = ' , ttt )
596+ // console.log('all a.size = ', ttt)
575597
576598 this . refreshStyleSizes ( ) ;
577599 this . notify ( 'progress' , this . snapshot . gutterNum ) ;
578600
579- console . groupEnd ( )
601+ // console.groupEnd()
580602 }
581603
582604 private stopDragging ( event ?: Event ) : void {
0 commit comments