A drawer displays some content (hidden by default) that can be opened and closed with a sliding animation.

Coral.Drawer API

Constructor

JavaScript:

new Coral.Drawer() or document.createElement('coral-drawer')

HTML Tag:

<coral-drawer>

Extends

Sub-components

Static Properties

Coral.Drawer.direction {String}

Drawer directions.

Properties:

Name Type Value Description
DOWN String down A drawer with a toggle button on the bottom.
UP String up A drawer with a toggle button on top.

Instance Properties

instance.content {HTMLElement}

The drawer's content element.

instance.direction {Coral.Drawer.direction}

The drawer's direction.
Default Value:
  • Coral.Drawer.direction.DOWN
HTML Attribute:
  • direction

instance.disabled {Boolean}

Reflected
Whether this item is disabled or not. This will stop every user interaction with the item.
Default Value:
  • false
HTML Attribute:
  • disabled

instance.open {Boolean}

Reflected
Whether the Drawer is expanded or not.
Default Value:
  • false
HTML Attribute:
  • open

Methods

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Hide this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
false Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
Inherited From:

instance.show

Show this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
true Set to false to prevent the event from bubbling.
cancelable Boolean Yes
true Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:detached

Triggered when the component is detached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:hide

Triggerred after the component is hidden with Coral.Component#hide.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-drawer:close

Triggered when the drawer is closed
Callback Parameters:
Name Type Description
event Object Event object

coral-drawer:open

Triggered when the drawer is opened
Callback Parameters:
Name Type Description
event Object Event object