@@ -52,6 +52,7 @@ import {takeUntil} from 'rxjs/operators';
5252 exportAs : 'cdkDrag' ,
5353 host : {
5454 'class' : 'cdk-drag' ,
55+ '[class.cdk-drag-dragging]' : '_isDragging()' ,
5556 '(mousedown)' : '_startDragging($event)' ,
5657 '(touchstart)' : '_startDragging($event)' ,
5758 }
@@ -189,7 +190,7 @@ export class CdkDrag<T = any> implements OnDestroy {
189190
190191 // Do this check before removing from the registry since it'll
191192 // stop being considered as dragged once it is removed.
192- if ( this . _dragDropRegistry . isDragging ( this ) ) {
193+ if ( this . _isDragging ( ) ) {
193194 // Since we move out the element to the end of the body while it's being
194195 // dragged, we have to make sure that it's removed if it gets destroyed.
195196 this . _removeElement ( this . element . nativeElement ) ;
@@ -220,11 +221,16 @@ export class CdkDrag<T = any> implements OnDestroy {
220221 }
221222 }
222223
224+ /** Checks whether the element is currently being dragged. */
225+ _isDragging ( ) {
226+ return this . _dragDropRegistry . isDragging ( this ) ;
227+ }
228+
223229 /** Handler for when the pointer is pressed down on the element or the handle. */
224230 private _pointerDown = ( referenceElement : ElementRef < HTMLElement > ,
225231 event : MouseEvent | TouchEvent ) => {
226232
227- const isDragging = this . _dragDropRegistry . isDragging ( this ) ;
233+ const isDragging = this . _isDragging ( ) ;
228234
229235 // Abort if the user is already dragging or is using a mouse button other than the primary one.
230236 if ( isDragging || ( ! this . _isTouchEvent ( event ) && event . button !== 0 ) ) {
@@ -274,7 +280,7 @@ export class CdkDrag<T = any> implements OnDestroy {
274280 private _pointerMove = ( event : MouseEvent | TouchEvent ) => {
275281 // TODO(crisbeto): this should start dragging after a certain threshold,
276282 // otherwise we risk interfering with clicks on the element.
277- if ( ! this . _dragDropRegistry . isDragging ( this ) ) {
283+ if ( ! this . _isDragging ( ) ) {
278284 return ;
279285 }
280286
@@ -310,7 +316,7 @@ export class CdkDrag<T = any> implements OnDestroy {
310316
311317 /** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */
312318 private _pointerUp = ( ) => {
313- if ( ! this . _dragDropRegistry . isDragging ( this ) ) {
319+ if ( ! this . _isDragging ( ) ) {
314320 return ;
315321 }
316322
0 commit comments