Giter VIP home page Giter VIP logo

Comments (5)

raphamorim avatar raphamorim commented on June 16, 2024 1

Nice!
I'll close this then 👍

And document for this for future issues :)

from waterfall.js.

raphamorim avatar raphamorim commented on June 16, 2024

Yeah, it's possible.
But does make sense make this change?

In which cases you think it gonna be useful @lnmunhoz?
What do you think @israelst ?

from waterfall.js.

lnmunhoz avatar lnmunhoz commented on June 16, 2024

I'm using in a infinite loading context. I just solved like this:

const cardsBox = this.firstNode;
cardsBox._uihooks = {
  insertElement: (node, next) => {
    $(node).insertBefore(next);
    $(node).imagesLoaded(() => {
      // Retrieve the current amount on the grid
      this.data.onItemReady($(cardsBox).find('.item').length);
      waterfall(cardsBox);
    });
  }
}

After each rendered item I'm getting the length of the grid and passing to my onItemReady callback. So when I reach a certain number of elements It will be able to "fetch more" in my list.

This is not actually a problem, I solved very quickly. But with masonry I had a callback that does this trick for me.

It can be useful for dynamic contexts like mine.

from waterfall.js.

israelst avatar israelst commented on June 16, 2024

Hello @lnmunhoz, why don't you simply use cardsBox.childNodes.length or cardsBox.childElementCount?

Did I get something wrong?

The Node.childNodes read-only property returns a live collection of child nodes of the given element.
https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes

from waterfall.js.

lnmunhoz avatar lnmunhoz commented on June 16, 2024

Works perfectly!

from waterfall.js.

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.