Popup - 图1

Popup Vue 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 Vue component represents Popup component.

Popup Components

There are following components included:

  • f7-popup - popup element

Popup Properties

PropTypeDescription
<f7-popup> properties
tablet-fullscreenbooleanDefines 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

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

Popup Events

EventDescription
<f7-popup> events
popup:openEvent will be triggered when Popup starts its opening animation
popup:openedEvent will be triggered after Popup completes its opening animation
popup:closeEvent will be triggered when Popup starts its closing animation
popup:closedEvent will be triggered after Popup completes its closing animation
popup:swipestartEvent will be triggered in the beginning of swipe-to-close interaction (when user just started to drag popup)
popup:swipemoveEvent will be triggered on swipe-to-close move interaction
popup:swipeendEvent will be triggered on swipe-to-close release
popup:swipecloseEvent 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 popup-open property (to open it) and popup-close property to close it

Access To Popup Instance

You can access Popup initialized instance by accessing .f7Popup component’s property.

Examples

  1. <template>
  2. <f7-page @page:beforeremove="onPageBeforeRemove">
  3. <f7-navbar title="Popup"></f7-navbar>
  4. <f7-block>
  5. <p>
  6. <f7-button fill popup-open=".demo-popup">Open Popup</f7-button>
  7. </p>
  8. <p>
  9. <f7-button fill @click="popupOpened = true">Open Via Prop Change</f7-button>
  10. </p>
  11. <p>
  12. <f7-button fill @click="createPopup">Create Dynamic Popup</f7-button>
  13. </p>
  14. <p>
  15. <f7-button fill popup-open=".demo-popup-swipe">Swipe To Close</f7-button>
  16. </p>
  17. <p>
  18. <f7-button fill popup-open=".demo-popup-swipe-handler">With Swipe Handler</f7-button>
  19. </p>
  20. <p>
  21. <f7-button fill popup-open=".demo-popup-push">Popup Push</f7-button>
  22. </p>
  23. </f7-block>
  24. <f7-popup class="demo-popup" :opened="popupOpened" @popup:closed="popupOpened = false">
  25. <f7-page>
  26. <f7-navbar title="Popup Title">
  27. <f7-nav-right>
  28. <f7-link popup-close>Close</f7-link>
  29. </f7-nav-right>
  30. </f7-navbar>
  31. <f7-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...</p>
  34. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula...</p>
  35. </f7-block>
  36. </f7-page>
  37. </f7-popup>
  38. <f7-popup class="demo-popup-swipe" swipe-to-close>
  39. <f7-page>
  40. <f7-navbar title="Swipe To Close">
  41. <f7-nav-right>
  42. <f7-link popup-close>Close</f7-link>
  43. </f7-nav-right>
  44. </f7-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. </f7-page>
  49. </f7-popup>
  50. <f7-popup class="demo-popup-swipe-handler" swipe-to-close swipe-handler=".swipe-handler">
  51. <f7-page>
  52. <f7-block-title large>Hello!</f7-block-title>
  53. <f7-block strong>
  54. <p class="swipe-handler"><b>Swipe works only on this paragraph</b></p>
  55. <p>Lorem ipsum dolor sit amet...</p>
  56. </f7-block>
  57. </f7-page>
  58. </f7-popup>
  59. <f7-popup class="demo-popup-push" push>
  60. <f7-page>
  61. <f7-navbar title="Popup Push">
  62. <f7-nav-right>
  63. <f7-link popup-close>Close</f7-link>
  64. </f7-nav-right>
  65. </f7-navbar>
  66. <f7-block strong>
  67. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
  68. </f7-block>
  69. </f7-page>
  70. </f7-popup>
  71. </f7-page>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. popupOpened: false,
  78. };
  79. },
  80. methods: {
  81. createPopup() {
  82. const self = this;
  83. // Create popup
  84. if (!self.popup) {
  85. self.popup = self.$f7.popup.create({
  86. content: `
  87. <div class="popup">
  88. <div class="page">
  89. <div class="navbar">
  90. <div class="navbar-bg">
  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...</p>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. `.trim(),
  105. });
  106. }
  107. // Open it
  108. self.popup.open();
  109. },
  110. onPageBeforeRemove() {
  111. const self = this;
  112. // Destroy popup when page removed
  113. if (self.popup) self.popup.destroy();
  114. },
  115. },
  116. };
  117. </script>

← Popover

Preloader →