0.0.5 • Published 6 years ago

vue-simple-lightbox-omer v0.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

vue-simple-lightbox

A Vue.js component for touch-friendly image lightbox for mobile and desktop powered by Simple Lighbox

LIVE DEMO


Install

// For Vue.js 2.0+
npm install vue-simple-lightbox

Usage

  1. Import the module
  2. Register it as a component as you would any other Vue component
  3. Use it within your template

Example

<template>
  <div id="app">
    <p>Welcome to your Vue.js lightbox!</p>

    <lightbox
      id="mylightbox"
      :images="images"
      :image_class=" 'img-responsive img-rounded' "
      :album_class=" 'my-album-class' "
      :options="options">
    </lightbox>

  </div>
</template>

<script>
  import Lightbox from 'vue-simple-lightbox'

  export default {
    components: {
      Lightbox
    },
    data(){
        return{
          images : [
            {
                src : 'https://cdn.rawgit.com/vrajroham/vrajroham.github.io/85d64ac5/imgs/img1.jpg',
                title : 'Image 2'
            },
            {
                src : 'https://cdn.rawgit.com/vrajroham/vrajroham.github.io/85d64ac5/imgs/img2.jpg',
                title : 'Image 3'
            },
            {
                src : 'https://cdn.rawgit.com/vrajroham/vrajroham.github.io/85d64ac5/imgs/img3.jpg',
                title : ''
            },
            {
                src : 'https://cdn.rawgit.com/vrajroham/vrajroham.github.io/85d64ac5/imgs/img4.jpg',
                title : ''
            },
          ],
          options : {
            closeText : 'X'
          }
        }
      }
  }
</script>

Props

Many of these props are inherited from simplelightbox configuration so see their docs for further details.

Prop NameTypeDescription
idStringA string by which to identify the component, can be anything. Required
imagesArrayArray containing (src,title) Required
image_classStringClass for each image
album_classStringClass for album. i.e. Group of images (current lightbox)
optionsObjectOptions for lightbox (refer following table)

Options

PropertyDefaultTypeDescription
sourceAttrhrefstringthe attribute used for large images
overlaytrueboolshow an overlay or not
spinnertrueboolshow spinner or not
navtrueboolshow arrow-navigation or not
navText'',''arraytext or html for the navigation arrows
captionstrueboolshow captions if availabled or not
captionSelector'img'stringset the element where the caption is. Set it to "self" for the A-Tag itself
captionType'attr'stringhow to get the caption. You can choose between attr, data or text
captionsDatatitlestringget the caption from given attribute
captionPosition'bottom'stringthe position of the caption. Options are top, bottom or outside (note that outside can be outside the visible viewport!)
captionDelay0intadds a delay before the caption shows (in ms)
closetrueboolshow the close button or not
closeText'×'stringtext or html for the close button
swipeClosetrueboolswipe up or down to close gallery
showCountertrueboolshow current image index or not
fileExt'png|jpg|jpeg|gif'regexp or falselist of fileextensions the plugin works with or false for disable the check
animationSpeed250inthow long takes the slide animation
animationSlidetrueboolweather to slide in new photos or not, disable to fade
preloadingtrueboolallows preloading next und previous images
enableKeyboardtrueboolallow keyboard arrow navigation and close with ESC key
looptrueboolenables looping through images
relfalsemixedgroup images by rel attribute of link with same selector.
docClosetrueboolcloses the lightbox when clicking outside
swipeTolerance50inthow much pixel you have to swipe, until next or previous image
className:'simple-lightbox'stringadds a class to the wrapper of the lightbox
widthRatio:0.8floatRatio of image width to screen width
heightRatio:0.9floatRatio of image height to screen height
disableRightClickfalsebooldisable rightclick on image or not
disableScrolltrueboolstop scrolling page if lightbox is opened
alertErrortrueboolshow an alert, if image was not found. If false error will be ignored
alertErrorMessage'Image not found, next image will be loaded'stringthe message displayed if image was not found
additionalHtmlfalsestringAdditional HTML showing inside every image. Usefull for watermark etc. If false nothing is added
historytrueboolenable history back closes lightbox instead of reloading the page

Development

# install dependencies
npm install

# serve example at localhost:8080
npm run dev

# build any changes made
npm run build