Coder Social home page Coder Social logo

vue-image-lightbox's Issues

Lazy Load Large (src) image Only when Gallery Opened / thumbs clicked?

I am using the example with lazy-load (.src) and then openGallery to get Lightbox to show.

Since a typical page may have 20 images or so, and, they could be large, I notice that its the large images (not the thumbs) that are put into the thumb (background on small divs) then when click, it starts lightbox at that image. Which is great. But is there any way to only have the thumbs lazy-loaded, then, when opening lightbox gallery, only then have the full size image lazy loaded, as it's possible not all visitors to the page will even want to click photos.

Here is my code (so maybe it's just a simple adjustment you can recommend, or I've missed something likely, looks great by the way).

<ul class="photoThumbs">
    <li class="thumb-li"
      v-for="(image, index) in images" >
      <div v-lazy:background-image="image.src"  :class="'lazy-thumb'" @click="openGallery(index)">
      </div>

Tried to go with ="image.thumb" but then open LightBox and only get a gallery of the small thumbs. At 8,000 pages with 10 to 20 images per page, and heavy traffic, I'd prefer to download thumbs and only download the large image when someone clicks the thumb or moves to next image in the gallery. Hopefullly I've just not missed something.

no lightBoxOn event !

in my project i'm using lightbox and i need to keep an eye on lightBoxOn to control sidebar show/hide. so it'll be great having lightBoxOn event.

displayThumbs problem

situation:
After dynamically modification the :images property (add or remove) displayThumbs and countImages properties not updated

Failed to mount component

After update vue-image-lightbox have error:
"[Vue warn]: Failed to mount component: template or render function not defined.
(found in )"
image

TypeError: undefined is not an object (evaluating 't.addEventListener')

I'm getting the following error during page-load:

[Vue warn]: Error in mounted hook: "TypeError: undefined is not an object (evaluating 't.addEventListener')"

found in

---> <Lightbox> at src/components/LightBox.vue
       <Root>

Here's how I am rendering it out:

import LazyLoad from 'vue-lazyload';
import Lightbox from 'vue-image-lightbox';
Vue.use(LazyLoad);
Vue.component("lightbox", Lightbox);
    data: function () {
        return {
            lightboxImages: [],
        };
    },
            <lightbox ref="lightbox" :images="lightboxImages" :show-light-box="false" :show-caption="true"></lightbox>

It appears to have to do with this line:

    const hammer = new Hammer(this.$refs.container)

where this.$refs.container is undefined.
Updating this to the following seems to have worked:

    if (this.$refs.container || false) {
        console.log(this.$refs);
        const hammer = new Hammer(this.$refs.container)

        hammer.on('swiperight', () => {
          this.previousImage()
        })

        hammer.on('swipeleft', () => {
          this.nextImage()
        })
    }

Any thoughts on what may be causing this? It seems to work fine; but I need to clear any errors from the console. Thanks! :)

Nuxt Page refresh

Hey I really like this component, but am running into some issues with refreshing the page in my Nuxt app.

image

Here are my dependencies:
"nuxt": "^2.0.0",
"vue-image-lightbox": "^6.0.1",
"vue-lazyload": "^1.2.6",
"vue-touch": "^1.1.0",

and here is the page using the lightbox component

image

I have set up Lazyload as a Nuxt plugin like this

plugins/lazyLoad.js:
import Vue from 'vue'
import VueLazyLoad from 'vue-lazyload'

Vue.use(VueLazyLoad)

nuxt.config.js:
'@/plugins/lazyLoad

What ive tried:

Any help would be greatly appreciated, thanks!

ES5 build

Hi,

can you adjust babel so this lib produces ES5 compatible build? This is a nice lib but cannot be used when an app needs to support IE11.

Thanks, Ondrej.

closeLightBox methods

hey,
am really like the package , just need help how using method closeLightBox ?

<lightbox alt="" class="mw-100 w-auto" v-if="data.image" :images="[data.image.full]" ></lightbox>

Build fails

When doing a npm run build the following error occurs:

ERROR in static/js/vendor.87839b9db02403d7ae6a.js from UglifyJs
Unexpected token: name (s) [./~/vue-image-lightbox/dist/vue-image-lightbox.min.js:1,26466][static/js/vendor.87839b9db02403d7ae6a.js:88596,26426]

How to load images using require (as needed by vue.js)

Not a bug or issue, but a question on usage (my apologizes in advance if this is not the right location to ask questions for vue-image-lightbox). I really want to use vue-image-lightbox. How to use 'require' to load .jpg images as needed by Vue.js?

For example (this will show images on page):

          <img
            v-lazy="require(`@/img/${image.src}`)"
            style="height: 100px"
            @click="openGallery(index)"
          >

However, when clicking on an image Lightbox comes up, but images are broken.

Question: How can 'require' be set for the .jpg images for/within <Lightbox...> (so when an images is clicked it will show as expected. Currently images are broken.)?

Thanks much for this tool, and your time.

Could you add onClose event?

This event would fire when the lightbox is closed.

Are there examples of how to work with the events this module provides?
Thank you!

stopPropagation is not a function

In vue-image-lightbox/dist/vue-image-lightbox in stopPropagation

{snip} .stopPropagation(),t.previousImage()},swipeleft:function(e){e.stopPropagation(),t.nextImage()}}},[s("div",{staticClass:"vue-lb-content"},[s( {snip}

Remove vue-lazyload as a dependancy

Man I really wanted to love this package, and I was so close. Then I noticed that it's heavily dependent on vue-lazyload. Why? I'm using what I believe is a better lazy load lib (https://github.com/aFarkas/lazysizes) and I'm stuck with the decision on going with a different lightbox or having 2 lazy load libs.

This seems to be a decision I shouldn't have to make.

Can't your comp detect if lazy load is installed and do whatever it needs to?

Responsive Thumbnail Section?

Is there a way the thumbnail section can be responsive? I have seen a few other lightbox examples where depending on the screen size the number of thumbnails changes. Is there a way to do that with this package? or is it something I need to add my own custom CSS/Vue computed property for the nThumbs?

Thanks!

Onchange?

Is there any method to know when you change images?

Animation effects

would be nice to chose transition effects (most desirable slide in and out)

IE11 Issue

Getting an error in IE11 Expected ':'

SSR options

Hello thanks for the package, already using it in one of my projects.
I do have a question however.

Is there a way to use this package with ssr/nuxt?
If so it would be awesome if the readme contained an example, if not is something that is going to be added?

Missing sourcemap???

Hi,

Tks for nice lightbox.
I wonder if you could provide sourcemap for js file?

TS support

need types support for typescript version....

How to use slots?

How do I use the slots.

Currently trying like this, but it does not work:

      <light-box
        :images="lightBoxImages"
      >
        <template v-slot="close">
          <h2>TEST</h2>
        </template>
      </light-box>

Avoid flicker when loading full size images

As opposed to the demo, on my site I'm using different files for thumbnails / full size images. When I open the lightbox or click the next image, for a moment all that's displayed is a little box on the middle of the screen (while the image loads). Is it possible to avoid this?

lightbox

As you can see, after the images are loaded everything works fine.

Not working on Ipad

Problem exist on Ipads only. Remote debugger shows next thing

image

This problem discovered on my project (latest build also used). Screen was taken from debugging your demo

Mem leak

You must destroy hammer created in mounted hook in beforeDestroy hook

Add ability to zoom

One should be able to pinch-zoom the image.

I would like to contribute, but I need some infos about where to start or where to put this implementation.

Accessibility for images

Looking at the inspected code of the demo and the src it seems you aren't adding an alt tag to the images in the gallery.

It would be rad if the caption attr could translate to an alt tag.

thumb on dynamic image don't change

I have this template and second thumbs don't change on images change.
The images change correctly but thumbs not work properly.

<template>
  <div>
        <div 
          v-for="(image, index) in products" 
          style="display: inline-block"
          :key="index"
        >
          <img 
            v-lazy="image.link" 
            style="height: 100px" 
            @click="openGallery(index)"
          >
        </div>
      <LightBox 
        :images="images" 
        ref="lightbox"
        :show-thumbs="true"
        :show-light-box="false"
      >
      </LightBox>
    </div>

</template>

<script>
require('vue-image-lightbox/dist/vue-image-lightbox.min.css')
import LightBox from 'vue-image-lightbox'

export default {
  components: {
    LightBox,
  },
  created() {
    console.log('ene0')
  },
  data() {
    return {
      products: [
        { id: 1, link: '/image/1.jpg', images: [
            { id: 1, link: '/image/7.jpg'},
            { id: 2, link: '/image/2.jpg'},
            { id: 3, link: '/image/3.jpg'}
        ]},
        { id: 2, link: '/image/6.jpg', images: [
            { id: 4, link: '/image/4.jpg'},
            { id: 5, link: '/image/5.jpg'},
            { id: 6, link: '/image/6.jpg'}
        ]}
      ],
      images: []
    }
  },
   methods: {
    openGallery(index) {
      this.images = []
      for (let i = 0; i < this.products[index].images.length; i++){
        this.images.push({
          src: this.products[index].images[i].link,
          thumb: this.products[index].images[i].link
        })
      }
      console.log(this.images)
      this.$refs.lightbox.showImage(0)
    }
  }
}
</script>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.