Module Byo_toplayer_private_floating

Do not use this library directly! Use Byo_toplayer instead.

Config Types

module Position : sig ... end
module Alignment : sig ... end
module Offset : sig ... end
module Match_anchor_side : sig ... end

Anchoring

module Anchor : sig ... end
val position_within_viewport : Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> Anchor.t -> unit

Absolutely positioned popovers start at the top left corner of the viewport before autopositioning kicks in. If the popover is focused via autofocus or Effect.Focus.on_activate, and the popover has position:absolute, and autopositioning has not yet completed, this focusing will scroll the page to the top.

Because floating UI positioning is asynchronous, we always need to pre-position the popovers into the viewport before opening it.

position_within_viewport should be called on any toplayer element that can be focused and is positioned via floating positioning, before it is opened.

Control and positioning hooks

val position_me : ?prepare:(Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> unit) -> ?arrow_selector:string -> ?position:Position.t -> ?alignment:Alignment.t -> ?offset:Offset.t -> ?match_anchor_side_length:Match_anchor_side.t -> Anchor.t -> Virtual_dom.Vdom.Attr.t

position_me returns an attr which, when added to a vdom node, will automatically position it relative to the anchor, with auto-update.

If provided, prepare will run once befre positioning is applied, when the element is mounted. The most common use case is opening a popover before starting autopositioning to avoid a flicker.

If match_anchor_side_length is set to true, the popover's main axis (width if position is Top/Bottom, height if position is Left/Right) will be set to have a length equal to the corresponding axis of the anchor. This is particularly useful for dropdowns and typeaheads.

Accessors for styles and data provided by floating_positioning

module Accessors : sig ... end
module For_testing_position_me_hook : sig ... end