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.

There are following components included:

  • f7-popup - popup element
Prop Type Description
<f7-popup> properties
--- --- ---
tablet-fullscreen boolean Defines whether the popup should be displayed fullscreen on tablets or not
opened boolean Allows to open/close Popup and set its initial state
backdrop boolean Enables Popup backdrop (dark semi transparent layer behind). By default inherits same app parameter value (true)
backdropEl string object HTML element or string CSS selector of custom backdrop element
closeByBackdropClick boolean When enabled, popup will be closed on backdrop click. By default inherits same app parameter value (true)
closeOnEscape boolean When enabled, popup will be closed on ESC keyboard key press
animate boolean Whether 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)
swipeToClose boolean 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.
swipeHandler HTMLElement 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)
push boolean When 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.
<f7-popup> methods
.open(animate) Open popup
.close(animate) Close popup
Event Description
<f7-popup> events
--- ---
popup:open Event will be triggered when Popup starts its opening animation
popup:opened Event will be triggered after Popup completes its opening animation
popup:close Event will be triggered when Popup starts its closing animation
popup:closed Event will be triggered after Popup completes its closing animation
popup:swipestart Event will be triggered in the beginning of swipe-to-close interaction (when user just started to drag popup)
popup:swipemove Event will be triggered on swipe-to-close move interaction
popup:swipeend Event will be triggered on swipe-to-close release
popup:swipeclose Event 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>

25. <f7-popup class="demo-popup" :opened="popupOpened" @popup:closed="popupOpened = false">
26. <f7-page>
27. <f7-navbar title="Popup Title">
28. <f7-nav-right>
29. <f7-link popup-close>Close</f7-link>
30. </f7-nav-right>
31. </f7-navbar>
32. <f7-block>
33. <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>
34. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
35. <p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula...</p>
36. </f7-block>
37. </f7-page>
38. </f7-popup>

40. <f7-popup class="demo-popup-swipe" swipe-to-close>
41. <f7-page>
42. <f7-navbar title="Swipe To Close">
43. <f7-nav-right>
44. <f7-link popup-close>Close</f7-link>
45. </f7-nav-right>
46. </f7-navbar>

48. <div style="height: 100%" class="display-flex justify-content-center align-items-center">
49. <p>Swipe me up or down</p>
50. </div>
51. </f7-page>
52. </f7-popup>

54. <f7-popup class="demo-popup-swipe-handler" swipe-to-close swipe-handler=".swipe-handler">
55. <f7-page>
56. <f7-block-title large>Hello!</f7-block-title>
57. <f7-block strong>
58. <p class="swipe-handler"><b>Swipe works only on this paragraph</b></p>
59. <p>Lorem ipsum dolor sit amet...</p>
60. </f7-block>
61. </f7-page>
62. </f7-popup>

64. <f7-popup class="demo-popup-push" push>
65. <f7-page>
66. <f7-navbar title="Popup Push">
67. <f7-nav-right>
68. <f7-link popup-close>Close</f7-link>
69. </f7-nav-right>
70. </f7-navbar>
71. <f7-block strong>
72. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
73. </f7-block>
74. </f7-page>
75. </f7-popup>

77. </f7-page>
78. </template>

80. <script>
81. export default {
82. data() {
83. return {
84. popupOpened: false,
85. };
86. },
87. methods: {
88. createPopup() {
89. const self = this;
90. // Create popup
91. if (!self.popup) {
92. self.popup = self.$f7.popup.create({
93. content: `
94. <div class="popup">
95. <div class="page">
96. <div class="navbar">
97. <div class="navbar-bg">
98. <div class="navbar-inner">
99. <div class="title">Dynamic Popup</div>
100. <div class="right"><a href="#" class="link popup-close">Close</a></div>
101. </div>
102. </div>
103. <div class="page-content">
104. <div class="block">
105. <p>This popup was created dynamically</p>
106. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse faucibus mauris leo, eu bibendum neque congue non...</p>
107. </div>
108. </div>
109. </div>
110. </div>
111. `.trim(),
112. });
113. }
114. // Open it
115. self.popup.open();
116. },
117. onPageBeforeRemove() {
118. const self = this;
119. // Destroy popup when page removed
120. if (self.popup) self.popup.destroy();
121. },
122. },
123. };
124. </script>

← Popover

Preloader →