Socket
Socket
Sign inDemoInstall

vue-cool-lightbox

Package Overview
Dependencies
10
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vue-cool-lightbox

A pretty Vue.js component to display an image gallery lightbox inspired by fancybox


Version published
Maintainers
1
Install size
20.6 MB
Created

Readme

Source

Vue-cool-lightbox

Vue-cool-lightbox is a pretty Vue.js lightbox component without any dependencies, inspired by fancybox with zoom, swipe, captions and videos supported.

Vue CoolLightbox screenshot

Installation

Use node package manager to install vue-cool-lightbox.

npm install --save vue-cool-lightbox

and use the lightbox:

import CoolLightBox from 'vue-cool-lightbox'
import 'vue-cool-lightbox/dist/vue-cool-lightbox.min.css'

export default {
  components: {
    CoolLightBox,
  },
}

Examples

You can see the full documentation here: https://vue-cool-lightbox.lucaspulliese.com/.

Usage

<template>
  <div id="app">
    <CoolLightBox 
      :items="items" 
      :index="index"
      loop
      @close="index = null">
    </CoolLightBox>

    <div class="images-wrapper">
      <div
        class="image"
        v-for="(image, imageIndex) in items"
        :key="imageIndex"
        @click="setIndex(imageIndex)"
        :style="{ backgroundImage: 'url(' + image.src + ')' }"
      ></div>
    </div>
  </div>
</template>

<script>
import CoolLightBox from 'vue-cool-lightbox'

export default {
  name: "app",
  data: function () {
    return {
      items: [
        {
          src: 'https://cosmos-images2.imgix.net/file/spina/photo/20565/
          191010_nature.jpg?ixlib=rails-2.1.4&auto=format&ch=Width%2CDPR&fit=max&w=835',
        },
        {
          src: 'https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/
          images/nature-quotes-1557340276.jpg?crop=0.666xw:1.00xh;0.168xw,0&resize=640:*',
        },
      ],
      index: null
    };
  },
  components: {
    CoolLightBox
  },
  methods: {
    setIndex(index) {
      this.index = index
    }
  }
};
</script>

Or items can be just an array:

items: [
  'http://example.com/image.jpg',
  'youtube.com',
  'vimeo.com',
  'mp4',
]

Items Supported attributes

AttributerequiredtypeDescription
srcyesstringmedia source, it can be an image or a Youtube / Vimeo / Mp4 video
titlenostringthe image title
descriptionnostringthe image description
thumbnostringthumb url used in thumbs block
mediaTypenostringdefines media type

Props Supported

AttributetypeDescriptionDefault
itemsArrayArray of images/videos
indexNumberIndex of items to open
effectStringEffect on slide, could be swipe or fadeswipe
fullScreenBooleanAllow users to fullscreen modefalse
loopBooleanEnables looping through itemstrue
slideshowBooleanEnables lighbox slideshowtrue
slideshowColorBarStringColor of the slideshow progress bar#fa4242
slideshowDurationNumberDuration of slides when slideshow is running (in ms)3000
srcNameStringName of the prop to use as image/video urlsrc
srcThumbStringName of the prop to use as image/video thumbthumb
overlayColorStringOverlay colorrgba(30, 30, 30, .9)
zIndexNumber.cool-lightbox z-index9999
galleryBooleanEnable/disable gallerytrue
thumbsPositionStringDefines thumbs position, could be right or bottom'right'
youtubeCookiesBooleanif is setted to false it will use https://www.youtube-nocookie.com/embed/YOUTUBE_ID for youtube videostrue
useZoomBarBooleanenables a zoom bar similar with the zoom as in Slackfalse
enableWheelEventBooleanenables change slides on mouse wheel eventsfalse
closeOnClickOutsideMobileBooleanenables close lightbox when the user clicks outside the image/video/iframe on mobile devicesfalse
srcMediaTypeStringmedia type src for each item'mediaType'
showCloseButtonBooleanshow or hide close buttontrue
disableZoomBooleandisable lightbox zoomfalse

Slots Supported

NameDescription
icon-previousPrevious icon
icon-nextNext icon
closeClose icon
loadingLoading animation

Events Supported

NameAttributesListen toDescription
OnChange(indexItem)@on-changeEmitted when the lightbox changes the item index
OnOpen(indexItem)@on-openEmitted when the lightbox is opened
Close(indexItem)@closeEmitted when the lightbox is closed

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Keywords

FAQs

Last updated on 24 Aug 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