# Defold Druid UI Library

# Module `druid.scroll`

Component to handle scroll content.

Scroll consist from two nodes: scroll parent and scroll input Scroll input the user input zone, it's static Scroll parent the scroll moving part, it will change position. Setup initial scroll size by changing scroll parent size. If scroll parent size will be less than scroll_input size, no scroll is available. For scroll parent size should be more than input size

## Functions

init(view_node, content_node) | Scroll constructor.
scroll_to(vector3[, is_instant]) | Start scroll to target point.
scroll_to_index(index[, skip_cb]) | Scroll to item in scroll by point index.
scroll_to_percent(vector3[, is_instant]) | Start scroll to target scroll percent
get_percent() | Return current scroll progress status.
set_size(size) | Set scroll content size.
set_inert(state) | Enable or disable scroll inert.
is_inert() | Return if scroll have inertion.
set_extra_stretch_size([stretch_size=0]) | Set extra size for scroll stretching.
get_scroll_size() | Return vector of scroll size with width and height.
set_points(points) | Set points of interest.

## Tables

Events | Component events
Fields | Component fields
Style | Component style params.

## Functions

init(view_node, content_node)
  Scroll constructor.

  ### Parameters:

  - view_node node GUI view scroll node
  - content_node node GUI content scroll node
scroll_to(vector3[, is_instant])
  Start scroll to target point.

  ### Parameters:

  - vector3 point Target point
  - is_instant bool Instant scroll flag (optional)

  ### Usage:

  -     scroll:scroll_to(vmath.vector3(0, 50, 0))

  -     scroll:scroll_to(vmath.vector3(0), true)

scroll_to_index(index[, skip_cb])
  Scroll to item in scroll by point index.

  ### Parameters:

  - index number Point index
  - skip_cb bool If true, skip the point callback (optional)
scroll_to_percent(vector3[, is_instant])
  Start scroll to target scroll percent

  ### Parameters:

  - vector3 point target percent
  - is_instant bool instant scroll flag (optional)

  ### Usage:

      scroll:scroll_to_percent(vmath.vector3(0.5, 0, 0))

get_percent()
  Return current scroll progress status. Values will be in [0..1] interval

  ### Returns:

  vector3 New vector with scroll progress values
set_size(size)
  Set scroll content size. It will change content gui node size

  ### Parameters:

  - size vector3 The new size for content node

  ### Returns:

  druid.scroll Current scroll instance
set_inert(state)
  Enable or disable scroll inert. If disabled, scroll through points (if exist) If no points, just simple drag without inertion

  ### Parameters:

  - state bool Inert scroll state

  ### Returns:

  druid.scroll Current scroll instance
is_inert()
  Return if scroll have inertion.

  ### Returns:

  bool If scroll have inertion
set_extra_stretch_size([stretch_size=0])
  Set extra size for scroll stretching. Set 0 to disable stretching effect

  ### Parameters:

  - stretch_size number Size in pixels of additional scroll area (default 0)

  ### Returns:

  druid.scroll Current scroll instance
get_scroll_size()
  Return vector of scroll size with width and height.

  ### Returns:

  vector3 Available scroll size
set_points(points)
  Set points of interest. Scroll will always centered on closer points

  ### Parameters:

  - points table Array of vector3 points

  ### Returns:

  druid.scroll Current scroll instance

## Tables

Events
  Component events

  ### Fields:

  - on_scroll druid_event On scroll move callback
  - on_scroll_to druid_event On scroll_to function callback
  - on_point_scroll druid_event On scrolltoindex function callback
Fields
  Component fields

  ### Fields:

  - view_node node Scroll view node
  - content_node node Scroll content node
  - is_inert bool Flag, if scroll now moving by inertion
  - inertion vector3 Current inert speed
  - position vector3 Current scroll posisition
  - target_position vector3 Current scroll target position
  - available_pos vector4 Available position for content node: (minx, maxy, maxx, miny)
  - available_size vector3 Size of available positions: (width, height, 0)
  - drag druid.drag Drag component
  - Current selected index of points of interests (optional)
  - is_animate bool Flag, if scroll now animating by gui.animate
Style
  Component style params. You can override this component styles params in druid styles table or create your own style

  ### Fields:

  - FRICT number Multiplier for free inertion (default 0)
  - FRICT_HOLD number Multiplier for inertion, while touching (default 0)
  - INERT_THRESHOLD number Scroll speed to stop inertion (default 3)
  - INERT_SPEED number Multiplier for inertion speed (default 30)
  - POINTS_DEADZONE number Speed to check points of interests in no_inertion mode (default 20)
  - BACK_SPEED number Scroll back returning lerp speed (default 0.35)
  - ANIM_SPEED number Scroll gui.animation speed for scroll_to function (default 0.2)
  - EXTRA_STRETCH_SIZE number extra size in pixels outside of scroll (stretch effect) (default 0)
  - SMALL_CONTENT_SCROLL bool If true, content node with size less than view node size can be scrolled (default false)

generated by LDoc 1.4.6 Last updated 2020-06-14 20:13:02