We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
quickApp ReferencesQuick AppElementsdrawer

drawer

Overview

If the drawer element is used, the drawer is not displayed by default. You can swipe from the screen side or call an API to display it. The flex layout is supported.

Application Scope

Expand

Item

Description

Applicable devices

Mobile phones, tablets, and telematics devices

Applicable regions

Global

Subelements

Subelements are supported, for example, the drawer-navigation element.

Attribute

In addition to general attributes, the attribute listed in the following table is supported.

Expand

Attribute

Type

Default Value

Mandatory

Description

enableswipe

boolean

true

No

Controls whether the drawer can be opened or closed by swiping. This feature is enabled by default.

Styles

Common styles are supported.

Events

In addition to common events, the events listed in the following table are supported.

Expand

Event

Parameter

Description

change

{direction:directionValue, state: stateValue}

Callback upon the drawer opening or closing.

  • direction: position of the drawer.
    • start: drawer on the left side.
    • end: drawer on the right side.
  • state: status of the drawer.
    • 0: closed.
    • 1: opened.

scroll

{direction:directionValue, slideOffset:offsetValue, state:stateValue}

Event callback upon drawer scrolling.

  • direction: position of the drawer during scrolling.
  • slideOffset: indicates the slide offset of the drawer. The value ranges from 0.0 to 1.0.
  • state: current status of a drawer.
    • 0: A drawer is not scrolling.
    • 1: A drawer is being swiped by the user.
    • 2: A user took fingers off the screen and the drawer is scrolling to the target position.

Methods

Expand

Method

Parameter

Description

openDrawer

object

Opens the drawer in the specified position.

closeDrawer

object

Closes the drawer in the specified position.

openDrawer parameters

Expand

Parameter

Type

Mandatory

Default Value

Description

direction

string

No

-

The value can be start or end.

If the value of direction is not set, and there exists only one drawer-navigation, the drawer-navigation is opened by default. If the left draw-navigation and right draw-navigation both exist, the left draw-navigation is opened by default. This parameter does not take effect when the specified value does not match the value of direction in drawer-navigation.

closeDrawer parameters

Expand

Parameter

Type

Mandatory

Default Value

Description

direction

string

No

-

The value can be start or end.

If the value of direction is not set, and there exists only one drawer-navigation, the drawer-navigation is closed by default. If the left draw-navigation and right draw-navigation both exist, the value of direction must be specified. This parameter does not take effect when the specified value does not match the value of direction in drawer-navigation.

Sample Code

Collapse
Word wrap
Dark theme
Copy code
  1. <template>
  2. <drawer class="drawer" id="drawer" enableswipe="{{enableSwipe}}" onchange="onDrawerStateChanged" onscroll="onDrawerScroll">
  3. <div class="content">
  4. <input class="btn" type="button" value="Toggle enableswipe" onclick="toggleEnableSwipe" />
  5. <input class="btn" type="button" value="Open Left" onclick="openLeft" />
  6. <input class="btn" type="button" value="Open Right" onclick="openRight" />
  7. <input class="btn" type="button" value="Open Default" onclick="openDefault" />
  8. </div>
  9. <drawer-navigation class="navigation" direction="start">
  10. <input class="btn" type="button" value="Toggle enableswipe" onclick="toggleEnableSwipe" />
  11. <input class="btn" type="button" value="Close Left" onclick="closeLeft" />
  12. <input class="btn" type="button" value="Close Default" onclick="closeDefault" />
  13. </drawer-navigation>
  14. <drawer-navigation class="navigation" direction="end">
  15. <input class="btn" type="button" value="Toggle enableswipe" onclick="toggleEnableSwipe" />
  16. <input class="btn" type="button" value="Close Right" onclick="closeRight" />
  17. </drawer-navigation>
  18. </drawer>
  19. </template>
  20. <style>
  21. .drawer {
  22. width: 100%;
  23. height: 100%;
  24. }
  25. .content {
  26. background-color: #808080;
  27. flex-direction: column;
  28. align-items: center;
  29. }
  30. .btn {
  31. width: 400px;
  32. height: 100px;
  33. margin: 16px;
  34. background-color: #00bfff;
  35. color: #ffffff;
  36. }
  37. .navigation {
  38. width: 70%;
  39. height: 100%;
  40. background-color: #ffffff;
  41. flex-direction: column;
  42. align-items: center;
  43. }
  44. </style>
  45. <script>
  46. module.exports = {
  47. data: {
  48. enableSwipe: true
  49. },
  50. onDrawerStateChanged(params) {
  51. console.log("change - direction:" + params.direction + " state:" + params.state);
  52. },
  53. onDrawerScroll(params) {
  54. console.log("scroll - direction:" + params.direction + " slideOffset:" + params.slideOffset + " state:" + params.state);
  55. },
  56. toggleEnableSwipe() {
  57. this.enableSwipe = !this.enableSwipe
  58. },
  59. openLeft() {
  60. this.$element('drawer').openDrawer({ direction: 'start' })
  61. },
  62. openRight() {
  63. this.$element('drawer').openDrawer({ direction: 'end' })
  64. },
  65. openDefault() {
  66. this.$element('drawer').openDrawer()
  67. },
  68. closeLeft() {
  69. this.$element('drawer').closeDrawer({ direction: 'start' })
  70. },
  71. closeRight() {
  72. this.$element('drawer').closeDrawer({ direction: 'end' })
  73. },
  74. closeDefault() {
  75. this.$element('drawer').closeDrawer()
  76. },
  77. }
  78. </script>

Version Change History

Expand

Version

Date

Description

1080

2021-12-28

First official release.

Search in References
Enter a keyword.