Popup - 图1

Popup Svelte Component

Popup is a popup window with any HTML content that pops up over App’s main content. Popup as all other overlays is part of so called “Temporary Views”.

Popup Svelte component represents Popup component.

Popup Components

There are following components included:

  • Popup - popup element

Popup Properties

PropTypeDescription
<Popup> properties
tabletFullscreenbooleanDefines whether the popup should be displayed fullscreen on tablets or not
openedbooleanAllows to open/close Popup and set its initial state
backdropbooleanEnables Popup backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
backdropElstring
object
HTML element or string CSS selector of custom backdrop element
closeByBackdropClickbooleanWhen enabled, popup will be closed on backdrop click. By default inherits same app parameter value (true)
closeOnEscapebooleanWhen enabled, popup will be closed on ESC keyboard key press
animatebooleanWhether the Popup should be opened/closed with animation or not. Can be overwritten in .open() and .close() methods. By default inherits same app parameter value (true)
swipeToCloseboolean
string
Whether the Popup can be closed with swipe gesture. Can be true to allow to close popup with swipes to top and to bottom, or can be to-top (string) to allow only swipe to top to close popup, or to-bottom (string) to allow only swipe to bottom to close.
swipeHandlerHTMLElement
string
If not passed, then whole popup 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 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 popup-push class to Popup element.

Popup Methods

<Popup> methods
.open(animate)Open popup
.close(animate)Close popup

Popup Events

EventDescription
<Popup> events
popupOpenEvent will be triggered when Popup starts its opening animation
popupOpenedEvent will be triggered after Popup completes its opening animation
popupCloseEvent will be triggered when Popup starts its closing animation
popupClosedEvent will be triggered after Popup completes its closing animation
popupSwipeStartEvent will be triggered in the beginning of swipe-to-close interaction (when user just started to drag popup)
popupSwipeMoveEvent will be triggered on swipe-to-close move interaction
popupSwipeEndEvent will be triggered on swipe-to-close release
popupSwipeCloseEvent will be triggered when popup closed with swipe

Open And Close Popup

You can control Popup state, open and closing it:

  • using Popup API
  • by passing true or false to its opened prop
  • by clicking on Link or Button with relevant popupOpen property (to open it) and popupClose property to close it

Access To Popup Instance

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

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

Examples

  1. <Page>
  2. <Navbar title="Popup"></Navbar>
  3. <Block>
  4. <p>Popup is a modal window with any HTML content that pops up over App's main content. Popup as all other overlays is part of so called "Temporary Views".</p>
  5. <p>
  6. <Button fill popupOpen=".demo-popup">Open Popup</Button>
  7. </p>
  8. <p>
  9. <Button fill onClick={() => popupOpened = true}>Open Via Prop Change</Button>
  10. </p>
  11. <p>
  12. <Button fill onClick={createPopup}>Create Dynamic Popup</Button>
  13. </p>
  14. <p>
  15. <Button fill popupOpen=".demo-popup-swipe">Swipe To Close</Button>
  16. </p>
  17. <p>
  18. <Button fill popupOpen=".demo-popup-swipe-handler">With Swipe Handler</Button>
  19. </p>
  20. <p>
  21. <Button fill popupOpen=".demo-popup-push">Popup Push</Button>
  22. </p>
  23. </Block>
  24. <Popup class="demo-popup" opened={popupOpened} onPopupClosed={() => popupOpened = false}>
  25. <Page>
  26. <Navbar title="Popup Title">
  27. <NavRight>
  28. <Link popupClose>Close</Link>
  29. </NavRight>
  30. </Navbar>
  31. <Block>
  32. <p>Here comes popup. You can put here anything, even independent view with its own navigation. Also not, that by default popup looks a bit different on iPhone/iPod and iPad, on iPhone it is fullscreen.</p>
  33. <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>
  34. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula. Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh, suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctor vel tristique ac, malesuada ut ante. Sed molestie, est in eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque tempor congue massa quis faucibus. Vestibulum nunc eros, convallis blandit dui sit amet, gravida adipiscing libero.</p>
  35. </Block>
  36. </Page>
  37. </Popup>
  38. <Popup class="demo-popup-swipe" swipeToClose>
  39. <Page>
  40. <Navbar title="Swipe To Close">
  41. <NavRight>
  42. <Link popupClose>Close</Link>
  43. </NavRight>
  44. </Navbar>
  45. <div style="height: 100%" class="display-flex justify-content-center align-items-center">
  46. <p>Swipe me up or down</p>
  47. </div>
  48. </Page>
  49. </Popup>
  50. <Popup class="demo-popup-swipe-handler" swipeToClose swipeHandler=".swipe-handler">
  51. <Page>
  52. <BlockTitle large>Hello!</BlockTitle>
  53. <Block strong>
  54. <p class="swipe-handler"><b>Swipe works only on this paragraph</b></p>
  55. <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>
  56. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula. Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh, suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctor vel tristique ac, malesuada ut ante. Sed molestie, est in eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque tempor congue massa quis faucibus. Vestibulum nunc eros, convallis blandit dui sit amet, gravida adipiscing libero.</p>
  57. <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>
  58. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula. Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh, suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctor vel tristique ac, malesuada ut ante. Sed molestie, est in eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque tempor congue massa quis faucibus. Vestibulum nunc eros, convallis blandit dui sit amet, gravida adipiscing libero.</p>
  59. </Block>
  60. </Page>
  61. </Popup>
  62. <Popup class="demo-popup-push" push>
  63. <Page>
  64. <Navbar title="Popup Push">
  65. <NavRight>
  66. <Link popupClose>Close</Link>
  67. </NavRight>
  68. </Navbar>
  69. <Block strong>
  70. <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>
  71. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula. Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh, suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctor vel tristique ac, malesuada ut ante. Sed molestie, est in eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque tempor congue massa quis faucibus. Vestibulum nunc eros, convallis blandit dui sit amet, gravida adipiscing libero.</p>
  72. <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>
  73. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula. Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh, suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctor vel tristique ac, malesuada ut ante. Sed molestie, est in eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque tempor congue massa quis faucibus. Vestibulum nunc eros, convallis blandit dui sit amet, gravida adipiscing libero.</p>
  74. </Block>
  75. </Page>
  76. </Popup>
  77. </Page>
  78. <script>
  79. import {f7, Page, Navbar, Block, Button, Popup, NavRight, Link, BlockTitle} from 'framework7-svelte';
  80. let popupOpened = false;
  81. let popup;
  82. function createPopup() {
  83. // Create popup
  84. if (!popup) {
  85. popup = f7.popup.create({
  86. content: `
  87. <div class="popup">
  88. <div class="page">
  89. <div class="navbar">
  90. <div class="navbar-bg"></div>
  91. <div class="navbar-inner">
  92. <div class="title">Dynamic Popup</div>
  93. <div class="right"><a href="#" class="link popup-close">Close</a></div>
  94. </div>
  95. </div>
  96. <div class="page-content">
  97. <div class="block">
  98. <p>This popup was created dynamically</p>
  99. <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>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. `.trim(),
  105. });
  106. }
  107. // Open it
  108. popup.open();
  109. }
  110. </script>

← Popover

Preloader →