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
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
onShow
:
function
optionalevent listener for show (cancellable, fires before showing)
onShown
:
function
optionalevent listener for shown (fires after showing)
onHide
:
function
optionalevent listener for hide (cancellable, fires before hiding)
onHidden
:
function
optionalevent listener for hidden (fires after hiding)
scope
:
string
optionalshowing a floater will hide all other floaters of same scope
content
:
string
|
HTMLElement
|
Array
|
Object
optionalcontent to append to element. Passed to Dolla's content
Instance Methods
Toggle the floater visibility
Parameters
shouldHide
:
boolean
optionalexplicitly show or hide. If omitted, toggles based on current visibility.
Returns
Floater
this
Events
hide
Fired before the floater is hidden (cancellable)
show
Fired before the floater is shown (cancellable)
shown
Fired after the floater is shown