vue-lazyload icon indicating copy to clipboard operation
vue-lazyload copied to clipboard

inline @load @loading @error events

Open julian-ca opened this issue 6 years ago • 9 comments

How can we use add these event listener per inline item?

for example

<img v-for="(item, index) in items" v-lazy="https://example.com/photo.jpg" @loading="onLoading(index)"/>

We specifically want to pass the index to the callback.

julian-ca avatar Jul 25 '18 18:07 julian-ca

it should be implemented in the lazyImage component, but not yet

hilongjw avatar Jul 26 '18 10:07 hilongjw

@hilongjw is there any documentation about the lazy-image component? I can't seem to find it.

julian-ca avatar Jul 26 '18 13:07 julian-ca

Okay, I found out that it wasn't documented and we need to enable the component by passing lazyImage: true to the options.

It's working, but is there any reason why it isn't documented?

julian-ca avatar Jul 26 '18 13:07 julian-ca

@julian-ca because the current implementation is relatively simple

hilongjw avatar Aug 10 '18 15:08 hilongjw

so where is a example to do that?

weituotian avatar Oct 09 '18 15:10 weituotian

Any ideas on this, I want to also do this? I'd like to have a error listener in my component which then does something

jamesmorgan avatar May 27 '19 05:05 jamesmorgan

So it's not possible to use @error inline on an image tag?

<img v-lazy="https://example.com/photo.jpg" @error="onError()" />

Currently error never fires because it's the default img error handler and vue-lazyload always has a legit blank image inside of src. So I need the vue-lazyload error to bubble up when it fails to load the real image.

alexcroox avatar Jul 28 '20 12:07 alexcroox

@alexcroox you can refer to my code.

I've modified the vue-lazyload's lazy-image component a little bit. https://github.com/WisdomSky/wisdomsky.github.io/tree/develop/src/vue-lazyload

and then installed the plug-in. Make sure that lazyImage flag is passed in the config. https://github.com/WisdomSky/wisdomsky.github.io/blob/develop/src/main.js#L16

Then use it. You can see in my code that I'm using @loading. https://github.com/WisdomSky/wisdomsky.github.io/blob/develop/src/views/Photography.vue#L27

but @error is available too. https://github.com/WisdomSky/wisdomsky.github.io/blob/develop/src/vue-lazyload/lazy-image.js#L94

I've added three handy events. @loading, @loaded and @error.

WisdomSky avatar Jul 28 '20 23:07 WisdomSky

@hilongjw is the implementation from @WisdomSky PR worthy? It would be nice to get the events.

@WisdomSky thanks for the work, I'll use your fork for now.

Artem-Schander avatar Aug 19 '21 09:08 Artem-Schander