Save url of latest load to allow back button #230

Closed
wants to merge 2 commits into
from

Projects

None yet

4 participants

@ilyakatz

This commit allow to save the page of the latest load into the URL. This allows user to use the back button. There is also a way to override the default behavior by extending a method

@67726e
Contributor
67726e commented Oct 28, 2012

What exactly is the use case for this? I understand that you are saving what URL was used, but what is this to be used for? How are you using this in your own project?

@ilyakatz

currently, when using infinite scroll if I scrolldown to page 10 and click on something that takes me to different page, when I click Back button in my browser, it will bring me back to the beginning which isn't great user experience. Saving the page in the push state would allow developers to bring users back to the page they were on. It may or may not be the best for all use cases but I think it would be great to have this option

@kristianmandrup

Interesting!!!! Would love to see a demo of this in action :)

@ilyakatz

there isn't a website that uses that concept anymore. unfortunately, had to close down that project a couple of weeks ago. so i'll try to create a small app to illustrate the idea

@ilyakatz

ok, here is a little app that shows an example. it may not be perfect but enough to illustrate what i mean

http://infinitecomeback.herokuapp.com/posts

@kristianmandrup

Thanks a lot :) I will have a look ASAP.

@67726e
Contributor
67726e commented Dec 11, 2012

@ilyakatz I like the idea, but I don't particularly wish to add more features to the plugin that are not strictly necessary. I'm thinking adding a callback with this would be the proper way to go, but currently one cannot fetch the URL from it currently. I'm going to add this in instead of adding this as an entirely new feature.

@67726e 67726e added a commit that referenced this pull request Dec 11, 2012
@67726e 67726e Issue #230 Added URL to append callback 536317e
@67726e
Contributor
67726e commented Dec 11, 2012

@ilyakatz The append callback now takes the URL as the last parameter, so you can now write something like:

function(newElements, data, url) {
  history.replaceState({infiniteScroll:true}, null, url);
}
@67726e 67726e closed this Dec 11, 2012
@ilyakatz

thanks @67726e, i guess that is a reasonable compromise, however, I would encourage to consider it further. imo, clicking back button in infinite scroll enabled page is not handled well on many sites which is a shame. not sure what is the best "default" solution but I think it would add a lot of value having one possible solution out of the box.

@67726e
Contributor
67726e commented Dec 11, 2012

@ilyakatz Yeah, the back button is a bit of an issue, although it could be handled a number of ways. I think that maybe creating a behavior for "back buttons" would be something to do in the future.

As I said, I like the idea, I just don't think it is something that should be in the core plugin. I would prefer to get the plugin in a very module state so that overriding certain behaviors is very easy. I'll definitely revisit this idea once I've finished up the last chunk of issues.

@shadeless

This is great! Any way to use it on a WordPress site?

@67726e
Contributor
67726e commented Dec 18, 2012

@shadeless I haven't yet upgraded the WordPress plugin. I should be doing a new release something this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment