Module Ojw_position

module Ojw_position : sig..end

Positions helper for javascript elements

This module provides some helpers to get coordinates or move element next to each others. Author(s): Charly Chevalier


type position = [ `absolute | `fixed ]

The type to determin the value of the position attribute of the javascript element.

type common_orientation = [ `center ]

The type used by vertical and horizontal orientation

The type for horizontal orientation.

type h_orientation = [ `center | `left | `right ]

The type for vertical orientation.

type v_orientation = [ `bottom | `center | `top ]
val relative_coord : 
  ?h:h_orientation ->
  ?v:v_orientation ->
  ?scroll:bool ->
  relative:#Dom_html.element Js.t -> #Dom_html.element Js.t -> int * int

relative_coord ?h ?v ~relative elt try to calculate the coordinates of elt applying the directions h and v on it and using relative as a reference. elt will be placed outside of relative.

If the given orientation move elt out of screen, the orientation is flip to the opposite.

val relative_move : 
  ?h:h_orientation ->
  ?v:v_orientation ->
  ?scroll:bool ->
  ?position:position ->
  relative:#Dom_html.element Js.t -> #Dom_html.element Js.t -> unit

relative_move ?h ?v ~relative elt same as relative_coord, but instead of returning coordinates, it moves directly elt to the calculated coordinates.

val absolute_coord : 
  ?h:h_orientation ->
  ?v:v_orientation ->
  ?scroll:bool ->
  relative:#Dom_html.element Js.t -> #Dom_html.element Js.t -> int * int

absolute_coord ?h ?v ~relative elt same as relative_coord, but instead of placing elt outside of relative, it place inside.

val absolute_move : 
  ?h:h_orientation ->
  ?v:v_orientation ->
  ?scroll:bool ->
  ?position:position ->
  relative:#Dom_html.element Js.t -> #Dom_html.element Js.t -> unit

absolute_move ?h ?v ~relative elt same as absolute_coord, but instead of returning coordinates, it moves directly elt to the calculated coordinates.