Constructors
Section titled "Constructors"IgxDragDirective
Section titled "IgxDragDirective"new IgxDragDirective(): IgxDragDirective Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:732
Returns IgxDragDirective
Properties
Section titled "Properties"cancelOnEscape
Section titled "cancelOnEscape"Sets whether pressing Escape while dragging cancels the drag.
When cancelled, no drop is performed and dragEnd is emitted with cancelled set to true.
By default it is set to false.
cancelOnEscape: boolean = false Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:361
Example
<div igxDrag [cancelOnEscape]="true">
<span>Drag Me!</span>
</div> cdr: ChangeDetectorRef Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:725
dragChannel
Section titled "dragChannel"A property that provides a way for igxDrag and igxDrop to be linked through channels. It accepts single value or an array of values and evaluates then using strict equality.
<div igxDrag [dragChannel]="'odd'">
<span>95</span>
</div>
<div igxDrop [dropChannel]="['odd', 'irrational']">
<span>Numbers drop area!</span>
</div> dragChannel: string | number | string[] | number[] Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:259
dragClick
Section titled "dragClick"Event triggered when the draggable element is clicked.
<div igxDrag (dragClick)="onDragClick()">
<span>Drag Me!</span>
</div>public onDragClick(){
alert("The element has been clicked!");
} dragClick: EventEmitter<IDragBaseEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:433
dragDirection
Section titled "dragDirection"Sets the directions that the element can be dragged. By default it is set to both horizontal and vertical directions.
<div igxDrag [dragDirection]="dragDir">
<span>Drag Me!</span>
</div>public dragDir = DragDirection.HORIZONTAL; dragDirection: DragDirection = DragDirection.BOTH Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:242
dragEnd
Section titled "dragEnd"Event triggered when the draggable element is released.
<div igxDrag (dragEnd)="onDragEnd()">
<span>Drag Me!</span>
</div>public onDragEnd(){
alert("The drag has ended!");
} dragEnd: EventEmitter<IDragBaseEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:415
dragMove
Section titled "dragMove"Event triggered when the draggable element has been moved.
<div igxDrag (dragMove)="onDragMove()">
<span>Drag Me!</span>
</div>public onDragMove(){
alert("The element has moved!");
} dragMove: EventEmitter<IDragMoveEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:397
dragStart
Section titled "dragStart"Event triggered when the draggable element drag starts.
<div igxDrag (dragStart)="onDragStart()">
<span>Drag Me!</span>
</div>public onDragStart(){
alert("The drag has stared!");
} dragStart: EventEmitter<IDragStartEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:379
dragTolerance
Section titled "dragTolerance"Sets the tolerance in pixels before drag starts. By default the drag starts after the draggable element is moved by 5px.
<div igxDrag [dragTolerance]="100">
<span>Drag Me!</span>
</div> dragTolerance: number = 5 Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:225
element
Section titled "element"element: ElementRef<any> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:726
ghost
Section titled "ghost"Sets whether the base element should be moved, or a ghost element should be rendered that represents it instead.
By default it is set to true.
If it is set to false when dragging the base element is moved instead and no ghost elements are rendered.
<div igxDrag [ghost]="false">
<span>Drag Me!</span>
</div> ghost: boolean = true Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:274
ghostClass
Section titled "ghostClass"Sets a custom class that will be added to the ghostElement element.
<div igxDrag [ghostClass]="'ghostElement'">
<span>Drag Me!</span>
</div> ghostClass: string = '' Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:287
ghostCreate
Section titled "ghostCreate"Event triggered when the drag ghost element is created.
<div igxDrag (ghostCreate)="ghostCreated()">
<span>Drag Me!</span>
</div>public ghostCreated(){
alert("The ghost has been created!");
} ghostCreate: EventEmitter<IDragGhostBaseEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:451
ghostDestroy
Section titled "ghostDestroy"Event triggered when the drag ghost element is created.
<div igxDrag (ghostDestroy)="ghostDestroyed()">
<span>Drag Me!</span>
</div>public ghostDestroyed(){
alert("The ghost has been destroyed!");
} ghostDestroy: EventEmitter<IDragGhostBaseEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:469
ghostHost
Section titled "ghostHost"Sets the element to which the dragged element will be appended. By default it's set to null and the dragged element is appended to the body.
<div #hostDiv></div>
<div igxDrag [ghostHost]="hostDiv">
<span>Drag Me!</span>
</div> ghostHost: any Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:338
ghostStyle
Section titled "ghostStyle"Set styles that will be added to the ghostElement element.
<div igxDrag [ghostStyle]="{'--ig-size': 'var(--ig-size-small)'}">
<span>Drag Me!</span>
</div> ghostStyle: object = {} Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:304
ghostTemplate
Section titled "ghostTemplate"Specifies a template for the ghost element created when dragging starts and ghost is true.
By default a clone of the base element the igxDrag is instanced is created.
<div igxDrag [ghostTemplate]="customGhost">
<span>Drag Me!</span>
</div>
<ng-template #customGhost>
<div class="customGhostStyle">
<span>I am being dragged!</span>
</div>
</ng-template> ghostTemplate: TemplateRef<any> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:323
renderer
Section titled "renderer"renderer: Renderer2 Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:729
scrollContainer
Section titled "scrollContainer"Overrides the scroll container of the dragged element. By default its the window.
scrollContainer: HTMLElement Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:344
transitioned
Section titled "transitioned"Event triggered after the draggable element is released and after its animation has finished.
<div igxDrag (transitioned)="onMoveEnd()">
<span>Drag Me!</span>
</div>public onMoveEnd(){
alert("The move has ended!");
} transitioned: EventEmitter<IDragBaseEventArgs> Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:487
viewContainer
Section titled "viewContainer"viewContainer: ViewContainerRef Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:727
zone: NgZone Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:728
Accessors
Section titled "Accessors"get data(): any Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:209
Returns any
- Save data inside the
igxDragdirective. This can be set when instancingigxDragon an element.
<div [igxDrag]="{ source: myElement }"></div> set data(value: any): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:205
Parameters
- value:
any
Returns void
ghostOffsetX
Section titled "ghostOffsetX"get ghostOffsetX(): any Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:700
Returns any
Sets the offset of the dragged element relative to the mouse in pixels. By default it's taking the relative position to the mouse when the drag started and keeps it the same.
<div #hostDiv></div>
<div igxDrag [ghostOffsetX]="0">
<span>Drag Me!</span>
</div> set ghostOffsetX(value: any): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:696
Parameters
- value:
any
Returns void
ghostOffsetY
Section titled "ghostOffsetY"get ghostOffsetY(): any Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:721
Returns any
Sets the offset of the dragged element relative to the mouse in pixels. By default it's taking the relative position to the mouse when the drag started and keeps it the same.
<div #hostDiv></div>
<div igxDrag [ghostOffsetY]="0">
<span>Drag Me!</span>
</div> set ghostOffsetY(value: any): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:717
Parameters
- value:
any
Returns void
location
Section titled "location"Gets the current location of the element relative to the page.
get location(): IgxDragLocation Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:517
Returns IgxDragLocation
originLocation
Section titled "originLocation"Gets the original location of the element before dragging started.
get originLocation(): IgxDragLocation Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:524
Returns IgxDragLocation
Methods
Section titled "Methods"cancelDrag
Section titled "cancelDrag"Cancels the drag that is currently in progress.
No drop is performed. If the dragged element is over an igxDrop area, it receives only a leave event.
dragEnd is emitted with cancelled set to true and the ghost element is removed.
To animate the element back instead, call transitionToOrigin() in the dragEnd handler.
Does nothing when there is no drag in progress, including when the pointer is pressed
but has not moved beyond dragTolerance yet.
cancelDrag(): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:856
Returns void
Example
@ViewChild(IgxDragDirective) public dragDir: IgxDragDirective;
public onCancelClick() {
this.dragDir.cancelDrag();
} setLocation
Section titled "setLocation"Sets desired location of the base element or ghost element if rended relative to the document.
setLocation(newLocation: IgxDragLocation): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:865
Parameters
- newLocation:
IgxDragLocationNew location that should be applied. It is advised to get new location using getBoundingClientRects() + scroll.
Returns void
transitionTo
Section titled "transitionTo"Animates the base or ghost element to a specific target location or other element using transition.
If ghost is true but there is not ghost rendered, it will be created and animated.
It is recommended to use 'getBoundingClientRects() + pageScroll' when determining desired location.
transitionTo(target: ElementRef<any> | IgxDragLocation, customAnimArgs: IDragCustomTransitionArgs, startLocation: IgxDragLocation): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:960
Parameters
- target:
ElementRef<any> | IgxDragLocationTarget that the base or ghost will transition to. It can be either location in the page or another HTML element.
- customAnimArgs:
IDragCustomTransitionArgsCustom transition properties that will be applied when performing the transition.
- startLocation:
IgxDragLocationStart location from where the transition should start.
Returns void
transitionToOrigin
Section titled "transitionToOrigin"Animates the base or ghost element depending on the ghost input to its initial location.
If ghost is true but there is not ghost rendered, it will be created and animated.
If the base element has changed its DOM position its initial location will be changed accordingly.
transitionToOrigin(customAnimArgs: IDragCustomTransitionArgs, startLocation: IgxDragLocation): void Defined in projects/igniteui-angular/directives/src/directives/drag-drop/drag-drop.directive.ts:890
Parameters
- customAnimArgs:
IDragCustomTransitionArgsCustom transition properties that will be applied when performing the transition.
- startLocation:
IgxDragLocationStart location from where the transition should start.