@@ -46,7 +46,13 @@ import {CDK_DRAG_PARENT} from '../drag-parent';
4646import { DragRef , Point , PreviewContainer } from '../drag-ref' ;
4747import type { CdkDropList } from './drop-list' ;
4848import { DragDrop } from '../drag-drop' ;
49- import { CDK_DRAG_CONFIG , DragDropConfig , DragStartDelay , DragAxis } from './config' ;
49+ import {
50+ CDK_DRAG_CONFIG ,
51+ DragDropConfig ,
52+ DragStartDelay ,
53+ DragAxis ,
54+ DragStartPredicate ,
55+ } from './config' ;
5056import { assertElementNode } from './assertions' ;
5157import { DragDropRegistry } from '../drag-drop-registry' ;
5258
@@ -114,6 +120,9 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
114120 */
115121 @Input ( 'cdkDragStartDelay' ) dragStartDelay : DragStartDelay ;
116122
123+ /** Function that is used to determine whether a drag operation is allowed to start. */
124+ @Input ( 'cdkDragStartPredicate' ) dragStartPredicate ?: DragStartPredicate ;
125+
117126 /**
118127 * Sets the position of a `CdkDrag` that is outside of a drop container.
119128 * Can be used to restore the element's position for a returning user.
@@ -430,6 +439,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
430439 if ( ! ref . isDragging ( ) ) {
431440 const dir = this . _dir ;
432441 const dragStartDelay = this . dragStartDelay ;
442+ const dragStartPredicate = this . dragStartPredicate ;
433443 const placeholder = this . _placeholderTemplate
434444 ? {
435445 template : this . _placeholderTemplate . templateRef ,
@@ -453,6 +463,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
453463 typeof dragStartDelay === 'object' && dragStartDelay
454464 ? dragStartDelay
455465 : coerceNumberProperty ( dragStartDelay ) ;
466+ ref . dragStartPredicate = dragStartPredicate ;
456467 ref . constrainPosition = this . constrainPosition ;
457468 ref . previewClass = this . previewClass ;
458469 ref
0 commit comments