class Collapsible
package feathers.controls
extends FeathersControl › MeasureSprite › ValidatingSprite
implements IOpenCloseToggle
A container that displays primary content
that may be collapsed and
expanded by clicking or tapping a header
.
The following example creates a closed collapsible container with word-wrapped text as content:
var collapsible = new Collapsible();
collapsible.text = "What is Feathers UI?";
collapsible.opened = false;
var textContent = new Label();
textContent.width = 200.0;
textContent.wordWrap = true;
textContent.text = "Feathers UI is an open source framework of graphical user interface (GUI) components for creative, cross-platform projects.";
collapsible.content = textContent;
addChild(collapsible);
Events:
openfl.events.Event.OPEN | Dispatched when the content has completely opened. |
---|---|
openfl.events.Event.CLOSE | Dispatched when the content has completely closed. |
openfl.events.Event.CANCEL | Dispatched when an open or close action is cancelled before completing. |
feathers.events.FeathersEvent.OPENING | Dispatched when the content starts opening. This event may be cancelled. |
feathers.events.FeathersEvent.CLOSING | Dispatched when the content starts closing. This event may be cancelled. |
1.3.0
.See also:
Static variables
staticfinalread onlyCHILD_VARIANT_HEADER:String = "collapsible_header"
The variant used to style the header child component in a theme.
To override this default variant, set the
Collapsible.customHeaderVariant
property.
1.3.0
.See also:
Constructor
new(?text:String, ?content:DisplayObject)
Creates a new Collapsible
object with the given arguments.
1.3.0
.Variables
animateContentAlpha:Bool
Optionally fades the alpha
value of the content when opening and
closing.
In the following example, the alpha value fades on open and close:
collapsible.animateContentAlpha = true;
1.3.0
.animateOpenedProperty:Bool
Indicates if setting the opened
property causes the drawer to animate
open and closed, or if it causes the drawer to open and close instantly.
1.3.0
.See also:
content:DisplayObject
The primary content to display in the container. When the header is toggled, this content will be hidden or shown.
1.3.0
.customHeaderVariant:String
A custom variant to set on the header, instead of
Collapsible.CHILD_VARIANT_HEADER
.
The customHeaderVariant
will be not be used if the result of
headerFactory
already has a variant set.
1.3.0
.See also:
headerFactory:AbstractDisplayObjectFactory<Dynamic, DisplayObject>
Creates the header control that is used to toggle the visibility of the
content. The header of a Collapsible
must be of type
openfl.display.DisplayObject
.
Collapsible
supports a few different events for determining when to
toggle the visibility of the content, depending on whether the header
implements certain specific interfaces. The following interfaces and
events are supported, in the following order of precedence.
-
If the header implements
feathers.core.IOpenCloseToggle
, theCollapsible
will listen for the header to dispatchopenfl.events.Event.OPEN
andopenfl.events.Event.CLOSE
to determine when to toggle the visibility of the content. -
If the header implements
feathers.controls.IToggle
, theCollapsible
will listen for the header to dispatchopenfl.events.Event.CHANGE
to determine when to toggle the visibility of the content. -
If the header implements
feathers.controls.ITriggerView
, theCollapsible
will listen for the header to dispatchfeathers.events.TriggerEvent.TRIGGER
to determine when to toggle the visibility of the content. -
If the header does not implement any of the above events, the header will listen for
openfl.events.MouseEvent.CLICK
.
In the following example, a custom header factory is provided:
collapsible.headerFactory = () ->
{
return new ToggleButton();
};
1.3.0
.openCloseDuration:Float
The duration, measured in seconds, of the animation when the content opens and closes.
In the following example, the duration of the animation that toggles the thumb is set to 500 milliseconds:
collapsible.openCloseDuration = 0.5;
1.3.0
.See also:
openCloseEase:IEasing = Quart.easeOut
The easing function to use when animating open or closed.
1.3.0
.See also:
text:String
The text to display in the header.
The header must implement ITextControl
to display text. The default
header is a ToggleButton
, which can display text.
The following example sets the header's text:
collapsible.text = "Header Text";
1.3.0
.Methods
closeContent(animate:Bool = true):Void
Closes the content, if it is currently open.
1.3.0
.openContent(animate:Bool = true):Void
Opens the content, if it is currently closed.
1.3.0
.