Sheet Modal - 图1

Sheet Modal Svelte 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 Svelte component represents Sheet Modal component.

Sheet Modal Components

There are following components included:

  • Sheet - sheet modal element

Sheet Modal Properties

PropTypeDescription
<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)
pushbooleanWhen enabled it will push view behind on open. Works only when top safe area is in place. It can also be enabled by adding sheet-modal-push class to Sheet element.

Sheet Modal Methods

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

Sheet Modal Events

EventDescription
<Sheet> events
sheetOpenEvent will be triggered when Sheet Modal starts its opening animation
sheetOpenedEvent will be triggered after Sheet Modal completes its opening animation
sheetCloseEvent will be triggered when Sheet Modal starts its closing animation
sheetClosedEvent will be triggered after Sheet Modal completes its closing animation
sheetStepOpenEvent will be triggered on Sheet swipe step open/expand
sheetStepCloseEvent will be triggered on Sheet swipe step close/collapse
sheetStepProgressEvent 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 sheetOpen property (to open it) and sheetClose property to close it

Access To Sheet Modal Instance

You can access Sheet Modal initialized instance by calling .instance() component’s method. For example:

  1. <Sheet bind:this={component}>...</Sheet>
  2. <script>
  3. let component;
  4. // to get instance in some method
  5. component.instance()
  6. </script>

Examples

  1. <Page onPageBeforeOut={onPageBeforeOut} onPageBeforeRemove={onPageBeforeRemove}>
  2. <Navbar title="Sheet Modal"></Navbar>
  3. <Block>
  4. <p>Sheet Modals slide up from the bottom of the screen to reveal more content. Such modals allow to create custom overlays with custom content.</p>
  5. <p>
  6. <Button fill sheetOpen=".demo-sheet">Open Sheet</Button>
  7. </p>
  8. <p>
  9. <Button fill onClick={createSheet}>Create Dynamic Sheet</Button>
  10. </p>
  11. <p>
  12. <Button fill onClick={() => sheetOpened = true}>Open Via Prop Change</Button>
  13. </p>
  14. <p>
  15. <Button fill sheetOpen=".demo-sheet-swipe-to-close">Swipe To Close</Button>
  16. </p>
  17. <p>
  18. <Button fill sheetOpen=".demo-sheet-swipe-to-step">Swipe To Step</Button>
  19. </p>
  20. <p>
  21. <Button fill sheetOpen=".demo-sheet-push">Sheet Push</Button>
  22. </p>
  23. </Block>
  24. <Sheet class="demo-sheet" opened={sheetOpened} onSheetClosed={() => sheetOpened = false}>
  25. <Toolbar>
  26. <div class="left"></div>
  27. <div class="right">
  28. <Link sheetClose>Close</Link>
  29. </div>
  30. </Toolbar>
  31. <!-- Scrollable sheet content -->
  32. <PageContent>
  33. <Block>
  34. <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>
  35. <p>Sunt magni enim saepe quasi aspernatur delectus consectetur fugiat necessitatibus qui sed, similique quis facere tempora, laudantium quae expedita ea, aperiam dolores. Aut deserunt soluta alias magnam. Consequatur, nisi, enim.</p>
  36. <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab. Quaerat quasi consectetur quidem libero? Repudiandae adipisci vel voluptatum, autem libero minus dignissimos repellat.</p>
  37. <p>Iusto, est corrupti! Totam minus voluptas natus esse possimus nobis, delectus veniam expedita sapiente ut cum reprehenderit aliquid odio amet praesentium vero temporibus obcaecati beatae aspernatur incidunt, perferendis voluptates doloribus?</p>
  38. <p>Illum id laborum tempore, doloribus culpa labore ex iusto odit. Quibusdam consequuntur totam nam obcaecati, enim cumque nobis, accusamus, quos voluptates, voluptatibus sapiente repellendus nesciunt praesentium velit ipsa illo iusto.</p>
  39. </Block>
  40. </PageContent>
  41. </Sheet>
  42. <Sheet
  43. class="demo-sheet-swipe-to-close"
  44. style="height: auto; --f7-sheet-bg-color: #fff"
  45. swipeToClose
  46. backdrop
  47. >
  48. <PageContent>
  49. <BlockTitle large>Hello!</BlockTitle>
  50. <Block>
  51. <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab. Quaerat quasi consectetur quidem libero? Repudiandae adipisci vel voluptatum, autem libero minus dignissimos repellat.</p>
  52. <p>Iusto, est corrupti! Totam minus voluptas natus esse possimus nobis, delectus veniam expedita sapiente ut cum reprehenderit aliquid odio amet praesentium vero temporibus obcaecati beatae aspernatur incidunt, perferendis voluptates doloribus?</p>
  53. </Block>
  54. </PageContent>
  55. </Sheet>
  56. <Sheet
  57. class="demo-sheet-swipe-to-step"
  58. style="height: auto; --f7-sheet-bg-color: #fff"
  59. swipeToClose
  60. swipeToStep
  61. backdrop
  62. >
  63. <div class="sheet-modal-swipe-step">
  64. <div class="display-flex padding justify-content-space-between align-items-center">
  65. <div style="font-size: 18px"><b>Total:</b></div>
  66. <div style="font-size: 22px"><b>$500</b></div>
  67. </div>
  68. <div class="padding-horizontal padding-bottom">
  69. <Button large fill>Make Payment</Button>
  70. <div class="margin-top text-align-center">Swipe up for more details</div>
  71. </div>
  72. </div>
  73. <BlockTitle medium class="margin-top">Your order:</BlockTitle>
  74. <List noHairlines>
  75. <ListItem title="Item 1">
  76. <b slot="after" class="text-color-black">$200</b>
  77. </ListItem>
  78. <ListItem title="Item 2">
  79. <b slot="after" class="text-color-black">$180</b>
  80. </ListItem>
  81. <ListItem title="Delivery">
  82. <b slot="after" class="text-color-black">$120</b>
  83. </ListItem>
  84. </List>
  85. </Sheet>
  86. <Sheet class="demo-sheet-push" push>
  87. <Toolbar>
  88. <div class="left"></div>
  89. <div class="right">
  90. <Link sheetClose>Close</Link>
  91. </div>
  92. </Toolbar>
  93. <PageContent>
  94. <Block>
  95. <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>
  96. <p>Sunt magni enim saepe quasi aspernatur delectus consectetur fugiat necessitatibus qui sed, similique quis facere tempora, laudantium quae expedita ea, aperiam dolores. Aut deserunt soluta alias magnam. Consequatur, nisi, enim.</p>
  97. <p>Eaque maiores ducimus, impedit unde culpa qui, explicabo accusamus, non vero corporis voluptatibus similique odit ab. Quaerat quasi consectetur quidem libero? Repudiandae adipisci vel voluptatum, autem libero minus dignissimos repellat.</p>
  98. <p>Iusto, est corrupti! Totam minus voluptas natus esse possimus nobis, delectus veniam expedita sapiente ut cum reprehenderit aliquid odio amet praesentium vero temporibus obcaecati beatae aspernatur incidunt, perferendis voluptates doloribus?</p>
  99. <p>Illum id laborum tempore, doloribus culpa labore ex iusto odit. Quibusdam consequuntur totam nam obcaecati, enim cumque nobis, accusamus, quos voluptates, voluptatibus sapiente repellendus nesciunt praesentium velit ipsa illo iusto.</p>
  100. </Block>
  101. </PageContent>
  102. </Sheet>
  103. </Page>
  104. <script>
  105. import {f7, Page, Navbar, Block, Button, Sheet, Toolbar, Link, PageContent, BlockTitle, List, ListItem} from 'framework7-svelte';
  106. let sheetOpened = false;
  107. let sheet;
  108. function createSheet() {
  109. // Create sheet modal
  110. if (!sheet) {
  111. sheet = f7.sheet.create({
  112. content: `
  113. <div class="sheet-modal">
  114. <div class="toolbar">
  115. <div class="toolbar-inner justify-content-flex-end">
  116. <a href="#" class="link sheet-close">Close</a>
  117. </div>
  118. </div>
  119. <div class="sheet-modal-inner">
  120. <div class="page-content">
  121. <div class="block">
  122. <p>This sheet modal was created dynamically</p>
  123. <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. Suspendisse non nisl semper tellus malesuada suscipit eu et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare consequat nunc viverra pellentesque. Aenean semper eu massa sit amet aliquam. Integer et neque sed libero mollis elementum at vitae ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibus lectus.</p>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. `.trim(),
  129. });
  130. }
  131. // Close inline sheet
  132. if (f7.$('.demo-sheet.modal-in').length > 0) f7.sheet.close('.demo-sheet');
  133. // Open it
  134. sheet.open();
  135. }
  136. function onPageBeforeOut() {
  137. // Close opened sheets on page out
  138. f7.sheet.close();
  139. }
  140. function onPageBeforeRemove() {
  141. // Destroy sheet modal when page removed
  142. if (sheet) sheet.destroy();
  143. }
  144. </script>

← Searchbar

Skeleton →