@@ -2,7 +2,7 @@ import { Component, Input, Output, ChangeDetectionStrategy, ChangeDetectorRef, R
22import { Observable , Subscriber , Subject } from 'rxjs' ;
33import { debounceTime } from 'rxjs/operators' ;
44
5- import { IArea , IPoint , ISplitSnapshot , IAreaSnapshot } from '../interface' ;
5+ import { IArea , IPoint , ISplitSnapshot , IAreaSnapshot , ISplitSideAbsorptionSnapshot } from '../interface' ;
66import { SplitAreaDirective } from '../directive/splitArea.directive' ;
77import { getInputPositiveNumber , getInputBoolean , getPointFromEvent , getElementPixelSize , getAreaAbsorptionCapacity , isValidTotalSize } from '../utils' ;
88
@@ -152,8 +152,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
152152 private _dir : 'ltr' | 'rtl' = 'ltr' ;
153153
154154 @Input ( ) set dir ( v : 'ltr' | 'rtl' ) {
155- v = ( v === 'rtl' ) ? 'rtl' : 'ltr' ;
156- this . _dir = v ;
155+ this . _dir = ( v === 'rtl' ) ? 'rtl' : 'ltr' ;
157156
158157 this . renderer . setAttribute ( this . elRef . nativeElement , 'dir' , this . _dir ) ;
159158 }
@@ -424,9 +423,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
424423 event . stopPropagation ( ) ;
425424
426425 if ( this . startPoint && this . startPoint . x === event . clientX && this . startPoint . y === event . clientY ) {
427- this . currentGutterNum = gutterNum ;
428-
429- this . notify ( 'click' ) ;
426+ this . notify ( 'click' , gutterNum ) ;
430427 }
431428 }
432429
@@ -483,7 +480,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
483480 this . renderer . addClass ( this . elRef . nativeElement , 'is-dragging' ) ;
484481 this . renderer . addClass ( this . gutterEls . toArray ( ) [ this . snapshot . gutterNum - 1 ] . nativeElement , 'is-dragged' ) ;
485482
486- this . notify ( 'start' ) ;
483+ this . notify ( 'start' , this . snapshot . gutterNum ) ;
487484 }
488485
489486 private dragEvent ( event : MouseEvent | TouchEvent , areaA : IArea , areaB : IArea ) : void {
@@ -511,7 +508,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
511508
512509 this . snapshot . lastSteppedOffset = steppedOffset ;
513510
514- const areasBefore = this . snapshot . areasBeforeGutter . reduce ( ( acc , area ) => {
511+ const areasBefore : ISplitSideAbsorptionSnapshot = this . snapshot . areasBeforeGutter . reduce ( ( acc , area ) => {
515512 const res = getAreaAbsorptionCapacity ( this . unit , area , acc . remain ) ;
516513 acc . list . push ( res ) ;
517514 acc . remain = res . remain ;
@@ -520,7 +517,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
520517
521518 if ( areasBefore . remain !== 0 ) return ;
522519
523- const areasAfter = this . snapshot . areasAfterGutter . reduce ( ( acc , a ) => {
520+ const areasAfter : ISplitSideAbsorptionSnapshot = this . snapshot . areasAfterGutter . reduce ( ( acc , a ) => {
524521 const res = getAreaAbsorptionCapacity ( this . unit , a , acc . remain ) ;
525522 acc . list . push ( res ) ;
526523 acc . remain = res . remain ;
@@ -540,16 +537,28 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
540537 // }
541538
542539 areasBefore . list . forEach ( ( e , i ) => {
543- if ( e . )
540+ if ( e . absorb > 0 ) {
541+ if ( this . unit === 'percent' ) {
542+
543+ }
544+ else if ( this . unit === 'pixel' ) {
545+ if ( e . areaSnapshot . area . size === null ) {
546+
547+ }
548+ else {
549+ e . areaSnapshot . area . size -= e . absorb ;
550+ }
551+ }
552+ }
544553 } ) ;
545554
546555 this . refreshStyleSizes ( ) ;
547556
548557 // If moved from starting point, notify progress
549558 // TODO test but normally, IF condition is not needed because L513 "if(steppedOffset === this.snapshot.lastSteppedOffset)..."
550- if ( this . startPoint . x !== this . endPoint . x || this . startPoint . y !== this . endPoint . y ) {
551- this . notify ( 'progress' ) ;
552- }
559+ // if(this.startPoint.x !== this.endPoint.x || this.startPoint.y !== this.endPoint.y) {
560+ this . notify ( 'progress' , this . snapshot . gutterNum ) ;
561+ // }
553562 }
554563
555564 private stopDragging ( event ?: Event ) : void {
@@ -575,7 +584,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
575584
576585 // If moved from starting point, notify end
577586 if ( event && this . endPoint && ( this . startPoint . x !== this . endPoint . x || this . startPoint . y !== this . endPoint . y ) ) {
578- this . notify ( 'end' ) ;
587+ this . notify ( 'end' , this . snapshot . gutterNum ) ;
579588 }
580589
581590 this . isDragging = false ;
@@ -592,22 +601,22 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
592601 } ) ;
593602 }
594603
595- public notify ( type : 'start' | 'progress' | 'end' | 'click' | 'transitionEnd' ) : void {
604+ public notify ( type : 'start' | 'progress' | 'end' | 'click' | 'transitionEnd' , gutterNum : number ) : void {
596605 const sizes : Array < number > = this . displayedAreas . map ( a => a . size * 100 ) ;
597606
598607 if ( type === 'start' ) {
599608 if ( this . dragStartSubscriber ) {
600- this . ngZone . run ( ( ) => this . dragStartSubscriber . next ( { gutterNum : this . snapshot . gutterNum , sizes} ) ) ;
609+ this . ngZone . run ( ( ) => this . dragStartSubscriber . next ( { gutterNum, sizes} ) ) ;
601610 }
602611 }
603612 else if ( type === 'end' ) {
604613 if ( this . dragEndSubscriber ) {
605- this . ngZone . run ( ( ) => this . dragEndSubscriber . next ( { gutterNum : this . snapshot . gutterNum , sizes} ) ) ;
614+ this . ngZone . run ( ( ) => this . dragEndSubscriber . next ( { gutterNum, sizes} ) ) ;
606615 }
607616 }
608617 else if ( type === 'click' ) {
609618 if ( this . gutterClickSubscriber ) {
610- this . ngZone . run ( ( ) => this . gutterClickSubscriber . next ( { gutterNum : this . snapshot . gutterNum , sizes} ) ) ;
619+ this . ngZone . run ( ( ) => this . gutterClickSubscriber . next ( { gutterNum, sizes} ) ) ;
611620 }
612621 }
613622 else if ( type === 'transitionEnd' ) {
@@ -617,7 +626,7 @@ export class SplitComponent implements AfterViewInit, OnDestroy {
617626 }
618627 else if ( type === 'progress' ) {
619628 // Stay outside zone to allow users do what they want about change detection mechanism.
620- this . dragProgressSubject . next ( { gutterNum : this . snapshot . gutterNum , sizes} ) ;
629+ this . dragProgressSubject . next ( { gutterNum, sizes} ) ;
621630 }
622631 }
623632
0 commit comments