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)

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

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. </f7-block>
  21. <f7-popup class="demo-popup" :opened="popupOpened" @popup:closed="popupOpened = false">
  22. <f7-page>
  23. <f7-navbar title="Popup Title">
  24. <f7-nav-right>
  25. <f7-link popup-close>Close</f7-link>
  26. </f7-nav-right>
  27. </f7-navbar>
  28. <f7-block>
  29. <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>
  30. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
  31. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula...</p>
  32. </f7-block>
  33. </f7-page>
  34. </f7-popup>
  35. <f7-popup class="demo-popup-swipe" swipe-to-close>
  36. <f7-page>
  37. <f7-navbar title="Swipe To Close">
  38. <f7-nav-right>
  39. <f7-link popup-close>Close</f7-link>
  40. </f7-nav-right>
  41. </f7-navbar>
  42. <div style="height: 100%" class="display-flex justify-content-center align-items-center">
  43. <p>Swipe me up or down</p>
  44. </div>
  45. </f7-page>
  46. </f7-popup>
  47. <f7-popup class="demo-popup-swipe-handler" swipe-to-close swipe-handler=".swipe-handler">
  48. <f7-page>
  49. <f7-block-title large>Hello!</f7-block-title>
  50. <f7-block strong>
  51. <p class="swipe-handler"><b>Swipe works only on this paragraph</b></p>
  52. <p>Lorem ipsum dolor sit amet...</p>
  53. </f7-block>
  54. </f7-page>
  55. </f7-popup>
  56. </f7-page>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. popupOpened: false,
  63. };
  64. },
  65. methods: {
  66. createPopup() {
  67. const self = this;
  68. // Create popup
  69. if (!self.popup) {
  70. self.popup = self.$f7.popup.create({
  71. content: `
  72. <div class="popup">
  73. <div class="page">
  74. <div class="navbar">
  75. <div class="navbar-inner">
  76. <div class="title">Dynamic Popup</div>
  77. <div class="right"><a href="#" class="link popup-close">Close</a></div>
  78. </div>
  79. </div>
  80. <div class="page-content">
  81. <div class="block">
  82. <p>This popup was created dynamically</p>
  83. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non...</p>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. `.trim(),
  89. });
  90. }
  91. // Open it
  92. self.popup.open();
  93. },
  94. onPageBeforeRemove() {
  95. const self = this;
  96. // Destroy popup when page removed
  97. if (self.popup) self.popup.destroy();
  98. },
  99. },
  100. };
  101. </script>