-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(drag-drop): add injection token for configuring the input defaul…
…ts (#17970) Adds an injection token that allows consumers to change the defaults of the various options in the `drag-drop` module. Also moves some repeated inline types into shared ones. Fixes #17921.
- Loading branch information
Showing
7 changed files
with
239 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {InjectionToken} from '@angular/core'; | ||
import {DragRefConfig, Point, DragRef} from '../drag-ref'; | ||
|
||
/** Possible values that can be used to configure the drag start delay. */ | ||
export type DragStartDelay = number | {touch: number, mouse: number}; | ||
|
||
/** Possible axis along which dragging can be locked. */ | ||
export type DragAxis = 'x' | 'y'; | ||
|
||
/** Function that can be used to constrain the position of a dragged element. */ | ||
export type DragConstrainPosition = (point: Point, dragRef: DragRef) => Point; | ||
|
||
/** Possible orientations for a drop list. */ | ||
export type DropListOrientation = 'horizontal' | 'vertical'; | ||
|
||
/** | ||
* Injection token that can be used to configure the | ||
* behavior of the drag&drop-related components. | ||
*/ | ||
export const CDK_DRAG_CONFIG = new InjectionToken<DragDropConfig>('CDK_DRAG_CONFIG'); | ||
|
||
/** | ||
* Object that can be used to configure the drag | ||
* items and drop lists within a module or a component. | ||
*/ | ||
export interface DragDropConfig extends Partial<DragRefConfig> { | ||
lockAxis?: DragAxis; | ||
dragStartDelay?: DragStartDelay; | ||
constrainPosition?: DragConstrainPosition; | ||
previewClass?: string | string[]; | ||
boundaryElement?: string; | ||
rootElementSelector?: string; | ||
draggingDisabled?: boolean; | ||
sortingDisabled?: boolean; | ||
listAutoScrollDisabled?: boolean; | ||
listOrientation?: DropListOrientation; | ||
} | ||
|
||
/** | ||
* @deprecated No longer being used. To be removed. | ||
* @breaking-change 10.0.0 | ||
* @docs-private | ||
*/ | ||
export function CDK_DRAG_CONFIG_FACTORY(): DragDropConfig { | ||
return {dragStartThreshold: 5, pointerDirectionChangeThreshold: 5}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.