https://github.com/pexea12/vue-image-lightbox
A Vue component to display an image gallery lightbox
https://github.com/pexea12/vue-image-lightbox
image-gallery lightbox vue vue-components vue-image-lightbox
Last synced: 10 months ago
JSON representation
A Vue component to display an image gallery lightbox
- Host: GitHub
- URL: https://github.com/pexea12/vue-image-lightbox
- Owner: pexea12
- Created: 2016-12-06T18:28:25.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-22T13:26:40.000Z (about 2 years ago)
- Last Synced: 2024-09-19T00:29:12.465Z (about 1 year ago)
- Topics: image-gallery, lightbox, vue, vue-components, vue-image-lightbox
- Language: Vue
- Size: 2.38 MB
- Stars: 347
- Watchers: 9
- Forks: 80
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-vue-zh - Vue-图像收藏夹 - Vue图像灯箱/图库,可以很好地显示图像. (UI组件 / 覆盖)
- awesome-vue - vue-image-lightbox - A Vue component to display an image gallery lightbox ` 📝 11 days ago` (UI Components [🔝](#readme))
- awesome-vue - vue-image-lightbox ★117 - A Vue image lightbox/gallery to display images nicely. (UI Components / Overlay)
- awesome-vue - vue-image-lightbox - A Vue image lightbox/gallery to display images nicely. (Components & Libraries / UI Components)
- awesome-vue - vue-image-lightbox - A Vue image lightbox/gallery to display images nicely. (UI Components / Overlay)
README
# vue-image-lightbox
A simple image/video lightbox component for Vuejs
[NPM Package](https://www.npmjs.com/package/vue-image-lightbox)
I use CSS style from [react-images](https://github.com/jossmac/react-images)
[Demo!](http://pexea12.github.io/vue-image-lightbox/)
## Development (NPM / Yarn)
```
npm run dev
yarn dev
```
## Install
#### NPM / Yarn
Install the package:
```
npm install vue-image-lightbox vue-lazyload
yarn add vue-image-lightbox vue-lazyload
```
Then import it in your project
At your entry point (`main.js` normally)
```javascript
import Vue from 'vue'
import VueLazyLoad from 'vue-lazyload'
...
Vue.use(VueLazyLoad)
```
and use the lightbox:
```javascript
import LightBox from 'vue-image-lightbox'
export default {
components: {
LightBox,
},
}
```
#### Browser global
```html
```
## Usage
You can simply view [App.vue](https://github.com/pexea12/vue-image-lightbox/blob/master/src/App.vue) to see how to use **vue-image-lightbox**
Import CSS style
```javascript
require('vue-image-lightbox/dist/vue-image-lightbox.min.css')
// Use only when you are using Webpack
```
How to use:
```html
```
`media` has the structure:
```javascript
[
{ // For image
thumb: 'http://example.com/thumb.jpg',
src: 'http://example.com/image.jpg',
caption: 'caption to display. receive tag', // Optional
srcset: '...' // Optional for displaying responsive images
},
{ // For video
thumb: 'https://s3-us-west-1.amazonaws.com/powr/defaults/image-slider2.jpg',
sources: [
{
src: 'https://www.w3schools.com/html/mov_bbb.mp4',
type: 'video/mp4'
}
],
type: "video",
caption: '
Monsters Inc.
',
width: 800, // required
height: 600, // required
autoplay: true //Optional to autoplay video when lightbox opens
}
]
```
## Options
### Properties
name
type
default
description
media
Array
required
Media array to display
showLightBox
Boolean
true
Whether to show lightbox or not at the beginning
startAt
Number
0
Index of the image that you want to start at
nThumbs
Number
7
Number of thumbnail images
showThumbs
Boolean
true
Whether to show thumbnails or not
autoPlay
Boolean
false
Move to next image automatically
autoPlayTime
Number
3000 (ms)
Time to stop at an image before move on to next image
siteLoading
String
default image when your image is error or loading
showCaption
Boolean
false
Whether to show caption or not
disableScroll
Boolean
true
set to `true` to avoid scrolling views behind lightbox
disableZoom
Boolean
true
set to `true` to avoid zooming lightbox
lengthToLoadMore
Number
0
Minimum length unto end to emit load more event
closable
Boolean
true
Display the close button at the right top corner or not. ESC clicking-close will also be disabled if closable is set to false.
closeText
String
Close (Esc)
Text for the close button
previousText
String
Previous
Text for the previous image button
nextText
String
Next
Text for the next image button
previousThumbText
String
Previous
Text for the previous thumb image button
nextThumbText
String
Next
Text for the next thumb image button
showFooterCount
Boolean
true
Show footer count
### Methods
name
arguments
description
nextImage
()
Move to next image
previousImage
()
Move to previous image
closeLightBox
()
Close lightbox
showImage
(index)
Show the image at index
### Slots
#### close
The content of the close button.
#### footer
The content of the footer under the image.
##### slot-scopes
name
type
description
current
integer
Number of the current image displayed
total
integer
Numbers of the images
#### previous
The previous button on the main image.
#### next
The next button on the main image.
#### previousThumb
The previous button on the thumbs list.
#### nextThumb
The next button on the thumbs list.
#### customCaption
The caption of the current image.
#### videoIcon
The Icon used for videos
### Events
- `onOpened`: emit when the lightbox is opened.
- `onClosed`: emit when the lightbox is closed.
- `onLastIndex`: Emit when the current image is the last one of the list.
- `onFirstIndex`: Emit when the current image is the first one of the list.
- `onStartIndex`: Emit when the current image is at the `startAt` index (specified in the properties).
- `onLoad`: Emit when there are `lengthToLoadMore` images left in the array (specified in the properties). For example, if `lengthToLoadMore = 2` and there are 7 images in your array, when you reach index 4 (which means there are 2 images left which are not discovered yet), this event will be emitted. After that, if the image array are updated and there are totally 15 images, the event will be emitted at index 12.
- `onImageChanged`: Emit when the image is changed.
## CREDITS
Most of the CSS belongs to [react-images](https://github.com/jossmac/react-images)
### Contributors:
- [@imcvampire](https://github.com/imcvampire)
- [@krystalcampioni](https://github.com/krystalcampioni)
- [@jstr14](https://github.com/jstr14)
- [@PedroBatista333](https://github.com/PedroBatista333)
- [@vtalbot](https://github.com/vtalbot)
- [@hasangilak](https://github.com/hasangilak)
- [@neobutter](https://github.com/neobutter)
- [@mudin](https://github.com/mudin)
- [@asterisx](https://github.com/asterisx)
- [@janosrusiczki](https://github.com/janosrusiczki)
janosrusiczki)
janosrusiczki]