Sheet Modal - 图1

Sheet Modal Vue Component

Sheet Modal is a special overlay type which is similar to Picker/Calendar’s overlay. Such modal allows to create custom picker overlays with custom content.

Sheet Modal Vue component represents Sheet Modal component.

Sheet Modal Components

There are following components included:

  • **f7-sheet** - sheet modal element

Sheet Modal Properties

PropTypeDescription
<f7-sheet> properties
positionstringSheet position, can be top or bottom. By default is bottom
topbooleanSame as position="top"
bottombooleanSame as position="bottom"
backdropbooleanEnable to render additional sheet modal backdrop when required
backdropElstring
object
HTML element or string CSS selector of custom backdrop element
openedbooleanAllows to open/close Sheet Modal and set its initial state
closeByBackdropClickbooleanWhen enabled, sheet will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClickbooleanWhen enabled, sheet will be closed on when click outside of it. By default inherits same app parameter value
closeOnEscapebooleanWhen enabled, sheet will be closed on ESC keyboard key press
swipeToClosebooleanWhether the Sheet can be closed with swipe gesture
swipeToStepbooleanWhen enabled it will be possible to split opened sheet into two states: partially opened and fully opened that can be controlled with swipe
swipeHandlerHTMLElement
string
If not passed, then whole Sheet can be swiped to close. You can pass here HTML element or string CSS selector of custom element that will be used as a swipe target. (swipeToClose or swipeToStep must be also enabled)

Sheet Modal Methods

<f7-sheet> methods
.open(animate)Open sheet modal
.close(animate)Close sheet modal

Sheet Modal Events

EventDescription
<f7-sheet> events
sheet:openEvent will be triggered when Sheet Modal starts its opening animation
sheet:openedEvent will be triggered after Sheet Modal completes its opening animation
sheet:closeEvent will be triggered when Sheet Modal starts its closing animation
sheet:closedEvent will be triggered after Sheet Modal completes its closing animation
sheet:stepopenEvent will be triggered on Sheet swipe step open/expand
sheet:stepcloseEvent will be triggered on Sheet swipe step close/collapse
sheet:stepprogressEvent will be triggered on Sheet swipe step between step opened and closed state. As event.detail it receives step open progress number (from 0 to 1)

Open And Close Sheet Modal

You can control Sheet Modal state, open and closing it:

  • using its Sheet Modal API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant sheet-open property (to open it) and sheet-close property to close it

Access To Sheet Modal Instance

You can access Sheet Modal initialized instance by accessing **.f7Sheet** component’s property.

Examples

  1. <template>
  2. <f7-page @page:beforeremove="onPageBeforeRemove" @page:beforeout="onPageBeforeOut">
  3. <f7-navbar title="Sheet Modal"></f7-navbar>
  4. <f7-block>
  5. <p>
  6. <f7-button fill sheet-open=".demo-sheet">Open Sheet</f7-button>
  7. </p>
  8. <p>
  9. <f7-button fill @click="createSheet">Create Dynamic Sheet</f7-button>
  10. </p>
  11. <p>
  12. <f7-button fill @click="sheetOpened = true">Open Via Prop Change</f7-button>
  13. </p>
  14. <p>
  15. <f7-button fill sheet-open=".demo-sheet-swipe-to-close">Swipe To Close</f7-button>
  16. </p>
  17. <p>
  18. <f7-button fill sheet-open=".demo-sheet-swipe-to-step">Swipe To Step</f7-button>
  19. </p>
  20. </f7-block>
  21. <f7-sheet class="demo-sheet" :opened="sheetOpened" @sheet:closed="sheetOpened = false">
  22. <f7-toolbar>
  23. <div class="left"></div>
  24. <div class="right">
  25. <f7-link sheet-close>Close</f7-link>
  26. </div>
  27. </f7-toolbar>
  28. <!-- Scrollable sheet content -->
  29. <f7-page-content>
  30. <f7-block>
  31. <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae ducimus dolorum ipsa aliquid accusamus perferendis laboriosam delectus numquam minima animi, libero illo in tempora harum sequi corporis alias ex adipisci...</p>
  32. <!-- ... -->
  33. </f7-block>
  34. </f7-page-content>
  35. </f7-sheet>
  36. <!-- Swipe to close demo sheet -->
  37. <f7-sheet
  38. class="demo-sheet-swipe-to-close"
  39. style="height:auto; --f7-sheet-bg-color: #fff;"
  40. swipe-to-close
  41. backdrop
  42. >
  43. <f7-page-content>
  44. <f7-block-title large>Hello!</f7-block-title>
  45. <f7-block>
  46. <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab...</p>
  47. </f7-block>
  48. </f7-page-content>
  49. </f7-sheet>
  50. <!-- Swipe to step demo sheet -->
  51. <f7-sheet
  52. class="demo-sheet-swipe-to-step"
  53. style="height:auto; --f7-sheet-bg-color: #fff;"
  54. swipe-to-close
  55. swipe-to-step
  56. backdrop
  57. >
  58. <!-- Initial swipe step sheet content -->
  59. <div class="sheet-modal-swipe-step">
  60. <div class="display-flex padding justify-content-space-between align-items-center">
  61. <div style="font-size: 18px"><b>Total:</b></div>
  62. <div style="font-size: 22px"><b>$500</b></div>
  63. </div>
  64. <div class="padding-horizontal padding-bottom">
  65. <f7-button large fill>Make Payment</f7-button>
  66. <div class="margin-top text-align-center">Swipe up for more details</div>
  67. </div>
  68. </div>
  69. <!-- Rest of the sheet content that will opened with swipe -->
  70. <f7-block-title medium class="margin-top">Your order:</f7-block-title>
  71. <f7-list no-hairlines>
  72. <f7-list-item title="Item 1">
  73. <b slot="after" class="text-color-black">$200</b>
  74. </f7-list-item>
  75. <f7-list-item title="Item 2">
  76. <b slot="after" class="text-color-black">$180</b>
  77. </f7-list-item>
  78. <f7-list-item title="Delivery">
  79. <b slot="after" class="text-color-black">$120</b>
  80. </f7-list-item>
  81. </f7-list>
  82. </f7-sheet>
  83. </f7-page>
  84. </template>
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. sheetOpened: false,
  6. };
  7. },
  8. methods: {
  9. createSheet() {
  10. const self = this;
  11. const $ = self.$$;
  12. // Create sheet modal
  13. if (!self.sheet) {
  14. self.sheet = self.$f7.sheet.create({
  15. content: `
  16. <div class="sheet-modal">
  17. <div class="toolbar">
  18. <div class="toolbar-inner justify-content-flex-end">
  19. <a href="#" class="link sheet-close">Close</a>
  20. </div>
  21. </div>
  22. <div class="sheet-modal-inner">
  23. <div class="page-content">
  24. <div class="block">
  25. <p>This sheet modal was created dynamically</p>
  26. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non. Ut leo mauris, eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus, viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatis dignissim...</p>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. `.trim(),
  32. });
  33. }
  34. // Close inline sheet
  35. if ($('.demo-sheet.modal-in').length > 0) self.$f7.sheet.close('.demo-sheet');
  36. // Open it
  37. self.sheet.open();
  38. },
  39. onPageBeforeOut() {
  40. const self = this;
  41. // Close opened sheets on page out
  42. self.$f7.sheet.close();
  43. },
  44. onPageBeforeRemove() {
  45. const self = this;
  46. // Destroy sheet modal when page removed
  47. if (self.sheet) self.sheet.destroy();
  48. },
  49. },
  50. };
  51. </script>