package incr_dom_partial_render

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parameters

module Row_id : Row_id

Signature

module Row_id = Row_id
module Sort_key = Row_id
module Height_cache : sig ... end

Height_cache keeps track of the rendered height of items so that scrolling to a given position can decide which elements to render accurately. This allows rows to have different heights and change height at runtime.

type 'v t

Meant to be stored in the derived model

val create : rows:'v Sort_key.Map.t Incr_dom.Incr.t -> height_cache:Height_cache.t Incr_dom.Incr.t -> measurements: Incr_dom_partial_render__.Partial_render_list_intf.Measurements.t option Incr_dom.Incr.t -> 'v t Incr_dom.Incr.t
val measurements : _ t -> Incr_dom_partial_render__.Partial_render_list_intf.Measurements.t option
val find_by_position : _ t -> position:float -> Sort_key.t option
val find_by_relative_position : _ t -> Sort_key.t -> offset:float -> Sort_key.t option

find_by_relative_position t key ~offset returns the key at a distance of approximately offset away from key, preferring closer elements to farther ones. If the offset extends past the end of the list, the end key is returned instead.

val focus_offset_to_position : _ t -> Sort_key.t -> offset:float -> float
val rows_to_render : 'v t -> 'v Sort_key.Map.t

Meant for rendering, apps should normally use Incr.Map.mapi' on this

val spacer_heights : _ t Incr_dom.Incr.t -> (float * float) Incr_dom.Incr.t

(top, bottom) spacer pixel heights to put the rendered rows in the right place

val scroll_into_scroll_region : ?in_:Util.Scroll_region.t -> _ t -> top_margin:float -> bottom_margin:float -> key:Sort_key.t -> Util.Scroll_result.t

Scroll the view to the row with the given key, scrolling the minimum amount possible while still being (top|bottom)_margin pixels away from the top and bottom of the screen. If this can't be satisfied, the margin will be reduced to the point where it can. If a margin of 0 can't show the whole element, it will prefer showing the top.

?in determines the element which should be scrolled. Default is `Window

val scroll_to_position : ?in_:Util.Scroll_region.t -> _ t -> position:float -> key:Sort_key.t -> Util.Scroll_result.t
val scroll_to_position_and_into_region : ?in_:Util.Scroll_region.t -> _ t -> position:float -> top_margin:float -> bottom_margin:float -> key:Sort_key.t -> Util.Scroll_result.t

is_in_region and get_position return None if the given key does not exist or the view rect and list rect measurements are not yet available.

val is_in_region : _ t -> top_margin:float -> bottom_margin:float -> key:Sort_key.t -> bool option
val get_position : _ t -> key:Sort_key.t -> float option
val get_top_and_bottom : _ t -> key:Sort_key.t -> (float * float) option
val measure_heights_simple : _ t -> measure:(Sort_key.t -> float option) -> Height_cache.t

measure_heights_simple updates a height cache by measuring the rendered elements, relying on the app to provide a function for finding and measuring the element for a given key. This function can be used for table with collapsed borders and box sizing set to border-box.

val measure_heights : _ t -> measure_row:(Sort_key.t -> 'm option) -> get_row_height: (prev:'m option -> curr:'m option -> next:'m option -> float option) -> Height_cache.t

measure_heights is like measure_heights_simple, but allows the app to use the previous and next rows in addition to the current row to measure the current row's height (e.g. using the bottom position of the previous row and/or the top position of the next row). To avoid retaking the same measures three times for each row (once as the "previous" row, once as the "current" row, and once as the "next" row), measure_row allows the app to specify what measurements to take for a given row, and it is called exactly once per row. This function should be used for tables with non-collapsed borders.