Popup - 图1

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

Popup Components

There are following components included:

  • **Popup** / **F7Popup** - 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)
closeByBackdropClickbooleanWhen enabled, popup will be closed on backdrop click. By default inherits same app parameter value (true)
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)

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

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 accessing **.f7Popup** component’s property.

Examples

  1. export default class extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. this.state = {
  5. popupOpened: false,
  6. }
  7. }
  8. render() {
  9. return (
  10. <Page onPageBeforeRemove={this.onPageBeforeRemove.bind(this)}>
  11. <Navbar title="Popup"></Navbar>
  12. <Block>
  13. <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>
  14. <p>
  15. <Button raised popupOpen=".demo-popup">Open Popup</Button>
  16. </p>
  17. <p>
  18. <Button raised onClick={() => this.setState({ popupOpened : true })}>Open Via Prop Change</Button>
  19. </p>
  20. <p>
  21. <Button raised onClick={this.createPopup.bind(this)}>Create Dynamic Popup</Button>
  22. </p>
  23. </Block>
  24. <Popup className="demo-popup" opened={this.state.popupOpened} onPopupClosed={() => this.setState({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. </Page>
  39. )
  40. }
  41. createPopup() {
  42. const self = this;
  43. // Create popup
  44. if (!self.popup) {
  45. self.popup = self.$f7.popup.create({
  46. content: `
  47. <div class="popup">
  48. <div class="page">
  49. <div class="navbar">
  50. <div class="navbar-inner">
  51. <div class="title">Dynamic Popup</div>
  52. <div class="right"><a href="#" class="link popup-close">Close</a></div>
  53. </div>
  54. </div>
  55. <div class="page-content">
  56. <div class="block">
  57. <p>This popup was created dynamically</p>
  58. <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>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. `.trim(),
  64. });
  65. }
  66. // Open it
  67. self.popup.open();
  68. }
  69. onPageBeforeRemove() {
  70. const self = this;
  71. // Destroy popup when page removed
  72. if (self.popup) self.popup.destroy();
  73. }
  74. };