Giter Site home page Giter Site logo

Comments (10)

lukeshumard avatar lukeshumard commented on April 27, 2024

I'll put up a demo later today of how I have it working, but could you send a link to your example?

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

one thing to keep in mind...whenever there's an instance of infinite scroll, it needs to have it's own div.navigation. what error comes up when you switch debug on?

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

After doing some more testing and creating a demo page for multiple instances, I found out Hans was right with the $(document).ajaxError terminating for every instance of the plugin.

I've redone the error function to be...

function infscrError(xhr){
if (!opts.isDone && xhr == 404) {
// die if we're out of pages.
debug('Page not found. Self-destructing...');
showDoneMsg();
opts.isDone = true;
opts.currPage = 1; // if you need to go back to this instance
$(window).unbind('scroll.infscr.'+opts.infid, infscrSetup);
$(document).unbind('retrieve.infscr.'+opts.infid,kickOffAjax);
}
if (opts.isFiltered && xhr == 302) {
// die if filtered.
debug('Filtered. Going to next instance...');
opts.currPage = 1; // if you need to go back to this instance
opts.isPaused = false;
$(window).unbind('scroll.infscr.'+opts.infid, infscrSetup)
.unbind('pause.infscr.'+opts.infid)
.unbind('filter.infscr.'+opts.infid)
.unbind('error.infscr.'+opts.infid);
$(document).unbind('retrieve.infscr.'+opts.infid,kickOffAjax);
}
}

Errors will be triggered using...
$(window).trigger( "error."+opts.infid, [404] );

Here's something to think about, though. The infscr-loading box is set under props, so only one instance of it could exist. Should this be defined in opts, and each instance creates its own "#infscr-loading-"+opts.infid with a general class of infscr-loading (for easy styling)?

My demo page should be up later today or tomorrow.

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

http://lukeshumard.com/misc/infinite-scroll-demo/

okay, here's something for now. that has multiple instances working. i'm sure there's still cleanup to do.

i've also done a commit with the error changes.

from infinite-scroll.

samcleaver avatar samcleaver commented on April 27, 2024

As an update to this it looks as though having the "pixelsFromNavToBottom" under props was causing multiple instance conflicts. I've moved this out into opts for my latest commit,. I've also modified it; my last commit (a while ago) you had to manually define an infid for each instance, now it generates a randomish ID for each instance. Could you clarify how your isFiltered part works?

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

Nice catch on the pixelsFromNavToBottom!

The isFiltered is basically a way to trigger the function filterNav as isDone. How I have it on my project is...
$(window).trigger('filter.infscr');

That trigger causes infscrError to fire, and will go through the necessary code to unbind and such.

Out of curiosity, what is the benefit to having a random number for opts.infid? I think just having opts.infid set as 1 or being manually set is sufficient.

from infinite-scroll.

samcleaver avatar samcleaver commented on April 27, 2024

Ahh, isn't infscrError called when loadCallback is called and it detects a 404? On the trigger example the errorCallback is used to unbind the nav etc, is this a different way?

Yeah we could revert back to having to manually set it; I just thought it would make it easier for newer users trying to use multiple instances for the first time and it just working "out of the box" as it would save the user having to set the infid for each one. What do you think?

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

infscrError is called and detects a 404, but being filtered needs to cause several different unbindings and such. we could try to get it down to one error, but i think it's a good idea to have them separate for debugging.

i'm not opposed to having the random number as an option, but what if it would only generate a random number if you set infid to 0?

from infinite-scroll.

samcleaver avatar samcleaver commented on April 27, 2024

At the moment it only generates a random number if you don't define one, I think this might be a better way of doing it?

I agree -- keeping them separate is a better option :)

from infinite-scroll.

lukeshumard avatar lukeshumard commented on April 27, 2024

Since this issue seems to be resolved, I will go ahead and close it and make sure to include a demo for this in the new site.

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.