/** * @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 { Injectable, Inject, NgZone } from '@angular/core'; import { DOCUMENT } from '@angular/common'; import { ViewportRuler } from '@angular/cdk/scrolling'; import { DragRef } from './drag-ref'; import { DropListRef } from './drop-list-ref'; import { DragDropRegistry } from './drag-drop-registry'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/scrolling"; import * as i2 from "./drag-drop-registry"; /** Default configuration to be used when creating a `DragRef`. */ const DEFAULT_CONFIG = { dragStartThreshold: 5, pointerDirectionChangeThreshold: 5, }; /** * Service that allows for drag-and-drop functionality to be attached to DOM elements. */ export class DragDrop { constructor(_document, _ngZone, _viewportRuler, _dragDropRegistry) { this._document = _document; this._ngZone = _ngZone; this._viewportRuler = _viewportRuler; this._dragDropRegistry = _dragDropRegistry; } /** * Turns an element into a draggable item. * @param element Element to which to attach the dragging functionality. * @param config Object used to configure the dragging behavior. */ createDrag(element, config = DEFAULT_CONFIG) { return new DragRef(element, config, this._document, this._ngZone, this._viewportRuler, this._dragDropRegistry); } /** * Turns an element into a drop list. * @param element Element to which to attach the drop list functionality. */ createDropList(element) { return new DropListRef(element, this._dragDropRegistry, this._document, this._ngZone, this._viewportRuler); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: DragDrop, deps: [{ token: DOCUMENT }, { token: i0.NgZone }, { token: i1.ViewportRuler }, { token: i2.DragDropRegistry }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: DragDrop, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: DragDrop, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT] }] },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