Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New polyfill #1

Open
fvsch opened this issue Mar 10, 2016 · 4 comments
Open

New polyfill #1

fvsch opened this issue Mar 10, 2016 · 4 comments

Comments

@fvsch
Copy link

fvsch commented Mar 10, 2016

So we have a first polyfill in this repo, and a different approach at:
http://codepen.io/jonneal/pen/EKPONK
which I expanded upon at:
http://codepen.io/fvsch/pen/MyyBXW

So whether we make a fitie 2.0 or a new repo with a different name, it would be good to have a broad idea of what we want to do.

Name

"fitie" might be problematic with Edge and older WebKits needing some polyfill too.
If we don't keep this name, I guess we need a new repo.

Feature set

Rationale for some of the changes I did in my codepen:

  • Add (limited) object-position support: because it's nice. :) But it could be left to users, with instructions to set both object-position and background-position.
  • Move background-size and background-position out of the JS and to the CSS: I think it's nice to have the JS only add the background-image, and let users control it in CSS. Likewise, it's probably better to avoid resetting background-color.
  • Expose a global function: allows users to reapply the polyfill to new content (has to be done manually); there's some code to make sure we don't work on the same image twice.
  • Add limited responsive image support: using currentSrc then removing srcset.

Do we want to keep all of that? Only specific bits?

@fvsch
Copy link
Author

fvsch commented Mar 10, 2016

Looking at fitie.js, you're wrapping the img or video element in a custom element (duplicating a lot of CSS styles from that element to the wrapper), and then you have a little bit of complexity to support img and video and fill, contain and cover.

I guess that's needed for supporting <video>, but can you confirm that for <img> only we can go with background-image and avoid the complexity of doing the math (and live updates) ourselves?

@fregante
Copy link

fregante commented Mar 26, 2016

Most of what you suggested has been published here: https://github.com/bfred-it/object-fit-images

  • browser does the math through background-image
  • object-position support
  • background-color is not overridden (2.2.0)
  • global function
  • automatic new content detection
  • srcset support

fitie's disadvantages are necessary to support <video> so it's unlikely that they are implemented here.

@DanielRuf
Copy link

I recommend archiving this project. Other solutions have better support and it is irritating when there are multiple polyfills (come on devs, GitHub is actually for collaboration ;-) ) and you have to decide which one to use.

@jonathantneal
Copy link
Owner

I’m okay with someone contributing to this project (with a non-failing PR) and eventually taking it over to make such a decision. That being said, bfred-it wrote:

fitie's disadvantages are necessary to support

Unless you have evidence to show this is no longer the case, I’m not sure what you are basing your opinion on, other than your personal convenience and current non-video needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants