Joeri's avatar
Level 20

Laravel infinite scroll with position redirect.

Hey,

I'm looking around for a infinite scroll in my posts feed that works with laravel pagination. So when the user is near the bottom the next page appends on the bottom. I found some jQuery plugins that could manage this like infinite-scroll & jScroll.

The point is I want to have the option to redirect the users to the post or comment they created, so lets say the commented on post div#post_345 after I handled the add of that post I want to return them to the page and let them automatic scroll to their comment.

After some research I could not find a right/good solution. I hope someone can send me in the right direction to complete this.

Joeri,

0 likes
2 replies
Pendo's avatar
Pendo
Best Answer
Level 10

I think you have do some kind of check and call an extra javascript function:

  • (1) First you load the page after adding a comment
  • (2) You check if #post_345 exists on the page, if so, animate the scroll down to the post
  • (3) If not, scroll down the page and let inifiniscroll load extra posts. A function that is called after loading extra posts should redo step 2

Please or to participate in this conversation.