# Module `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(self, view_node, content_node) | Scroll constructor
scroll_to(self, point[, is_instant]) | Start scroll to target point.
scroll_to_index(self, index[, skip_cb]) | Scroll to item in scroll by point index.
scroll_to_percent(self, percent[, is_instant]) | Start scroll to target scroll percent
get_percent(self) | Return current scroll progress status.
set_size(self, size, offset) | Set scroll content size.
set_inert(self, state) | Enable or disable scroll inert.
is_inert(self) | Return if scroll have inertion.
set_extra_stretch_size(self[, stretch_size=0]) | Set extra size for scroll stretching.
get_scroll_size(self) | Return vector of scroll size with width and height.
set_points(self, points) | Set points of interest.
set_horizontal_scroll(self, state) | Lock or unlock horizontal scroll
set_vertical_scroll(self, state) | Lock or unlock vertical scroll
is_node_in_view(self, node) | Check node if it visible now on scroll.
bind_grid(self, grid) | Bind the grid component (Static or Dynamic) to recalculate scroll size on grid changes
set_click_zone(self, node) | Strict drag scroll area.
_cancel_animate(self) | Cancel animation on other animation or input touch

## Tables

style | Component style params.

## Fields

on_scroll | On scroll move callback(self, position)
on_scroll_to | On scroll_to function callback(self, target, is_instant)
on_point_scroll | On scroll_to_index function callback(self, index, point)
view_node | Scroll view node
content_node | Scroll content node
is_inert | Flag, if scroll now moving by inertion
inertion | Current inert speed
position | Current scroll posisition
target_position | Current scroll target position
available_pos | Available position for content node: (min_x, max_y, max_x, min_y)
available_size | Size of available positions: (width, height, 0)
drag | Drag Druid component
selected | Current index of points of interests
is_animate | Flag, if scroll now animating by gui.animate

## Functions

init(self, view_node, content_node)
  Scroll constructor

  ### Parameters:

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

  ### Parameters:

  - self Scroll
  - point vector3 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(self, index[, skip_cb])
  Scroll to item in scroll by point index.

  ### Parameters:

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

  ### Parameters:

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

  ### Usage:

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

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

  ### Parameters:

  - self Scroll

  ### Returns:

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

  ### Parameters:

  - self Scroll
  - size vector3 The new size for content node
  - offset vector3 Offset value to set, where content is starts

  ### Returns:

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

  ### Parameters:

  - self Scroll
  - state bool Inert scroll state

  ### Returns:

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

  ### Parameters:

  - self Scroll

  ### Returns:

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

  ### Parameters:

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

  ### Returns:

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

  ### Parameters:

  - self Scroll

  ### Returns:

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

  ### Parameters:

  - self Scroll
  - points table Array of vector3 points

  ### Returns:

  druid.scroll Current scroll instance
set_horizontal_scroll(self, state)
  Lock or unlock horizontal scroll

  ### Parameters:

  - self Scroll
  - state bool True, if horizontal scroll is enabled

  ### Returns:

  druid.scroll Current scroll instance
set_vertical_scroll(self, state)
  Lock or unlock vertical scroll

  ### Parameters:

  - self Scroll
  - state bool True, if vertical scroll is enabled

  ### Returns:

  druid.scroll Current scroll instance
is_node_in_view(self, node)
  Check node if it visible now on scroll. Extra border is not affected. Return true for elements in extra scroll zone

  ### Parameters:

  - self Scroll
  - node node The node to check

  ### Returns:

  boolean True if node in visible scroll area
bind_grid(self, grid)
  Bind the grid component (Static or Dynamic) to recalculate scroll size on grid changes

  ### Parameters:

  - self Scroll
  - grid StaticGrid or DynamicGrid Druid grid component

  ### Returns:

  druid.scroll Current scroll instance
set_click_zone(self, node)
  Strict drag scroll area. Useful for restrict events outside stencil node

  ### Parameters:

  - self Drag
  - node node Gui node
_cancel_animate(self)
  Cancel animation on other animation or input touch

  ### Parameters:

  - self

## Tables

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)
  - WHEEL_SCROLL_SPEED bool The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling (default 0)
  - WHEEL_SCROLL_INVERTED bool If true, invert direction for touchpad and mouse wheel scroll (default false)
  - WHEEL_SCROLL_BY_INERTION bool If true, wheel will add inertion to scroll. Direct set position otherwise. (default false)

## Fields

on_scroll
  On scroll move callback(self, position)
  - on_scroll druid_event
on_scroll_to
  On scroll_to function callback(self, target, is_instant)
  - on_scroll_to druid_event
on_point_scroll
  On scroll_to_index function callback(self, index, point)
  - on_point_scroll druid_event
view_node
  Scroll view node
  - view_node node
content_node
  Scroll content node
  - content_node node
is_inert
  Flag, if scroll now moving by inertion
  - is_inert bool
inertion
  Current inert speed
  - inertion vector3
position
  Current scroll posisition
  - position vector3
target_position
  Current scroll target position
  - target_position vector3
available_pos
  Available position for content node: (min_x, max_y, max_x, min_y)
  - available_pos vector4
available_size
  Size of available positions: (width, height, 0)
  - available_size vector3
drag
  Drag Druid component
  - drag Drag
selected
  Current index of points of interests
  - selected number (optional)
is_animate
  Flag, if scroll now animating by gui.animate
  - is_animate bool

generated by LDoc 1.4.6 Last updated 2022-02-12 17:16:44