Photo Browser Svelte Component
- Photo Browser Component
- Photo Browser Properties
- Photo Browser Events
- Photo Browser Methods
- Access To Photo Browser Instance
- Examples
Photo Browser is an photo browser component to display collection of photos / images. Photos can be zoomed and panned (optional).
Photo Browser Svelte component represents Framework7's Photo Browser component.
Photo Browser Svelte component doesn't render any output. It can be used to create JS Photo Browser instance and control it inside of your Svelte component.
Photo Browser Component
There are following components included:
PhotoBrowser
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:
Prop | Type | Default | Description |
---|---|---|---|
<PhotoBrowser> properties | |||
init | boolean | true | Initializes Photo Browser |
params | Object | Object with Photo Browser parameters | |
photos | array | [] | Array with URLs of photos or array of objects with "url" (or "html") and "caption" properties. |
url | string | photos/ | Photo browser modal URL that will be set as a current route |
routableModals | boolean | false | Will 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 |
swiper | object | Object with Swiper parameters. By default equals to:
| |
virtualSlides | boolean | true | When enabled then Swiper will use Virtual Slides |
exposition | boolean | true | Enable disable exposition mode when clicking on Photo Browser. |
expositionHideCaptions | boolean | false | Set to true if you also want to hide captions in exposition mode |
swipeToClose | boolean | true | You can close Photo Browser with swipe up/down when this parameter is enabled |
type | string | standalone | Define 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). |
theme | string | light | Photo Browser color theme, could be light or dark |
captionsTheme | string | Captions color theme, could be also dark or light . By default, equal to "theme" parameter | |
navbar | boolean | true | Set to false to remove Photo Browser's Navbar |
toolbar | boolean | true | Set to false to remove Photo Browser's Toolbar |
pageBackLinkText | string | Back | Text on back link in Photo Browser's navbar |
popupCloseLinkText | string | Close | Text on close link in Photo Browser's navbar when opened in Popup or as Standalone |
navbarShowCount | boolean | undefined | Defines should it display "3 of 5" text in navbar title or not. If not specified (undefined) then it will show this text if there is more than 1 item |
navbarOfText | string | of | Text of "of" in photos counter: "3 of 5" |
iconsColor | string | One of the default colors |
Photo Browser Events
Event | Description |
---|---|
<PhotoBrowser> events | |
photoBrowserOpen | Event will be triggered on Photo Browser open. |
photoBrowserOpened | Event will be triggered after Photo Browser completes its opening animation |
photoBrowserClose | Event will be triggered on Photo Browser close. |
photoBrowserClosed | Event will be triggered after Photo Browser completes its closing animation |
photoBrowserSwipeToClose | This 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 bind:this):
<PhotoBrowser> 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 calling .instance()
component's method. For example:
<PhotoBrowser bind:this={component}>...</PhotoBrowser>
<script>
let component;
// to get instance in some method
component.instance()
</script>
Examples
<Page>
<Navbar title="Photo Browser" />
<Block strong>
<p>Photo Browser could be opened in a three ways - as a Standalone component (Popup modification), in Popup, and as separate Page:</p>
<p>
<PhotoBrowser photos={photos} bind:this={standalone} />
<Button fill raised onClick={() => standalone.open()}>Standalone</Button>
</p>
<p>
<PhotoBrowser photos={photos} type="popup" bind:this={popup} />
<Button fill raised onClick={() => popup.open()}>Popup</Button>
</p>
<p>
<PhotoBrowser photos={photos} type="page" pageBackLinkText="Back" bind:this={page} />
<Button fill raised onClick={() => page.open()}>Page</Button>
</p>
</Block>
<Block strong>
<p>Photo Browser supports 2 default themes - default Light (like in previous examples) and Dark theme. Here is a Dark theme examples:</p>
<p>
<PhotoBrowser photos={photos} theme="dark" bind:this={standaloneDark} />
<Button fill raised onClick={() => standaloneDark.open()}>Standalone</Button>
</p>
<p>
<PhotoBrowser photos={photos} theme="dark" type="popup" bind:this={popupDark} />
<Button fill raised onClick={() => popupDark.open()}>Popup</Button>
</p>
<p>
<PhotoBrowser photos={photos} theme="dark" type="page" pageBackLinkText="Back" bind:this={pageDark} />
<Button fill raised onClick={() => pageDark.open()}>Page</Button>
</p>
</Block>
</Page>
<script>
import {Page, Navbar, Block, Row, Col, PhotoBrowser, Button} from 'framework7-svelte';
let standalone;
let popup;
let page;
let standaloneDark;
let popupDark;
let pageDark;
let photos = [
'https://placekitten.com/800/800',
'https://placekitten.com/1024/1024',
];
</script>