Panel / Side Panels - 图1

Panel Svelte Component

Panel Svelte component represents Side Panels component.

Panel Components

There are following components included:

  • Panel - Panel element

Panel Properties

PropTypeDefaultDescription
sidestringPanel side. Could be left or right
leftbooleanShortcut prop for side=”left”
rightbooleanShortcut prop for side=”right”
effectstringPanel effect. Could be cover or reveal
coverbooleanShortcut prop for effect=”cover”
revealbooleanShortcut prop for effect=”reveal”
visibleBreakpointnumberMinimal app width (in px) when left panel becomes always visible
collapsedBreakpointnumberMinimal app width (in px) when left panel becomes partially visible (collapsed)
swipebooleanfalseEnable if you want to enable ability to open/close panel with swipe
swipeNoFollowbooleanfalseFallback option for potentially better performance on old/slow devices. If you enable it, then swipe panel will not follow your finger during touch move, it will be automatically opened/closed on swipe left/right.
swipeActiveAreanumber0Width (in px) of invisible edge from the screen that triggers panel swipe
swipeOnlyClosebooleanfalseThis parameter allows to close (but not open) panel with swipes. (swipe should be also enabled)
swipeThresholdnumber0Panel will not move with swipe if “touch distance” will be less than this value (in px).
backdropbooleantrueEnables Panel backdrop (dark semi transparent layer behind)
backdropElHTMLElement
string
HTML element or string CSS selector of custom backdrop element
closeByBackdropClickbooleantrueEnable/disable ability to close panel by clicking outside of panel
resizablebooleanfalseEnables/disables resizable panel
openedbooleanAllows to open/close panel and set its initial state

Panel Methods

.open(animate)Open panel
.close(animate)Close panel

Panel Events

EventDescription
panelOpenEvent will be triggered when Panel starts its opening animation
panelOpenedEvent will be triggered after Panel completes its opening animation
panelCloseEvent will be triggered when Panel starts its closing animation
panelClosedEvent will be triggered after Panel completes its closing animation
panelBackdropClickEvent will be triggered when the panel backdrop is clicked
panelSwipeEvent will be triggered for swipe panels during touch swipe action
panelSwipeOpenEvent will be triggered in the very beginning of opening it with swipe
panelCollapsedBreakpointEvent will be triggered when it becomes visible/hidden when app width matches its collapsedBreakpoint
panelBreakpointEvent will be triggered when it becomes visible/hidden when app width matches its visibleBreakpoint

Open And Close Panel

You can control panel state, open and closing it:

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

Access To Panel Instance

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

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

Examples

  1. <App>
  2. <Panel resizable left reveal>
  3. <View>
  4. <Page>
  5. <Block>Left panel content</Block>
  6. </Page>
  7. </View>
  8. </Panel>
  9. <Panel resizable right themeDark>
  10. <View>
  11. <Page>
  12. <Block>Right panel content</Block>
  13. </Page>
  14. </View>
  15. </Panel>
  16. <View main>
  17. <Page>
  18. <Navbar title="Panel"></Navbar>
  19. <Block class="row">
  20. <Col>
  21. <Button raised fill panelOpen="left">Open left panel</Button>
  22. </Col>
  23. <Col>
  24. <Button raised fill panelOpen="right">Open right panel</Button>
  25. </Col>
  26. </Block>
  27. </Page>
  28. </View>
  29. </App>
  30. <style>
  31. /* Limit resizable panel width */
  32. :global(.panel) {
  33. min-width: 100px;
  34. max-width: 90vw;
  35. }
  36. </style>
  37. <script>
  38. import {App, Panel, View, Page, Block, Navbar, Col, Button} from 'framework7-svelte';
  39. </script>

← Page

Photo Browser →