Icard/angular-clarity-master(work.../node_modules/primeng/fesm2022/primeng-dragdrop.mjs.map

1 line
18 KiB
Plaintext
Raw Normal View History

2024-07-16 15:23:22 +00:00
{"version":3,"file":"primeng-dragdrop.mjs","sources":["../../src/app/components/dragdrop/dragdrop.ts","../../src/app/components/dragdrop/primeng-dragdrop.ts"],"sourcesContent":["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, Directive, ElementRef, EventEmitter, HostListener, Input, NgModule, NgZone, OnDestroy, Output, Renderer2, booleanAttribute } from '@angular/core';\nimport { DomHandler } from 'primeng/dom';\nimport { VoidListener } from 'primeng/ts-helpers';\n/**\n * pDraggable directive apply draggable behavior to any element.\n * @group Components\n */\n@Directive({\n selector: '[pDraggable]',\n host: {\n class: 'p-element'\n }\n})\nexport class Draggable implements AfterViewInit, OnDestroy {\n @Input('pDraggable') scope: string | undefined;\n /**\n * Defines the cursor style.\n * @group Props\n */\n @Input() dragEffect: 'none' | 'copy' | 'copyLink' | 'copyMove' | 'link' | 'linkMove' | 'move' | 'all' | 'uninitialized' | undefined;\n /**\n * Selector to define the drag handle, by default anywhere on the target element is a drag handle to start dragging.\n * @group Props\n */\n @Input() dragHandle: string | undefined;\n /**\n * Callback to invoke when drag begins.\n * @param {DragEvent} event - Drag event.\n * @group Emits\n */\n @Output() onDragStart: EventEmitter<DragEvent> = new EventEmitter();\n /**\n * Callback to invoke when drag ends.\n * @param {DragEvent} event - Drag event.\n * @group Emits\n */\n @Output() onDragEnd: EventEmitter<DragEvent> = new EventEmitter();\n /**\n * Callback to invoke on dragging.\n * @param {DragEvent} event - Drag event.\n * @group Emits\n */\n @Output() onDrag: EventEmitter<DragEvent> = new EventEmitter();\n\n handle: any;\n\n dragListener: VoidListener;\n\n mouseDownListener: VoidListener;\n\n mouseUpListener: VoidListener;\n\n _pDraggableDisabled: boolean = false;\n\n constructor(public el: ElementRef, public zone: NgZone, private renderer: Renderer2) {}\n\n @Input() get pDraggableDisabled(): boolean {\n return this._pDraggableDisabled;\n }\n set pDraggableDisabled(_pDraggableDisabled: boolean) {\n this._pDraggableDisabled = _pDraggableDisabled;\n\n if (this._pDraggableDisabled) {\n this.unbindMouseListeners();\n } else {\n this.el.nativeElement.draggable = true;\n this.bindMouseListeners();\n }\n }\n\n ngAfterViewInit() {\n if (!this.pDraggableDisabled) {\n this.el.nativeElement.draggable = true;\n this.bindMouseListeners();\n }\n }\n\n bindDragListener() {\n if (!this.dragListener) {\n this.zone.runOutsideAngular(() => {\n this.dragListener = this.renderer.listen(this.el.nativeElement, 'drag', this.drag.bind(this));\n });\n }\n }\n\n unbindDragListener() {\n if (this.dragListener) {\n this.zone.runOutsideAngular(() => {\n this.dragListener && this.dragListener();\n this.dragListener = null;\n });\n }\n }\n\n bindMouseListeners() {\n if (!this.mouseDownListener && !this.mouseUpListener) {\n this.zone.runOutsideAngular(() => {\n this.mouseDownListener = this.renderer.listen(this.el.nativeElement, 'mousedown', this.mousedown.bind(this));\n this.mouseUpListener = this.renderer.listen(this.el.nativeElement, 'mouseup', this.mouseup.bind(this));\n });\n }\n }\n\n unbindMouseListeners() {\n if (this.mouseDownListener && this.mouseUpListener) {\n this.zone.runOutsideAngular(() => {\n this.mouseDownListener && this.mouseDownListener();\n this.mouseUpListener && this.mouseUpListener();\n this.mouseDownListener = null;\n this.mouseUpListener = null;\n });\n }\n }\n\n drag(event: DragEvent) {\n this.