8.0.4 • Published 4 years ago

vue-image-lightbox-evolved v8.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

vue-image-lightbox-evolved

npm Build Status Depfu

A simple image / video lightbox component for Vue.js. Based on vue-image-lightbox.

Vue Image Lightbox Evolved Screenshot

Click on the screenshot above for a demo.

Installation

NPM / Yarn

Install the package:

npm install vue-image-lightbox-evolved
yarn add vue-image-lightbox-evolved

Then import it in your project at your entry point (main.js normally)

import Vue from 'vue'

and use the lightbox:

import LightBox from 'vue-image-lightbox-evolved'

export default {
  components: {
    LightBox,
  },
}

Browser global

<script src="path/to/vue.js"></script>
<script src="path/to/dist/vue-image-lightbox-evolved.js"></script>

Usage

You can simply view App.vue to see how to use vue-image-lightbox-evolved

Import CSS style

require('vue-image-lightbox-evolved/dist/vue-image-lightbox-evolved.min.css')
// Use only when you are using Webpack

How to use:

<LightBox :media="media"></LightBox>

Structure of the media prop:

[
  { // For image
    thumb: 'http://example.com/thumb.jpg',
    src: 'http://example.com/image.jpg',
    caption: 'caption to display. receive <html> <b>tag</b>', // 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: '<h4>Monsters Inc.</h4>',
    width: 800, // required
    height: 600, // required
  }
]

Options

Properties

Methods

Slots

close

The content of the close button.

footer

The content of the footer under the image.

slot-scopes

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(value): true to emit when the lightbox is opened and false when it 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.

Development (NPM / Yarn)

Clone the repository, cd into it and run:

npm run dev
yarn dev

Credits

Most of the CSS belongs to react-images

Contributors:

Original author: @pexea12. Other contributors: check out the contributors graph.