Photo Browser - 图1

Photo Browser Vue Component

Photo Browser is an photo browser component to display collection of photos / images. Photos can be zoomed and panned (optional).

Photo Browser Vue component represents Framework7’s Photo Browser component.

Photo Browser Vue component doesn’t render any output. It can be used to create JS Photo Browser instance and control it inside of your Vue component.

Photo Browser Component

There are following components included:

  • **f7-photo-browser**

Photo Browser Properties

You can pass all parameters in single params property or use separate props for each parameter to specify them via component properties:

PropTypeDefaultDescription
<f7-photo-browser> properties
initbooleantrueInitializes Photo Browser
paramsObjectObject with Photo Browser parameters
photosarray[]Array with URLs of photos or array of objects with “url” (or “html”) and “caption” properties.
urlstringphotos/Photo browser modal URL that will be set as a current route
routable-modalsbooleantrueWill add opened photo browser to router history which gives ability to close photo browser by going back in router history and set current route to the photo browser modal
swiperobjectObject with Swiper parameters. By default equals to:
  1. swiper: {
  2. initialSlide: 0,
  3. spaceBetween: 20,
  4. speed: 300,
  5. loop: false,
  6. preloadImages: true,
  7. navigation: {
  8. nextEl: ‘.photo-browser-next’,
  9. prevEl: ‘.photo-browser-prev’,
  10. },
  11. zoom: {
  12. enabled: true,
  13. maxRatio: 3,
  14. minRatio: 1,
  15. },
  16. lazy: {
  17. enabled: true,
  18. },
  19. },
virtualSlidesbooleantrueWhen enabled then Swiper will use Virtual Slides
expositionbooleantrueEnable disable exposition mode when clicking on Photo Browser.
exposition-hide-captionsbooleanfalseSet to true if you also want to hide captions in exposition mode
swipe-to-closebooleantrueYou can close Photo Browser with swipe up/down when this parameter is enabled
typestringstandaloneDefine how Photo Browser should be opened. Could be standalone (will be opened as an overlay with custom transition effect), popup (will be opened as popup), page (will be injected to View and loaded as a new page).
themestringlightPhoto Browser color theme, could be light or dark
captions-themestringCaptions color theme, could be also dark or light. By default, equal to “theme” parameter
navbarbooleantrueSet to false to remove Photo Browser’s Navbar
toolbarbooleantrueSet to false to remove Photo Browser’s Toolbar
back-link-textstringCloseText on back link in Photo Browser’s Navbar
navbar-of-textstringofText of “of” in photos counter: “3 of 5”
icons-colorstringOne of the default colors

Photo Browser Events

EventDescription
<f7-photo-browser> events
photobrowser:openEvent will be triggered on Photo Browser open.
photobrowser:openedEvent will be triggered after Photo Browser completes its opening animation
photobrowser:closeEvent will be triggered on Photo Browser close.
photobrowser:closedEvent will be triggered after Photo Browser completes its closing animation
photobrowser:swipetocloseThis event will be triggered when user close Photo Browser with swipe up/down.

Photo Browser Methods

The following Photo Browser components methods are available (e.g. by accesing it via $refs):

<f7-photo-browser> methods
.open(index);Open Photo Browser on photo with index number equal to “index” parameter. If “index” parameter is not specified, it will be opened on last closed photo.
.close();Close Photo Browser
.expositionToggle();Toggle exposition mode
.expositionEnable();Enable exposition mode
.expositionDisable();Disable exposition mode

Access To Photo Browser Instance

You can access Photo Browser initialized instance by accessing **.f7PhotoBrowser** component’s property.

Examples

  1. <template>
  2. <f7-page>
  3. <f7-navbar title="Photo Browser"></f7-navbar>
  4. <f7-block>
  5. <p>Photo Browser could be opened in a three ways - as a Standalone component (Popup modification), in Popup, and as separate Page:</p>
  6. <f7-row>
  7. <f7-col>
  8. <f7-photo-browser
  9. :photos="photos"
  10. ref="standalone"
  11. ></f7-photo-browser>
  12. <f7-button raised @click="$refs.standalone.open()">Standalone</f7-button>
  13. </f7-col>
  14. <f7-col>
  15. <f7-photo-browser
  16. :photos="photos"
  17. type="popup"
  18. ref="popup"
  19. ></f7-photo-browser>
  20. <f7-button raised @click="$refs.popup.open()">Popup</f7-button>
  21. </f7-col>
  22. <f7-col>
  23. <f7-photo-browser
  24. :photos="photos"
  25. type="page"
  26. back-link-text="Back"
  27. ref="page"
  28. ></f7-photo-browser>
  29. <f7-button raised @click="$refs.page.open()">Page</f7-button>
  30. </f7-col>
  31. </f7-row>
  32. </f7-block>
  33. <f7-block>
  34. <p>Photo Browser suppots 2 default themes - default Light (like in previous examples) and Dark theme. Here is a Dark theme examples:</p>
  35. <f7-row>
  36. <f7-col>
  37. <f7-photo-browser
  38. :photos="photos"
  39. theme="dark"
  40. ref="standaloneDark"
  41. ></f7-photo-browser>
  42. <f7-button raised @click="$refs.standaloneDark.open()">Standalone</f7-button>
  43. </f7-col>
  44. <f7-col>
  45. <f7-photo-browser
  46. :photos="photos"
  47. theme="dark"
  48. type="popup"
  49. ref="popupDark"
  50. ></f7-photo-browser>
  51. <f7-button raised @click="$refs.popupDark.open()">Popup</f7-button>
  52. </f7-col>
  53. <f7-col>
  54. <f7-photo-browser
  55. :photos="photos"
  56. theme="dark"
  57. type="page"
  58. back-link-text="Back"
  59. ref="pageDark"
  60. ></f7-photo-browser>
  61. <f7-button raised @click="$refs.pageDark.open()">Page</f7-button>
  62. </f7-col>
  63. </f7-row>
  64. </f7-block>
  65. </f7-page>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. photos: [
  72. {
  73. url: 'img/beach.jpg',
  74. caption: 'Amazing beach in Goa, India',
  75. },
  76. 'http://placekitten.com/1024/1024',
  77. 'img/lock.jpg',
  78. {
  79. url: 'img/monkey.jpg',
  80. caption: 'I met this monkey in Chinese mountains',
  81. },
  82. {
  83. url: 'img/mountains.jpg',
  84. caption: 'Beautiful mountains in Zhangjiajie, China',
  85. },
  86. ],
  87. };
  88. },
  89. }
  90. </script>