Floater (extends KompElement)
Render content on a layer above an anchored element.
Example
Syntax
new Floater({
content: "Hello World",
anchor: '#hi-button'
})
HTML
<komp-floater anchor="#hi-button">
Hello World
</komp-floater>
Options
container
| types | description | required | default | type | |
|---|---|---|---|---|---|
content
|
String, HTMLElement, Array, Object |
content for the floater, uses Dolla's |
|||
anchor
|
String, HTMLElement |
element to append floater to. If |
true | null/anchor.parentElement | |
placement
|
String |
how the floater is anchored options like "top", "top-start", "top-end", "left", "left-start"... |
bottom | ||
strategy
|
String |
how the floater is positioned in the document. "absolute" or "fixed" |
absolute | ||
flip
|
Boolean, Object |
See https://floating-ui.com/docs/flip, defaults to false in favor of autoPlacement |
false | ||
offset
|
Boolean, Object | false | |||
shift
|
Boolean, Object | true | |||
arrow
|
Boolean, Number |
True to show default size, or number in pixels |
false | ||
size
|
Boolean, Object | false | |||
autoPlacement
|
Boolean, Object | true | |||
inline
|
Boolean, Object | false | |||
autoUpdate
|
Boolean, Object | true | |||
removeOnBlur
|
Boolean |
hide floater on outside click/focus or escape key |
false | ||
timeout
|
Number |
ms to wait until hiding after mouseout |
0 | ||
onHide
|
Function |
called after hidden |
|||
onShow
|
Function |
called before showing |
|||
scope
|
showing a floater will hide all other floaters of same scope |
String |
Properties
| type | description | |
|---|---|---|
showing
|
boolean |
is floater showing, can be disconnected and not showing in case of Tooltip |
Events
| arguments | description | |
|---|---|---|
beforeRemove
|
[] |
called before element is removed |
afterRemove
|
[] |
called after element is removed |
beforeConnect
|
[] |
called before element is connected |
afterConnect
|
[] |
called before element is connected |
beforeDisconnect
|
[] |
called before element is disconnected |
afterDisconnect
|
[] |
called before element is disconnected |
shown
|
when floater is shown |
|
hidden
|
when floater is hidden |
Transition Animation
The floater will follow the transition effects set by CSS, and adds classes -out, -out-start, -in and -in-start when hiding and showing.
Additionally, the floater adds classes for placement -left, -right, -top, -bottom