Socket
Socket
Sign inDemoInstall

vue-image-lightbox

Package Overview
Dependencies
4
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-image-lightbox

A Vue.js package to display an image gallery lightbox


Version published
Weekly downloads
4K
decreased by-3.85%
Maintainers
2
Install size
1.34 MB
Created
Weekly downloads
 

Readme

Source

vue-image-lightbox

A simple image/video lightbox component for Vuejs NPM Package

I use CSS style from react-images

Demo!

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)

import Vue from 'vue'
import VueLazyLoad from 'vue-lazyload'
...
Vue.use(VueLazyLoad)

and use the lightbox:

import LightBox from 'vue-image-lightbox'

export default {
  components: {
    LightBox,
  },
}
Browser global
<script src="path/to/vue.js"></script>
<script src="path/to/dist/vue-image-lightbox.js"></script>

Usage

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

Import CSS style

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

How to use:

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

media has the structure:

[
  { // 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
    autoplay: true //Optional to autoplay video when lightbox opens
  }
]

Options

Properties

nametypedefaultdescription
mediaArrayrequiredMedia array to display
showLightBoxBooleantrueWhether to show lightbox or not at the beginning
startAtNumber0Index of the image that you want to start at
nThumbsNumber7Number of thumbnail images
showThumbsBooleantrueWhether to show thumbnails or not
autoPlayBooleanfalseMove to next image automatically
autoPlayTimeNumber3000 (ms)Time to stop at an image before move on to next image
siteLoadingStringdefault image when your image is error or loading
showCaptionBooleanfalseWhether to show caption or not
disableScrollBooleantrueset to `true` to avoid scrolling views behind lightbox
lengthToLoadMoreNumber0Minimum length unto end to emit load more event
closableBooleantrueDisplay the close button at the right top corner or not. ESC clicking-close will also be disabled if closable is set to false.
closeTextStringClose (Esc)Text for the close button
previousTextStringPreviousText for the previous image button
nextTextStringNextText for the next image button
previousThumbTextStringPreviousText for the previous thumb image button
nextThumbTextStringNextText for the next thumb image button
showFooterCountBooleantrueShow footer count

Methods

nameargumentsdescription
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.

The content of the footer under the image.

slot-scopes
nametypedescription
currentintegerNumber of the current image displayed
totalintegerNumbers 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

Contributors:

Keywords

FAQs

Last updated on 05 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc