cee-chen / object-fit-polyfill

A Javascript polyfill for browsers that don't support the object-fit CSS property.
ISC License
496 stars 93 forks source link

Possibility to give an element as parameter #27

Closed cedeber closed 7 years ago

cedeber commented 7 years ago

As objectFitPolyfill is already declared on window, I think that to add a parameter to it would be usefull so that we can use it with lazy loading images.

Something like this works well:

var objectFitPolyfill = function(element) {
    var media = typeof element === "undefined" ? document.querySelectorAll("[data-object-fit]") : [element];
    [..]
}

What do you think about that?

cee-chen commented 7 years ago

Yes, this is definitely something I'd like to do! Apologies for dropping off the grid for a bit here, I've been incredibly swamped with side work. I promise I'll get around to this! :)

cee-chen commented 7 years ago

This is now possible as of v2.0.5! While I was at it I added support for multiple DOM elements (jQuery or querySelectorAll arrays) - figured I might as well not make people add another for loop, since I'm already doing it :)

You can check the added code here if you're curious.

cedeber commented 7 years ago

Hello. Now it's perfect! Thank you.