# Defold Druid UI Library

# Module `Drag`

Component to handle drag action on node.

Drag have correct handling for multitouch and swap touched while dragging. Drag will be processed even the cursor is outside of node, if drag is already started

## Functions

init(self, node, on_drag_callback) | Drag component constructor
set_click_zone(self, node) | Strict drag click area.

## Tables

style | Component style params.

## Fields

on_touch_start | Event on touch start callback(self)
on_touch_end | Event on touch end callback(self)
on_drag_start | Event on drag start callback(self)
on_drag | on drag progress callback(self, dx, dy)
on_drag_end | Event on drag end callback(self)
is_touch | Is component now touching
is_drag | Is component now dragging
can_x | Is drag component process vertical dragging.
can_y | Is drag component process horizontal.
x | Current touch x position
y | Current touch y position
touch_start_pos | Touch start position

## Functions

init(self, node, on_drag_callback)
  Drag component constructor

  ### Parameters:

  - self Drag
  - node node GUI node to detect dragging
  - on_drag_callback function Callback for on_drag_event(self, dx, dy)
set_click_zone(self, node)
  Strict drag click area. Useful for restrict events outside stencil node

  ### Parameters:

  - self Drag
  - node node Gui node

## Tables

style
  Component style params. You can override this component styles params in druid styles table or create your own style

  ### Fields:

  - DRAG_DEADZONE number Distance in pixels to start dragging (default 10)

## Fields

on_touch_start
  Event on touch start callback(self)
  - on_touch_start druid_event
on_touch_end
  Event on touch end callback(self)
  - on_touch_end druid_event
on_drag_start
  Event on drag start callback(self)
  - on_drag_start druid_event
on_drag
  on drag progress callback(self, dx, dy)
  - on_drag druid_event Event
on_drag_end
  Event on drag end callback(self)
  - on_drag_end druid_event
is_touch
  Is component now touching
  - is_touch bool
is_drag
  Is component now dragging
  - is_drag bool
can_x
  Is drag component process vertical dragging. Default - true
  - can_x bool
can_y
  Is drag component process horizontal. Default - true
  - can_y bool
x
  Current touch x position
  - x number
y
  Current touch y position
  - y number
touch_start_pos
  Touch start position
  - touch_start_pos vector3

generated by LDoc 1.4.6 Last updated 2021-04-06 00:03:14