A Vue.js 3.0 image lightbox component with Zoom / Drag / Rotate / Switch .

Overview

vue-easy-lightbox

A Vue.js 3.0 image lightbox component with Zoom / Drag / Rotate / Switch .

npm npm npm

English | 中文文档 | Homepage

[email protected] only supports Vue.js 3, if you need Vue.js 2 version please check here.

Installation

Package managers

$ npm install --save vue-easy-lightbox@next
# OR
$ yarn add vue-easy-lightbox@next

Direct Download

Include the CDN link in the html file.

<script src="https://unpkg.com/vue@next">script>
<script src="https://unpkg.com/vue-easy-lightbox@next/dist/vue-easy-lightbox.umd.min.js">script>

Different Builds

ES5 build is converted by Babel. If you don't need to support an es5 environment, you can choose a nonES5 build with smaller size.

ES5(default in package.json) ES6
UMD(for browsers) vue-easy-lightbox.es5.umd.min.js vue-easy-lightbox.umd.min.js
CommonJS vue-easy-lightbox.es5.common.min.js (pkg.main) vue-easy-lightbox.common.min.js
ES Module(for bundlers) vue-easy-lightbox.es5.esm.min.js (pkg.module) vue-easy-lightbox.esm.min.js

Usage

Direct
Comments
  • CSP Violation

    CSP Violation

    Снимок экрана 2021-08-02 в 15 20 44 Снимок экрана 2021-08-02 в 15 23 03

    This package is inlining css, which violates my CSP rules (default-src 'self'). I know I can enable unsafe-inline but this is unsafe and kinda defeats the purpose.

    Is it possible to bundle this package in some other way?

    opened by sheremet-va 9
  • Toolbar Methods

    Toolbar Methods

    Hi, in the documentation regarding custom toolbar you mention:

    <template v-slot:toolbar="{ toolbarMethods }">
        <button @click="toolbarMethods.zoomIn">zoom in</button>
        <button @click="toolbarMethods.zoomOut">zoom out</button>
        <button @click="toolbarMethods.rotateLeft">Anticlockwise rotation</button>
        <button @click="toolbarMethods.rotateRight">clockwise rotation</button>
      </template>
    
    

    The question that I'm having is, where should the toolbarMethods come from? Can I import the default implementation somehow, and just configure the visuals? Can you provide an example of how this should be used?

    opened by Drabuna 7
  • TODO

    TODO

    • [x] Custom toolbar/btns/ options #5
    • [x] Description text #9
    • [x] Rewrite class name
    • [ ] New document ( vuePress ?)
    • [x] Mobile support #4
    • [x] Minimize bundle size #12
    • [x] Provide es5 / es6+ #12
    • [x] Img loading.
    • [x] escape pressing
    • [x] TypeScript support
    • [x] Rewrite to TypeScript
    • [x] Minize TypeScript build size (with babel)
    • [ ] Customize Styles support
    • [x] Error handler
    • [ ] Refactor with tsx
    • [x] btn click event & index change event
    opened by XiongAmao 7
  • RTL not work correctly

    RTL not work correctly

    Hi, I'm using this package with vue3 but I have a problem with something. When I click on the previous icon, the next image is displayed to me and vice versa. This also happens for the key left and key right.

    opened by sajjad5221 6
  • Lightbox is not Working with Bootstrap

    Lightbox is not Working with Bootstrap

    I'm not sure why it's not working with Bootstrap.

    When I remove import ('Bootstrap.css) its working fine while my custom stylesheet still there.

    Any help would be much appreciated

    Thanks

    opened by MuhaddiMu 6
  • Direct script Include error - Failed to mount app: mount target selector

    Direct script Include error - Failed to mount app: mount target selector "#root" returned null.

    I paste the in script example in a html file (see below code), but it returns the error: Failed to mount app: mount target selector "#root" returned null.

    So I guess I should create a #root element in the DOM, and add <div id="root"></div> in the html, but it return another error: Uncaught TypeError: dataOptions.call is not a function

    Could you help! Thanks.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <!-- in html -->
        <div id="root"></div>
    <div id="app">
        <div class="">
          <div
            v-for="(src, index) in imgs"
            :key="index"
            class="pic"
            @click="() => showImg(index)"
          >
            <img :src="src" />
          </div>
        </div>
        <vue-easy-lightbox
          :visible="visible"
          :imgs="imgs"
          :index="index"
          @hide="handleHide"
        ></vue-easy-lightbox>
      </div>
      
      <script src="https://unpkg.com/vue@next"></script>
      <script src="https://unpkg.com/vue-easy-lightbox@next/dist/vue-easy-lightbox.umd.min.js"></script>
      <script>
        // Note: The Global Vue Constructor is no longer available in Vue 3.0.
        // https://v3.vuejs.org/guide/migration/global-api.html#a-new-global-api-createapp
        var app = Vue.createApp({
          el: '#app',
          data: {
            visible: false,
            index: 0, // default: 0
            imgs: [
              'https://via.placeholder.com/450.png/',
              'https://via.placeholder.com/300.png/',
              'https://via.placeholder.com/150.png/',
              { src: 'https://via.placeholder.com/450.png/', title: 'this is title' }
            ]
          },
          methods: {
            showImg(index) {
              this.index = index
              this.visible = true
            },
            handleHide() {
              this.visible = false
            }
          }
        })
        // Registering VueEasyLightbox for your VueApp.
        app.use(VueEasyLightbox)
          
        app.mount('#root')
      </script>
    </body>
    </html>
    
    opened by liangwuweb 4
  • Feat: Add swipe support, option to disable scrolling and loop next/previous

    Feat: Add swipe support, option to disable scrolling and loop next/previous

    Feature request: Support swipe #63

    Here are some new features I added to my fork:

    • Add ability to swipe left/right on desktop and mobile
    • Add option to disable scrolling when modal is visible
    • Allow user to navigate from beginning to end and vice versa
    • Rename the on-prev-click/on-next-click events to on-prev/on-next

    Remaining work:

    • Update changelog with new features/properties
    • Bump minor version since the events were renamed
    • Update docs and other language READMEs

    Any feedback?

    opened by kevinsimard 4
  • How to show images in center of screen?

    How to show images in center of screen?

    I have many images in block When I click one of images, an image doesn't shows in center of screen I need an image to be sxactly in center of screen vertically even If I scroll page to bottom and clikc on last image. How to show images in center of screen? Is there something that I can change with CSS?

    <div class="works">
          <div
            class="image"
            v-for="(image, index) in images"
            :key="index"
            @click="showSingleImage(index)"
          >
            <img :src="image" :alt="index"/>
          </div>
        </div>
        <client-only>
          <vue-easy-lightbox
            :visible="visible"
            :index="index"
            :imgs="images"
            @hide="visible = false"
          />
        </client-only>
    

    Video

    opened by kentforth 4
  • The picture is blurry.

    The picture is blurry.

    image

    The top image is an easy-lightbox image. The image below is when the same picture is opened directly This is the image you see. Why does the image in the lightbox look blurry? All sizes are 100%.

    opened by k3341095 4
  • How can I handle onerror Img?

    How can I handle onerror Img?

    I got Img from Api but I don't know the Img can correct show or can't.

    How can I handle onerror Img ?

    The issue like this : https://imgur.com/a/195ETZp


    Thx EveryOne.

    feature request 
    opened by RexHung0302 4
  • overflow-y of body is not removed on lightbox close

    overflow-y of body is not removed on lightbox close

    I'm using the version for Vue2. When closing the lightbox via ESC, close button or mask the body element stil has overflow-y: hidden set.

    Currently I'm using a workaround to fix this. Also index isn't reactive. I have to use @on-index-change to update current index variable.

    <template>
        <vue-easy-lightbox
            moveDisabled
            scrollDisabled
            :visible="show"
            :imgs="images"
            :index="currentIndex"
            @on-index-change="onIndexChange"
            @on-error="close"
            @hide="close"
        >
            <template #toolbar>
                <span></span>
            </template>
        </vue-easy-lightbox>
    <template>
    
    <script>
    import VueEasyLightbox from 'vue-easy-lightbox'
    
    export default {
        components: { VueEasyLightbox },
    
        data: () => ({ currentIndex: 0, show: false }),
    
        mounted () {
            setTimeout(() => {
                // Timeout in order to load the first image
                this.show = true
            }, 2000)
        },
    
        computed: {
            images () {
                return this.$store.getters.images
            },
        },
    
        methods: {
            close () {
                document.querySelector('body').style['overflow-y'] = 'visible'
            },
    
            onIndexChange (oldIndex, newIndex) {
                this.currentIndex = newIndex
            },
        },
    }
    </script>
    
    bug question 
    opened by NickHatBoecker 3
  • Buttons next and last image with multi image not align using vue 3 ts

    Buttons next and last image with multi image not align using vue 3 ts

    Why? Install Vue3 and vue-easy-lightbox@next
    And using "hello world" using type option and composition api
    The buttons are not align as live demo. Screenshot from 2022-12-06 16-39-26

    As the above image show, the next and last button are on the up side of the view.

    npm init vue@latest // "vue": "^3.2.45", +
    Code: https://onycat.com/vue-easy-lightbox/guide/#basic-usage-in-sfc

    opened by skatesham 3
  • v2.0  dev

    v2.0 dev

    TODO:

    • [ ] update gesture behaviours
      • [ ] limit image movement range
      • [ ] support swipe to change image index without conflict with other gestures
    • [ ] lazy load
    • [ ] thumbnail
    • [ ] toolbar custom
      • [ ] slots ? render function ?
    • [ ] iframe?
    opened by XiongAmao 0
  • Feature request - zooming behaviours

    Feature request - zooming behaviours

    Hello,

    usually we want to swipe to get to previous or next image. (:moveDisabled="true").

    But if we are zoomed in, so that parts of the image are not visible, we want to get to them by repositioning the image with cursor or swiping. (:moveDisabled='false').

    We could achieve this by also emitting zoom changes and current zoom scale.

    Greetings

    feature request 
    opened by mplanitzer 0
  • Feature Request - Double click to enlarge, and pinch to zoom

    Feature Request - Double click to enlarge, and pinch to zoom

    Hi,

    I like this lightbox component a lot! But I am missing two features: 1) A doubleclick or doubletap on the current image should adjust the image to fill the screen or should zoom in all the way 2) Pinch to zoom on touch devices is currently not working.

    Since the component does not expose the image-domelement, I can't find a way to implement this feature in my own project.

    Kind regards

    bug 
    opened by theoreticalsampling 1
Releases(v1.8.1)

Owner
XiongAmao
(・ェ・。)
XiongAmao
A lightweight image, video and iframe lightbox gallery component for Vue

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

Mervin 3 Aug 30, 2022
Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js

Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js

mirari 2.1k Dec 27, 2022
Lightweight responsive image zoom component for Vue.js 2

Vue Image Zoomer Lightweight responsive image zoom component for Vue.js 2, that also works on touch devices. Perfect for zooming on product images on

Sam Jones 40 Dec 24, 2022
Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js

v-viewer Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js Live demo Examples directive component thumbnail

hua chen yu 0 Dec 3, 2020
🔍 Vue image zoom component

vue-magnifier This is a Vue 3 adaptation of react-magnifier, which is the original version. Someone else made a Svelte version, called svelte-magnifie

Website Beaver 3 Aug 9, 2022
Image viewer component for vue 3.x, supports rotation, scale, zoom and so on, based on viewer.js

v-viewer Image viewer component for vue, supports rotation, scale, zoom and so on, based on viewer.js v-viewer for vue2 Live demo Quick Example direct

mirari 14 Oct 29, 2022
Vue Prettybox - a tool dependency that allows you to open or zoom image just by click it

Vue Prettybox - a tool dependency that allows you to open or zoom image just by click it. It helps you to view the image to have a better look of it without making zoom in on your browser.

Israel De Castro A. 2 Aug 7, 2022
A native Vue.js lightbox component

vlightbox Simple native Vue.js lightbox

Oliver Taylor 34 Sep 11, 2022
A lightbox inspired Vue.js component.

A second version of the lightweight lightbox inspired component for Vue.js with local video support and more features coming. If you're interested, see demo.

Martin Rocek 271 Dec 27, 2022
A lightweight lightbox inspired component for Vue.js

A lightweight lightbox inspired component for Vue.js

我是笨蛋小扁担 0 May 28, 2021
Lightbox Photo Grid and Slideshow compoment for Vue.JS

Lightbox Photo Grid and Slideshow component for Vue.JS v-lightbox is a Vue component which allows to display first x (1-5) images of your gallery in a

Morioh Lab 78 Nov 27, 2022
vue zoom component

vue zoom component

Alexander Vysotsky 2 Oct 11, 2021
Mobile-friendly picture file input Vue.js component with image preview, drag and drop, EXIF orientation

vue-picture-input Mobile-friendly picture file input Vue.js component with image preview, drag and drop, EXIF orientation, and more. Installation npm

C.H Lee 0 Sep 24, 2019
Mobile-friendly picture file input Vue.js component with image preview, drag and drop, EXIF orientation, and more.

vue-picture-input Mobile-friendly picture file input Vue.js component with image preview, drag and drop, EXIF orientation, and more. Installation npm

Robert 0 Jun 14, 2018
KéMeet is a Simple, beautiful, fast and secured Open-source zoom alternative, 100% FREE forever!

KéMeet is a Simple, beautiful, fast and secured Open-source zoom alternative, 100% FREE forever! Simply enter a meeting room ID and connect to anyone else in that room! You can even share your screen if you are on desktop!

fotiecodes 31 Jul 6, 2022
A Vue component for showing loader during image loading https://john015.github.io/vue-load-image/

English | 한국어 Vue-load-image Vue-load-image is 1KB(gzipped size) minimalist Vue component that display loader during image loading and display alterna

Sangwon Lee 60 Dec 7, 2022
🌈 A Vue image component. Simple realization of image shadow.

?? vue-image-shadow A Vue image component. Simple realization of image shadow. ?? Example Online: https://image-component.github.io/vue-image-shadow/

null 21 Aug 13, 2022
Vue-image-loader: image loader for vue js with prevue

Vue-image-loader: image loader for vue js with prevue

null 0 Feb 1, 2020
vue-image-markup will provide you to edit uploaded image easily and save it.

Markup Image with Vue.js (customizable) vue-image-markup will provide you to edit uploaded image easily and save it. Installation npm i vue-image-mark

Lionix 92 Dec 9, 2022