# Manual Drag

In complex scenarios you could take full control over the [`DragTarget`](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective) directive behavior by setting its [`mode`](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective#mode) option to `manual`. In this case the built-in internal logic for moving the element will not be executed. Adding custom logic, styles and positioning is completely in the hands of the developer and is achieved by handling the corresponding DragTarget [`events`](https://www.telerik.com/kendo-angular-ui/components/utils/draganddrop/events#dragtarget-events).

## Dragging between Scrollable Containers

By default, when the DragTarget is nested inside a scrollable container, its movement is restricted within the parent boundaries. To override this behavior, you could manually handle the drag action and apply the needed styling and positioning.

The following example demonstrates this approach by applying `position: fixed` to the target element.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/utils/draganddrop/manual/source.txt)

### Setup

To calculate the DragTarget position correctly when `position: fixed` is set, you have to retrieve the current pointer coordinates in the `drag` event handler. Follow the steps listed below, to achieve the above setup:

1. Set the [`mode`](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective#mode) property to `manual` in order to take full control over the drag action.

2. Handle the [`onDragStart`](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective#ondragstart) event to get the current DragTarget HTML element. Use this event to update the element position to `fixed`.

```ts
    public handleDragStart(ev: DragTargetDragStartEvent): void {
        this.dragIndex = ev.dragTargetId;
        this.dragTarget = ev.dragTarget;
        this.renderer.setStyle(this.dragTarget, 'position',  'fixed');
    }
```

1. Handle the [`onDrag`](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective#ondrag) event to get the position of the DragTarget and to apply the `left` and `top` styles to the element.

```ts
    public handleDrag(ev: DragTargetDragEvent): void {
        const position = {
            x: ev.dragEvent.clientX,
            y: ev.dragEvent.clientY
        };
        this.renderer.setStyle(this.dragTarget, 'left', `${position.x}px`);
        this.renderer.setStyle(this.dragTarget, 'top', `${position.y}px`);
    }
```

1. Handle the [`onRelease`](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective#onrelease) event to remove the `fixed` position. This is recommend in order to prevent unwanted behavior.

```ts
    public handleRelease(ev): void {
        this.dragTarget && this.renderer.removeStyle(this.dragTarget, 'position');
    }
```

## Suggested Links

* [API Reference of the DragTarget](https://www.telerik.com/kendo-angular-ui/components/utils/api/dragtargetdirective)
* [API Reference of the DropTarget](https://www.telerik.com/kendo-angular-ui/components/utils/api/droptargetdirective)
