# 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_strech_size(stretch_size) | 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 Self 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 Self instance
is_inert()
  Return if scroll have inertion.

  ### Returns:

  bool If scroll have inertion
set_extra_strech_size(stretch_size)
  Set extra size for scroll stretching. Set 0 to disable stretching effect

  ### Parameters:

  - stretch_size number Size in pixels of additional scroll area

  ### Returns:

  druid.scroll Self 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 Self 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

  ### Fields:

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

generated by LDoc 1.4.6 Last updated 2020-05-04 00:51:46