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
backdropbooleanEnable to render additional sheet modal backdrop when required
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

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

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. <f7-row tag="p">
  6. <f7-button class="col" raised sheet-open=".demo-sheet">Open Sheet</f7-button>
  7. <f7-button class="col" raised @click="createSheet">Create Dynamic Sheet</f7-button>
  8. </f7-row>
  9. <p>
  10. <f7-button class="col" raised @click="sheetOpened = true">Open Via Prop Change</f7-button>
  11. </p>
  12. </f7-block>
  13. <f7-sheet class="demo-sheet" :opened="sheetOpened" @sheet:closed="sheetOpened = false">
  14. <f7-toolbar>
  15. <div class="left"></div>
  16. <div class="right">
  17. <f7-link sheet-close>Close</f7-link>
  18. </div>
  19. </f7-toolbar>
  20. <!-- Scrollable sheet content -->
  21. <f7-page-content>
  22. <f7-block>
  23. <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>
  24. <!-- ... -->
  25. </f7-block>
  26. </f7-page-content>
  27. </f7-sheet>
  28. </f7-page>
  29. </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>