luis-almeida / unveil

A very lightweight jQuery plugin to lazy load images
4.15k stars 675 forks source link

Unveil-Image in "hidden" Elements #72

Open derSteffen opened 10 years ago

derSteffen commented 10 years ago

Hello,

I use the great script for the first time and everything is GOOD!

I have a question. If I habe "unveil-image" in hidden elements, fo example in accordion-divs or tabs, the images are not display. If I reszie or scroll, then the images are display ... thats the function! In know!

Is there an opinion that I can display the image with an click-event. For example. If I click the .head-element that unveil-image in this child-element .child-element are display.

Or can I start the function unveil() with a click-element?

Thank you very much!

Greetings Steffen

ghost commented 10 years ago

i haven't used the plugin yet but the documentation says you could use the trigger event to do that...something like this...

$('#button').on('click', function() { $("img").trigger("unveil"); });

derSteffen commented 10 years ago

GREAT

Thank you very much!

derSteffen commented 10 years ago

Thats my Code: $('.responsive-accordion-head', this).on('click', function() { $(".responsive-accordion-panel img.lazyload").trigger("unveil"); }); That works, but in this case, all image in all my .responsive-accordion-panel are display, if I click on the head. Is there an opinion that only the images are display in $this .responsive-accordion-panel and not also in all others .responsive-accordion-panel ?

Please, can you help me?

Greetings

ardok commented 10 years ago

@derSteffen Not quite sure what you mean but I believe you should be able to do something like:

$('.responsive-accordion-head', this).on('click', function() {
  $(this).find('.responsive-accordion-panel img.lazyload').trigger("unveil");
});
derSteffen commented 10 years ago

Thanks! That is it :-)

ghost commented 9 years ago

So, If I have more than one hidden image and I have to show on click. I have to trigger unveil on each and every click?