Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Trigger an event when pictureFill completed #53

Closed
idflood opened this Issue · 8 comments

6 participants

@idflood

Triggering a custom event at the end of the pictureFill function would have some benefits I think.

Imagine if you have a responsive slideshow with images of different height. Right now, If you add the slideshow on document ready it will have a wrong height since the images are not replaced yet. You could use some imagesLoaded plugin, but again, the images are not replaced when you call it and it will still give a wrong height.

One workaround is to create the slideshow on document load event but it's not the best solution and can have some "long" delay.

Since on my setup I have jQuery I simply added this at the end of the pictureFill function:

$(w).trigger("picturefill_complete");

Then I was able to simply do something like this and it fixed my issue:

$(window).on("picturefill_complete", function(){
  $("#slideshow").imagesLoaded(function(){
    slider.reloadSlider();
  });
});

So, is this kind of addition possible? If it is, I could try to make a pull request : )

@LorenzKahl

+1 for addition of callbacks :-)

@ixisio

that would be a nice feature!

@staabm

I would suggest to use jQuery event namespaces: $(w).trigger("complete.picturefill");

see http://api.jquery.com/on/#event-names

@ixisio

agreed!
might look something like this:

$(window).trigger("eventType.namespace") 

I prefer a dot instead of colon, but both would be okay

Cheers

@staabm

fixed my example above... the . is the offical jquery way.. thanks @ixisio

@u982744

I don't think this should be done with jQuery. Keep it decoupled from jQuery.

@ixisio

@u982744 you 're absolutely right.
think we can close this issue, the correct approach already exists #60.

@scottjehl
Owner

Thanks for your ideas here. We're closing this out as Picturefill moves to support the new standard markup landing in browsers. Thread here: #125

@scottjehl scottjehl closed this
@xini xini referenced this issue from a commit in xini/silverstripe-responsive-images
@xini xini Trigger event on picturefill completion, see trigger complete event (… a828a63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.