Giter Site home page Giter Site logo

Comments (7)

sjwilliams avatar sjwilliams commented on July 19, 2024

added in v0.5.0

from laziestloader.

zachwise avatar zachwise commented on July 19, 2024

It seems that this works, sort of. It adds the class but it does so before the browser has fully loaded the image. It seems that the class is added when the source is switched, not when it's actually loaded.

from laziestloader.

sjwilliams avatar sjwilliams commented on July 19, 2024

@zachwise, yes, you're correct. it doesn't actually wait until the image has loaded. My need was tracking whether the element had triggered the scroll-based callback, not whether or not the function of the callback -- which is an image load by default but could be lots of other things -- had actually completed.

I could see how 1) the language/feature is confusing and 2) folks would want what you're talking about, not what I actually implemented.

I'm certainly open to the idea of changing state somehow on an event, like image load. If we add it, I'd want to make sure the solution is still generic, so things like iframes, videos and custom callbacks with no src setting behave predictably.

What were you trying to do? What would you want in an ideal solution?

from laziestloader.

zachwise avatar zachwise commented on July 19, 2024

I was hoping to smooth out the loading of images as they come into view by fading them in. Right now I was using the ll-loaded class to change the opacity but it gets applied before the image actually loads. which means the image pops into view instead of fading. Here's an example of what I'm working on: http://picturestory.knightlab.com/stories/jackie.html

from laziestloader.

zachwise avatar zachwise commented on July 19, 2024

It looks like I could just use jquery's load method to find out when something loads, so it's up to you if you think it's needed for this library or not.

from laziestloader.

sjwilliams avatar sjwilliams commented on July 19, 2024

@zachwise fwiw, today I needed the same functionality you do, so I've started the feature-onload branch to experiment.

from laziestloader.

sjwilliams avatar sjwilliams commented on July 19, 2024

I've changed this in v0.5.1 so images fire their callback and update class names onload, and video and audio elements do it onloadstart. Every other situation continues to do it immediately when the viewport position triggers the callback.

from laziestloader.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.