You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vue-lightbox-lite

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-lightbox-lite

A lightweight image and video lightbox gallery component for Vue

1.2.3
latest
Source
npmnpm
Version published
Weekly downloads
66
-19.51%
Maintainers
1
Weekly downloads
 
Created
Source

vue-lightbox-lite

A lightweight image, video and iframe lightbox gallery component for Vue. Supports slide, zoom, rotation, autoplay, captions and so on, based on Vue-cool-lightbox.

轻量级的图片/视频 预览器,支持自动播放、旋转、缩放、全屏、键盘及手势滑动切换等。

default screenshot

light screenshot

Features

  • No external dependencies.
  • Fully responsive.
  • autoplay slides that play or pause
  • Full screen support.
  • Multiple zoom levels.
  • Rotate images.
  • YouTube Vimeo and html5 videos Support.
  • Keyboard Navigation for desktop.
  • And many more.

Installation

npm install vue-lightbox-lite

# 或

yarn add vue-lightbox-lite

Usage

1. Global import

In main.js:

// main.js
import Lightbox from 'vue-lightbox-lite'
import 'vue-lightbox-lite/dist/index.css'

Vue.use(Lightbox)

In component.vue

<template>
<div class="lightbox">
  <ul class="list">
    <li v-for="(item, key) in list" :key="key" @click="index = key">link - {{ key }}</li>
  </ul>

  <LightBox
    :index="index"
    :items="list"
  />
</div>
</template>

<script>
export default {
  data() {
    return {
      index: null,
      list: [
        'http://www.domain.com/image.jpg',
        'http://www.domain.com/video.mp4',
        {
          src: 'http://www.domain.com/playgame/',
          mediaType: 'video',
          ext: 'webm',
          title: '',
          description: ''
        },
        'https://www.youtube.com/watch?v=d0tU18Ybcvk',
        {
          src: 'https://www.youtube.com/watch?v=d0tU18Ybcvk',
          mediaType: 'webVideo'
        },
        {
          src: 'http://www.domain.com/file.pdf',
          mediaType: 'iframe'
        }
      ]
    }
  }
}
</script>

2. In Component

<template>
<div class="lightbox">
  <button @click="index = 0">preview</button>

  <Viewer
    :index="index"
    :items="list"
  />
</div>
</template>

<script>
import VueLightbox from 'vue-lightbox-lite'
import 'vue-lightbox-lite/dist/index.css'

export default {
  component: {
    Viewer: VueLightbox
  },
  data() {
    return {
      index: null,
      list: [
        'http://www.domain.com/image.jpg',
        'http://www.domain.com/video.mp4',
        'http://www.domain.com/file.pdf'
      ]
    }
  }
}
</script>

API

Items attributes

NameTypeDefaultDescription
srcStringUrl of the image/video/iframe
mediaTypeStringimagemedia type, image, video, webVideo, iframe
extStringe.g. mp4, ogg, webm, pdf
thumbString
altString
srcsetString
sizesString
titleString
descriptionString
widthString|NumberautoControl width, video & iframe
heightString|Numberauto
maxWidthString|Numberauto
maxHeightString|Numberauto

props

NameTypeDefaultDescription
indexNumbernullIndex of items to open
itemsArray<Object | String>Array of images/videos
containerElement | Stringdocument.body
themeStringdarkdarklight
customClassString
zIndexNumber9999
highColorString#fa4242progressbar color and thumbnails border-color
overlayColorString
navigatorBooleantrue
toolbarArraytoolbar: counter, zoom, slide, rotate, gallery, fullscreen, download, close
loopBooleantrue
slideDurationNumber3500
showGalleryBooleanfalse
galleryPositionStringrightbottom
videoObject{autoplay: false, raito: 16/9}video parameter,autoplay, width,height,maxWidth,maxHeight
iframeObjectwidth,height,maxWidth,maxHeight
enableWheelEventBooleanfalse
enableScrollLockBooleantrue
clickOutsideHideBooleantrue

Slots

  • loading
  • icon-previous
  • icon-next

Events

  • open(index: number)
  • close
  • change(index: number)
  • change-end(index: number)

Methods

  • open(index)
  • close()
  • previous()
  • next()
  • change(index)

Keywords

vue

FAQs

Package last updated on 08 Aug 2023

Did you know?

Socket

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