()
| 217 | private _injector = inject(Injector); |
| 218 | |
| 219 | constructor() { |
| 220 | const dropContainer = this.dropContainer; |
| 221 | const config = inject<DragDropConfig>(CDK_DRAG_CONFIG, {optional: true}); |
| 222 | |
| 223 | this._dragRef = createDragRef(this._injector, this.element, { |
| 224 | dragStartThreshold: |
| 225 | config && config.dragStartThreshold != null ? config.dragStartThreshold : 5, |
| 226 | pointerDirectionChangeThreshold: |
| 227 | config && config.pointerDirectionChangeThreshold != null |
| 228 | ? config.pointerDirectionChangeThreshold |
| 229 | : 5, |
| 230 | zIndex: config?.zIndex, |
| 231 | }); |
| 232 | this._dragRef.data = this; |
| 233 | this._dragDropRegistry.registerDirectiveNode(this.element.nativeElement, this); |
| 234 | |
| 235 | if (config) { |
| 236 | this._assignDefaults(config); |
| 237 | } |
| 238 | |
| 239 | // Note that usually the container is assigned when the drop list is picks up the item, but in |
| 240 | // some cases (mainly transplanted views with OnPush, see #18341) we may end up in a situation |
| 241 | // where there are no items on the first change detection pass, but the items get picked up as |
| 242 | // soon as the user triggers another pass by dragging. This is a problem, because the item would |
| 243 | // have to switch from standalone mode to drag mode in the middle of the dragging sequence which |
| 244 | // is too late since the two modes save different kinds of information. We work around it by |
| 245 | // assigning the drop container both from here and the list. |
| 246 | if (dropContainer) { |
| 247 | dropContainer.addItem(this); |
| 248 | |
| 249 | // The drop container reads this so we need to sync it here. |
| 250 | dropContainer._dropListRef.beforeStarted.pipe(takeUntil(this._destroyed)).subscribe(() => { |
| 251 | this._dragRef.scale = this.scale; |
| 252 | }); |
| 253 | } |
| 254 | |
| 255 | this._syncInputs(this._dragRef); |
| 256 | this._handleEvents(this._dragRef); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * Returns the element that is being used as a placeholder |
nothing calls this directly
no test coverage detected