Giter Site home page Giter Site logo

Comments (4)

darsain avatar darsain commented on June 12, 2024

Actually no. The always method doesn't receive any arguments. That's its nature as specified in the Deferred promise API specification. To get the simple callback functionality while binding deferred methods with an object map, you can pass the callback as a callback property. Here is the object map with all possible properties and arguments they receive:

$(selector).imagesLoaded({
    done: function ($images) {},
    fail: function ($images, $proper, $broken) {},
    always: function () {},
    progress: function (isBroken, $images, $proper, $broken) {},
    callback: function ($images, $proper, $broken) {} // here is the simple callback simulation
});

And it is all documented :)

from imagesloaded.

biphobe avatar biphobe commented on June 12, 2024

I still don't agree that it's all documented ;)

"Always" will be always executed no matter what happens with images - but what about standard callback? Will it be executed when all images fail to load? Or when something goes wrong?

Documentation states that callback function will be called when all images finish loading - but it hasn't been said what happens when images fail to load.

from imagesloaded.

darsain avatar darsain commented on June 12, 2024

Yes, "when all images has finished with loading". There is purposely nothing about their state, as that is irrelevant in simple callback. The images state has effect only on Deferred promise resolution, which is mentioned later in the docs as a bonus feature.

If nothing else, the callback arguments itself suggest that it is triggered regardless of the state of final images. Otherwise what would be the point of having $proper & $broken arrays when callback doesn't fire if there are broken images :)

But I see where the source of confusion might be. I'll try to clarify that.

from imagesloaded.

biphobe avatar biphobe commented on June 12, 2024

That's exactly what I meant, sorry for confusion - thanks!

from imagesloaded.

Related Issues (20)

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.