package incr_dom_partial_render
Module Util.ScrollSource
For functions in this module, "start" and "end" should be interpreted as follows:
- in the vertical direction, "start" means "top" and "end" means "bottom"
- in the horizontal direction, "start" means "left" and "end" means "right"
For instance, for scroll_to_position Horizontal, scroll_region_start is the left position of the scroll region and elem_start is the left position of the element.
val scroll_into_region :
?in_:Scroll_region.t ->
Dir.t ->
start_margin:float ->
end_margin:float ->
scroll_region_start:float ->
scroll_region_end:float ->
elem_start:float ->
elem_end:float ->
Scroll_result.tscroll_into_region scrolls the element with position from elem_start to elem_end into the scroll region as specified by scroll_region_start and scroll_region_end, with additional margins of start_margin and end_margin respectively.
val scroll_to_position :
?in_:Scroll_region.t ->
Dir.t ->
position:float ->
scroll_region_start:float ->
elem_start:float ->
Scroll_result.tscroll_to_position scrolls the element with position from elem_start to elem_end to the given position relative to the start of the scroll region as specified by scroll_region_start.
In cases where it is not possible to scroll the element to the specified position (e.g scrolling an element at the bottom of the page to the top of the viewport), the element is scrolled as close as possible to the given position.
val scroll_to_position_and_into_region :
?in_:Scroll_region.t ->
Dir.t ->
position:float ->
start_margin:float ->
end_margin:float ->
scroll_region_start:float ->
scroll_region_end:float ->
elem_start:float ->
elem_end:float ->
Scroll_result.tscroll_to_position_and_into_region first calls scroll_to_position, followed by scroll_into_region with the updated element position.
val is_in_region :
start_margin:float ->
end_margin:float ->
scroll_region_start:float ->
scroll_region_end:float ->
elem_start:float ->
elem_end:float ->
boolis_in_region checks if the element with position from elem_start to elem_end is within the boundaries of the scroll region as specified by scroll_region_start and scroll_region_end plus a margin of start_margin or end_margin respectively.
get_position returns the position of the element with start position elem_start relative to the start of the scroll region as specified by scroll_region_start