Popover - 图1

Popover Svelte Component

Popover compontent is used to manage the presentation of content in a popover. You use popovers to present information temporarily. The popover remains visible until the user taps outside of the popover window or you explicitly dismiss it.

Popover Svelte component represents Popover component.

Popover Components

There are following components included:

  • Popover

Popover Properties

PropTypeDefaultDescription
<Popover> properties
openedbooleanfalseAllows to open/close Popover and set its initial state
targetstring
object
HTML element or string CSS selector of Popover target element
backdropbooleanEnables Popover 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
closeByBackdropClickbooleantrueWhen enabled, popover will be closed on backdrop click. By default inherits same app parameter value
closeByOutsideClickbooleantrueWhen enabled, popover will be closed on when click outside of it. By default inherits same app parameter value
closeOnEscapebooleanfalseWhen enabled, popover sheet will be closed on ESC keyboard key press

Popover Methods

<Popover> methods
.open(target, animate)Open popover around target element
.close(animate)Close popover

Popover Events

EventDescription
<Popover> events
popoverOpenEvent will be triggered when Popover starts its opening animation
popoverOpenedEvent will be triggered after Popover completes its opening animation
popoverCloseEvent will be triggered when Popover starts its closing animation
popoverClosedEvent will be triggered after Popover completes its closing animation

Open And Close Popover

You can control Popover state, open and closing it:

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

Access To Popover Instance

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

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

Examples

  1. <Page>
  2. <Navbar title="Popover" />
  3. <Toolbar bottom>
  4. <Link>Dummy Link</Link>
  5. <Link popoverOpen=".popover-menu">Open Popover</Link>
  6. </Toolbar>
  7. <Block>
  8. <p><Button fill raised popoverOpen=".popover-menu">Open popover on me</Button></p>
  9. <p>Mauris fermentum neque et luctus venenatis. Vivamus a sem rhoncus, ornare tellus eu, euismod mauris. In porta turpis at semper convallis. Duis adipiscing leo eu nulla lacinia, quis rhoncus metus condimentum. Etiam nec malesuada nibh. Maecenas quis lacinia nisl, vel posuere dolor. Vestibulum condimentum, nisl ac vulputate egestas, neque enim dignissim elit, rhoncus volutpat magna enim a est. Aenean sit amet ligula neque. Cras suscipit rutrum enim. Nam a odio facilisis, elementum tellus non, <Link popoverOpen=".popover-menu">popover</Link> tortor. Pellentesque felis eros, dictum vitae lacinia quis, lobortis vitae ipsum. Cras vehicula bibendum lorem quis imperdiet.</p>
  10. <p>In hac habitasse platea dictumst. Etiam varius, ante vel ornare facilisis, velit massa rutrum dolor, ac porta magna magna lacinia nunc. Curabitur <Link popoverOpen=".popover-menu">popover!</Link> cursus laoreet. Aenean vel tempus augue. Pellentesque in imperdiet nibh. Mauris rhoncus nulla id sem suscipit volutpat. Pellentesque ac arcu in nisi viverra pulvinar. Nullam nulla orci, bibendum sed ligula non, ullamcorper iaculis mi. In hac habitasse platea dictumst. Praesent varius at nisl eu luctus. Cras aliquet porta est. Quisque elementum quis dui et consectetur. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sed laoreet purus. Pellentesque eget ante ante.</p>
  11. <p>Duis et ultricies nibh. Sed facilisis turpis urna, ac imperdiet erat venenatis eu. Proin sit amet faucibus tortor, et varius sem. Etiam vitae lacinia neque. Aliquam nisi purus, interdum in arcu sed, ultrices rutrum arcu. Nulla mi turpis, consectetur vel enim quis, facilisis viverra dui. Aliquam quis convallis tortor, quis semper ligula. Morbi ullamcorper <Link popoverOpen=".popover-menu">one more popover</Link> massa at accumsan. Etiam purus odio, posuere in ligula vitae, viverra ultricies justo. Vestibulum nec interdum nisi. Aenean ac consectetur velit, non malesuada magna. Sed pharetra vehicula augue, vel venenatis lectus gravida eget. Curabitur lacus tellus, venenatis eu arcu in, interdum auctor nunc. Nunc non metus neque. Suspendisse viverra lectus sed risus aliquet, vel accumsan dolor feugiat.</p>
  12. </Block>
  13. <Popover class="popover-menu">
  14. <List>
  15. <ListItem link="#" popoverClose title="Dialog" />
  16. <ListItem link="#" popoverClose title="Tabs" />
  17. <ListItem link="#" popoverClose title="Side Panels" />
  18. <ListItem link="#" popoverClose title="List View" />
  19. <ListItem link="#" popoverClose title="Form Inputs" />
  20. </List>
  21. </Popover>
  22. </Page>
  23. <script>
  24. import {Page, Navbar, Toolbar, Link, Block, Button, Popover, List, ListItem} from 'framework7-svelte';
  25. </script>

← Photo Browser

Popup →