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
Check if image is fully loaded #79
base: master
Are you sure you want to change the base?
Conversation
@aderaaij this could help don't you think? https://github.com/marlospomin/turtle/blob/master/src/turtle.js |
@jimblue Yeah it's done in a nice way, somewhat similar actually! Only it doesn't have solutions for |
Indeed @aderaaij... does the actual PR work for background image on your side? I doesn't here |
Good question! No it doesn't, I only check the normal src now. Background image shouldn't be too hard though. I'll have a check later on |
Allright. I'll work on this too. 😄 |
I was thinking about a nice way to make the loading feeling really smooth:
The benefit is to preloaded images outside viewport but showing the animation when reaching viewport. What do you think? |
It's a good idea but I think that would be for users themselves to define. You can override the rootmargin and treshold when calling the script, so everyone can figure out what works smooth for themselves, as long as there is a part in there that tells when the image is fully loaded. |
That's true |
Added support for background images |
Thanks @aderaaij!!!! I can't wait @ApoorvSaxena have a look to this PR 😝 ! |
Hi @aderaaij! Do you now why checks have failed? |
oh ok just learn somethin! Thanks @dutchenkoOleg ... Just don't know how to fix this ^^ |
@jimblue in this pull-request I explained I didn't bother passing all the tests as I wanted to discuss this PR first. I don't know too much about tests, but they're failing because they're expecting an image to be returned right away, so they probably also need the 'loading' script included. Oh and there's one about SRC Set too 😅. But to be honest I think @ApoorvSaxena is pretty preoccupied, and also it's around x-mas time so there might not be happening too much anyway. So you might have to run with the fork for now! |
Hey @aderaaij ! No worries about this, I'm already pretty happy with Lozad! |
@aderaaij PR has conflicts. I had the same problem in my pr #80. Also, could you please consider processing of an picture element |
Also you need to mark the items that have already started to load. Pay attention to these lines of code:
Maybe you need just add new data attribute, when image is loaded.
|
@dutchenkoOleg Thanks for the ideas! I'm completely aware that these don't pass the tests as I just wanted to get some opinion of the library maintainers first. As I say in my opening post:
If I ever hear back about this I will definitely take your suggestions into consideration 👌 |
Hi @ApoorvSaxena! Can we have your input on this to move on and start fixing #49? Thanks |
@ApoorvSaxena Nope I'm totally good with that! |
@ApoorvSaxena yep I'm good with that too ! EDIT: after some test it seems that #86 can't replace this PR as it doesn't check if image is fully loaded... |
This PR is very interested, I need it, how can I help to make it merged? |
it's shame it was never merged :c |
This is a quick and dirty pull request to check if images have already loaded. This will not pass your tests yet, and doesn't yet take in account
srcset
either, but I wanted to get the ball rolling!A few thoughts.
I've modified the
markAsLoaded
function to simply implement a waiting for images function,data-loaded
is only added after the image is fully loaded. I can imagine that there might be circumstances where you want to do something as soon as the image is added, so maybe it's an idea to add anotherdata-attribute
especially for when the image is fully loaded.I also made a solution for
srcset
but it isn't very elegant yet. It usesp-wait-for
, which only adds a couple of bytes to the total. I didn't include this solution in my pull request yet, I'd like to discuss it first!