Skip to content

Commit 8c107b9

Browse files
committed
fix(cdk/drag-drop): change type in CdkRef for property constrainPosition
Impot the type from the configuration CdkRef for property constrainPosition, which leads to type safety.
1 parent e2938a0 commit 8c107b9

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import {DragDropRegistry} from './drag-drop-registry';
3636
import type {DropListRef} from './drop-list-ref';
3737
import {DragPreviewTemplate, PreviewRef} from './preview-ref';
38+
import {DragConstrainPosition} from './directives/config';
3839

3940
/** Object that can be used to configure the behavior of DragRef. */
4041
export interface DragRefConfig {
@@ -364,12 +365,7 @@ export class DragRef<T = any> {
364365
* of the user's pointer on the page, a reference to the item being dragged and its dimensions.
365366
* Should return a point describing where the item should be rendered.
366367
*/
367-
constrainPosition?: (
368-
userPointerPosition: Point,
369-
dragRef: DragRef,
370-
dimensions: DOMRect,
371-
pickupPositionInElement: Point,
372-
) => Point;
368+
constrainPosition?: DragConstrainPosition;
373369

374370
constructor(
375371
element: ElementRef<HTMLElement> | HTMLElement,

tools/public_api_guard/cdk/drag-drop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ export class DragDropRegistry<_ = unknown, __ = unknown> implements OnDestroy {
381381
export class DragRef<T = any> {
382382
constructor(element: ElementRef<HTMLElement> | HTMLElement, _config: DragRefConfig, _document: Document, _ngZone: NgZone, _viewportRuler: ViewportRuler, _dragDropRegistry: DragDropRegistry, _renderer: Renderer2);
383383
readonly beforeStarted: Subject<void>;
384-
constrainPosition?: (userPointerPosition: Point, dragRef: DragRef, dimensions: DOMRect, pickupPositionInElement: Point) => Point;
384+
constrainPosition?: DragConstrainPosition;
385385
data: T;
386386
get disabled(): boolean;
387387
set disabled(value: boolean);

0 commit comments

Comments
 (0)