package virtual_dom_toplayer

  1. Overview
  2. Docs
OCaml bindings for the floating positioning library for 'toplevel' virtual dom components

Install

dune-project
 Dependency

Authors

Maintainers

Sources

virtual_dom_toplayer-v0.17.0.tar.gz
sha256=b525b0ba3607f142d417fe6edf1a08dbed86ae4e817680fb9bc191959b7a3aea

doc/virtual_dom_toplayer.floating_positioning/Floating_positioning_new/index.html

Module Floating_positioning_newSource

The Floating_positioning library is for positioning an element relative to a reference element. It is intended for component authors, and generally should not be used directly in implementations of web UIs.

These are used to implement positioning for `lib/vdom_toplayer`.

Config Types

Sourcemodule Position : sig ... end
Sourcemodule Alignment : sig ... end
Sourcemodule Offset : sig ... end
Sourcemodule Strategy : sig ... end

Anchoring

Sourcemodule Anchor : sig ... end
Sourcetype auto_update_handle

Positioning Primitives

Sourceval update_position : ?arrow_selector:string -> anchor:Anchor.t -> floating:Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> Position.t -> Alignment.t -> Offset.t -> Strategy.t -> unit

Sets the position of the floating element relative to the anchor. Can be useful for one-off positioning calls or virtual positioning. For real DOM anchors, you'll generally want to use auto_update_position.

arrow_selector can be used to indicate a child element of floating that should be a positioning indicator: https://floating-ui.com/docs/arrow.

Sourceval auto_update_position : ?arrow_selector:string -> anchor:Anchor.t -> floating:Js_of_ocaml.Dom_html.element Js_of_ocaml.Js.t -> Position.t -> Alignment.t -> Offset.t -> Strategy.t -> auto_update_handle

Like update_position, but automatically repositions the floating element when the anchor changes.

This can be expensive, don't use it to position elements with display:none while they are not visible.

Known bug: popovers attached to moving elements might disconnect when positioning params change due to some weird interactions between vdom diffing and floating_ui's use of IntersectionObserver. This could be fixed by running auto-update on every frame, but isn't currently implemented because it's not a likely use case.

Sourceval cancel_auto_update : auto_update_handle -> unit

Control and positioning hooks

Sourceval position_me : ?arrow_selector:string -> ?position:Position.t -> ?alignment:Alignment.t -> ?offset:Offset.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.

Accessors for positioning data provided by floating_positioning

Sourcemodule Accessors : sig ... end