Modal drawer component that slides in from the edge of the screen.
| Name | Type | Description |
|---|---|---|
options |
DrawerOptions |
Configuration options for the drawer. |
options.position |
DrawerPosition |
Screen edge the drawer is attached to (bottom, left, right, top). Defaults to |
options.backdrop |
string | Texture | Container | Sprite | Graphics |
Backdrop view or settings. If omitted, a large tinted sprite covering the screen is used. |
options.backdropColor |
number |
Color of the backdrop (if backdrop is not provided). Defaults to black. |
options.backdropAlpha |
number |
Alpha of the backdrop when the drawer is open. Defaults to 0.5. |
options.background |
string | Texture | Container | Sprite | Graphics |
Background view or settings for the drawer. |
options.content |
Container | Container<Array> |
Content view or array of views for the drawer. |
options.width |
number |
Width of the drawer panel. For left/right drawers it is the visible width. |
options.height |
number |
Height of the drawer panel. For top/bottom drawers it is the visible height. |
options.padding |
number |
Padding around the drawer content. Defaults to 20. |
options.scrollBox |
ScrollBoxOptions |
Configuration options for the scroll box containing the content. |
options.animations |
object |
Animation settings for opening and closing the drawer. Without them the drawer opens and closes instantly. |
options.animations.open |
Animation |
Animation settings for opening the drawer. |
options.animations.close |
Animation |
Animation settings for closing the drawer. |
options.closeOnBackdropClick |
boolean |
Whether to close the drawer when clicking on the backdrop. Defaults to true. |
options.swipeToClose |
boolean |
Whether to enable swipe gesture to close the drawer. Defaults to true. |
options.nineSliceSprite |
unknown |
Nine-slice scaling settings for the background
(left, top, right, bottom). Used when |
Example
const drawer = new Drawer({
background: new Graphics().roundRect(0, 0, 400, 300, 20).fill(0xFFFFFF),
content: myContent,
position: 'bottom',
width: 400,
height: 300,
animations: { open: { props: {}, duration: 300 }, close: { props: {}, duration: 300 } },
});
drawer.setScreenSize(app.screen.width, app.screen.height);
drawer.onClose.connect(() => {
console.log('Drawer closed');
});
view.addChild(drawer);
drawer.open();
Extends
- Container
Members
Whether the drawer is open. Becomes false only after the close animation has finished.
onClose Signal<() => void>
Signal emitted when the drawer is closed.
Open or close animations in flight; a new animation or a re-anchor stops them first.
Gets the drawer height from options or innerView.
Gets the drawer padding from options.
Gets the drawer position from options.
Gets the drawer width from options or innerView.
Kept as a field so destroy() can detach it from the shared ticker.
Methods
Slides the drawer out, hides it and emits onClose (instantly if no close animation is set).
Destroys the component, detaching it from the shared ticker.
| Name | Type | Attributes | Description |
|---|---|---|---|
options |
boolean | DestroyOptions |
<optional> |
Options parameter. |
Hides the drawer (alias for close).
Shows the drawer and slides it in (instantly if no open animation is set).
Sets the screen dimensions for positioning the drawer. The drawer automatically spans the full edge:
- Bottom/Top drawers: full screen width
- Left/Right drawers: full screen height
| Name | Type | Description |
|---|---|---|
width |
number |
Screen width. |
height |
number |
Screen height. |
Shows the drawer (alias for open).
Gets the closed position for the drawer based on its position setting.
Returns:
| Type | Description |
|---|---|
| { x : number, y : number } |
Gets the open position for the drawer based on its position setting.
Returns:
| Type | Description |
|---|---|
| { x : number, y : number } |
Initializes the backdrop (semi-transparent background).
Initializes the content area.
Initializes the inner view (background panel).
Initializes swipe gesture handling for closing.
Stops the open or close animation in flight, if any, where it is.