Skip to content

Commit e2938a0

Browse files
committed
fix(cdk/drag-drop): change type in CdkDrag for input cdkDragConstrainPosition
Impot the type from the configuration CdkDrag for input cdkDragConstrainPosition, which leads to type safety.
1 parent 0abfecd commit e2938a0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/cdk/drag-drop/directives/drag.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ import {CDK_DRAG_PARENT} from '../drag-parent';
4646
import {DragRef, Point, PreviewContainer} from '../drag-ref';
4747
import type {CdkDropList} from './drop-list';
4848
import {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+
DragConstrainPosition,
55+
} from './config';
5056
import {assertElementNode} from './assertions';
5157
import {DragDropRegistry} from '../drag-drop-registry';
5258

@@ -137,12 +143,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
137143
* of the user's pointer on the page, a reference to the item being dragged and its dimensions.
138144
* Should return a point describing where the item should be rendered.
139145
*/
140-
@Input('cdkDragConstrainPosition') constrainPosition?: (
141-
userPointerPosition: Point,
142-
dragRef: DragRef,
143-
dimensions: DOMRect,
144-
pickupPositionInElement: Point,
145-
) => Point;
146+
@Input('cdkDragConstrainPosition') constrainPosition?: DragConstrainPosition;
146147

147148
/** Class to be added to the preview element. */
148149
@Input('cdkDragPreviewClass') previewClass: string | string[];

tools/public_api_guard/cdk/drag-drop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
5050
// (undocumented)
5151
_addHandle(handle: CdkDragHandle): void;
5252
boundaryElement: string | ElementRef<HTMLElement> | HTMLElement;
53-
constrainPosition?: (userPointerPosition: Point, dragRef: DragRef, dimensions: DOMRect, pickupPositionInElement: Point) => Point;
53+
constrainPosition?: DragConstrainPosition;
5454
data: T;
5555
get disabled(): boolean;
5656
set disabled(value: boolean);

0 commit comments

Comments
 (0)