Dropdown extends Floater
Assign a floater panel to a MouseEvent
Example
new Dropdown({
content: createElement({
class: 'bg-white pad',
content: 'Hello World'
}),
anchor: '#hi-button'
})<komp-dropdown anchor="#hi-button">
Hello World
</komp-dropdown>Constructor
new Dropdown(options)
options
:
Object
optionalmouseevent
:
string
optionalMouseEvent that toggles floater
removeOnBlur
:
boolean
optionalHide dropdown when user clicks outside or focuses elsewhere
timeout
:
number
optionalMilliseconds to wait before hiding dropdown after mouseleave
content
:
string
|
HTMLElement
|
Array
|
Object
optionalcontent for the floater, uses Dolla's content
anchor
:
HTMLElement
element to anchor positioning to
container
:
string
|
HTMLElement
optionalelement to append floater to. If String, then used as selector for this.closest(selector)
placement
:
string
optionalhow the floater is anchored, e.g. "top", "top-start", "top-end", "left", "left-start"...
strategy
:
string
optionalhow the floater is positioned in the document. "absolute" or "fixed"
flip
:
boolean
|
Object
optionalSee https://floating-ui.com/docs/flip, defaults to false in favor of autoPlacement
arrow
:
boolean
|
number
optionalTrue to show default size, or number in pixels
onHide
:
function
optionalcalled after hidden
onShow
:
function
optionalcalled before showing
scope
:
string
optionalshowing a floater will hide all other floaters of same scope
Instance Methods
Toggle the floater visibility
Parameters
shouldHide
:
boolean
optionalexplicitly show or hide. If omitted, toggles based on current visibility.
Returns
Floater
this
Events
shown
Fired when the floater is shown