@@ -24,14 +24,16 @@ import {filter, takeUntil} from 'rxjs/operators';
24
24
25
25
import { _closest } from '@angular/cdk-experimental/popover-edit' ;
26
26
27
- import { HEADER_ROW_SELECTOR } from './constants ' ;
27
+ import { HEADER_ROW_SELECTOR } from './selectors ' ;
28
28
import { ResizeOverlayHandle } from './overlay-handle' ;
29
29
import { ColumnResize } from './column-resize' ;
30
30
import { ColumnSizeAction , ColumnResizeNotifierSource } from './column-resize-notifier' ;
31
31
import { HeaderRowEventDispatcher } from './event-dispatcher' ;
32
32
import { ResizeRef } from './resize-ref' ;
33
33
import { ResizeStrategy } from './resize-strategy' ;
34
34
35
+ const OVERLAY_ACTIVE_CLASS = 'cdk-resizable-overlay-thumb-active' ;
36
+
35
37
/**
36
38
* Base class for Resizable directives which are applied to column headers to make those columns
37
39
* resizable.
@@ -108,6 +110,10 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
108
110
protected abstract getOverlayHandleComponentType ( ) : Type < HandleComponent > ;
109
111
110
112
private _createOverlayForHandle ( ) : OverlayRef {
113
+ // Use of overlays allows us to properly capture click events spanning parts
114
+ // of two table cells and is also useful for displaying a resize thumb
115
+ // over both cells and extending it down the table as needed.
116
+
111
117
const positionStrategy = this . overlay . position ( )
112
118
. flexibleConnectedTo ( this . elementRef . nativeElement ! )
113
119
. withFlexibleDimensions ( false )
@@ -163,30 +169,38 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
163
169
this . _applySize ( size ) ;
164
170
165
171
if ( completeImmediately ) {
166
- this . ngZone . run ( ( ) => {
167
- this . resizeNotifier . resizeCompleted . next ( {
168
- columnId : this . columnDef . name ,
169
- size : this . elementRef . nativeElement ! . offsetWidth ,
170
- } ) ;
171
- } ) ;
172
+ this . _completeResizeOperation ( ) ;
172
173
}
173
174
} ) ;
174
175
175
176
merge (
176
177
this . resizeNotifier . resizeCanceled ,
177
178
this . resizeNotifier . resizeCompleted ,
178
179
) . pipe ( takeUntilDestroyed ) . subscribe ( columnSize => {
179
- this . elementRef . nativeElement ! . classList . remove ( OVERLAY_ACTIVE_CLASS ) ;
180
+ this . _cleanUpAfterResize ( columnSize ) ;
181
+ } ) ;
182
+ }
183
+
184
+ private _completeResizeOperation ( ) : void {
185
+ this . ngZone . run ( ( ) => {
186
+ this . resizeNotifier . resizeCompleted . next ( {
187
+ columnId : this . columnDef . name ,
188
+ size : this . elementRef . nativeElement ! . offsetWidth ,
189
+ } ) ;
190
+ } ) ;
191
+ }
180
192
181
- if ( this . overlayRef && this . overlayRef . hasAttached ( ) ) {
182
- this . _updateOverlayHandleHeight ( ) ;
183
- this . overlayRef . updatePosition ( ) ;
193
+ private _cleanUpAfterResize ( columnSize : ColumnSizeAction ) : void {
194
+ this . elementRef . nativeElement ! . classList . remove ( OVERLAY_ACTIVE_CLASS ) ;
184
195
185
- if ( columnSize . columnId === this . columnDef . name ) {
186
- this . inlineHandle ! . focus ( ) ;
187
- }
196
+ if ( this . overlayRef && this . overlayRef . hasAttached ( ) ) {
197
+ this . _updateOverlayHandleHeight ( ) ;
198
+ this . overlayRef . updatePosition ( ) ;
199
+
200
+ if ( columnSize . columnId === this . columnDef . name ) {
201
+ this . inlineHandle ! . focus ( ) ;
188
202
}
189
- } ) ;
203
+ }
190
204
}
191
205
192
206
private _createHandlePortal ( ) : ComponentPortal < HandleComponent > {
@@ -234,5 +248,3 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
234
248
this . elementRef . nativeElement ! . appendChild ( this . inlineHandle ) ;
235
249
}
236
250
}
237
-
238
- const OVERLAY_ACTIVE_CLASS = 'cdk-resizable-overlay-thumb-active' ;
0 commit comments