Giter Site home page Giter Site logo

Multiple Instances about infinite-scroll HOT 11 CLOSED

metafizzy avatar metafizzy commented on April 27, 2024
Multiple Instances

from infinite-scroll.

Comments (11)

scottbuckel avatar scottbuckel commented on April 27, 2024

Thanks!! Tested and it works as planned!

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

Tested, and mostly works. I've noticed if I reach the end of one Infinite Scroll, it won't initiate any other. I'll have a look at this today.

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

Found the bug. Once you've finished scrolling, props.isDone and props.isDuringAjax don't get reset for the next instance of the infinite scroll.

A potential fix might be to change isDone and isDuringAjax to be options instead of properties, so that they can be indexed with each instance of the Infinite Scroll. I'll take a crack at this today and see what I come up with.

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

Okay, I've resolved this...somewhat. I was getting $(document).ajaxError to fire for each instance of the scroll I had gone through, so I built in a temporary fix that determines if that opts.isDone has already been declared true.

This means that .ajaxError still fires 3 times if you're finishing your third instance of scrolling to the bottom, but at least it doesn't go through the rest of the code unnecessarily. That's why I would consider it to be a temporary fix, until someone can figure out how to properly unbind it.

Here's my revision.
http://lukeshumard.com/misc/infinite-scroll/

For now, here's the modified block.

$(document).ajaxError(function(e,xhr,opt){
if (!opts.isDone) {
debug('Page not found. Self-destructing...');
// die if we're out of pages.
if (xhr.status == 404){
showDoneMsg();
opts.isDone = true;
opts.currPage = 0; // if you need to go back to this instance
$(opts.localMode ? this : window).unbind('scroll.infscr', infscrSetup);
$(document).unbind('retrieve.infscr.'+opts.infid,kickOffAjax);
}
}
});

from infinite-scroll.

paulirish avatar paulirish commented on April 27, 2024

with http://pastebin.com you can pst the original.. then "submit a correction"
and after that.
the resulting page will have a Difference link.

nice work btw. :)

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

http://pastebin.com/diff.php?i=D79Z0neS

there you go! thanks!

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

spoke too soon. after doing some more testing, i realized that each instance won't become unbound unless it reaches the end. big oops on my part.

working on a fix now.

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

forgot to mention i sorted this out. i'll send a pull request soon.

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

Solved in version 1.5.101203

from infinite-scroll.

samcleaver avatar samcleaver commented on April 27, 2024

I've been away for a while! Looking good Luke, I've added the latest commit which builds on your modification, for some reason the multi-instancing wasn't working correctly with the triggering which I've resolved. I've also added automatic generating of the instance ID when not using manual triggering.

from infinite-scroll.

kkalbat avatar kkalbat commented on April 27, 2024

Is this change implemented in the latest version of Wordpress plugin? Because when I try multiple instance, it totally crashes. Is there an extra work for defining the the multiple containers and selectors in case of multiple scrollers on the same page?

from infinite-scroll.

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.