package virtual_dom_toplayer
Install
dune-project
Dependency
Authors
Maintainers
Sources
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
Anchoring
Positioning Primitives
val 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 ->
unitSets 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.
val 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_handleLike 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.
Control and positioning hooks
val position_me :
?arrow_selector:string ->
?position:Position.t ->
?alignment:Alignment.t ->
?offset:Offset.t ->
Anchor.t ->
Virtual_dom.Vdom.Attr.tposition_me returns an attr which, when added to a vdom node, will automatically position it relative to the anchor, with auto-update.