• Resolved RoselleCelina

    (@rosellecelina)


    Hi Sebastien,

    Everything works beautifully except for when you hit the back and forward buttons. When you hit those buttons, the url doesn’t match what the page jumps to.

    If I go to my latest post, and then scroll allllll the way down to my last post, and then hit the back button, it wont go to the top of the previous post. It just lands somewhere previously scrolled. Same thing goes if you’re hitting the forward button. Sometimes it goes somewhere, sometimes it doesn’t.

    I thought it was just an issue with my theme, but when I go to your demo site, it does it there too.

    Was wondering if you were aware of this and had a workaround?

    Thanks,
    Roselle

    P.S. Here’s a link to the YouTube video I made of the issue https://youtu.be/SZpIjXqkv3o

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    Hi Roselle.

    I was not aware of this so thank you for pointing this out. It is very good user feedback.

    There is nothing in the Javascript added to alter the way the back and forward buttons are handled so the fact that it scrolls to the top of the wrong article is odd.

    I will have to find some time to look into the issue further.

    Thank you for your patience.

    Sébastien.

    Thread Starter RoselleCelina

    (@rosellecelina)

    Thanks for getting back to me!

    I added this code to your auto-load-next-post.js

    // Bind to StateChange Event
    History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
    
    var State = History.getState(); // Note: We are using History.getState() instead of event.state
    
    if (State.url != curr_url) {
    window.location.reload(State.url);
    }
    
    });

    This gets us allllmost there.

    I noticed that with this code, when you hit either the back or forward button, it will go to where it’s supposed to go, but does so by reloading to it. Ideally, it would just scroll up or switch to it instantaneously without a reload.

    What can we do?

    Edit: Actually, what it does when you hit the back button is first, it goes to the wrong spot before it reloads to the right article. A bit herky jerky.

    Plugin Author Sébastien Dumont

    (@sebd86)

    You could ask it to scroll up to the previous post with animation if it exists.

    So first you would need to identify the current post your viewing if loaded from scrolling, then find the previous article in reference to the history state.

    Plugin Author Sébastien Dumont

    (@sebd86)

    I have created a new issue to this bug.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Created a snippet to test based on your code.

    Thread Starter RoselleCelina

    (@rosellecelina)

    Thanks,

    I changed the code I added to your code snippet. It fixed the back and forward buttons but it’s done away with the infinite scroll feature. As you scroll down, the browser loads the next post and the previous post is gone (so you can’t scroll up to where you were last).

    Here’s the video I made. https://youtu.be/0UHVBxrPWYc

    Thanks ??

    Plugin Author Sébastien Dumont

    (@sebd86)

    Ah… it’s because we need to identify that the user actually pressed the back button and not constantly check the history state.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Updated the snippet. See if that works.

    Thread Starter RoselleCelina

    (@rosellecelina)

    Thanks.

    Now it adds #forward to the initial url. –not too big of a deal, but is telling.

    As you scroll down, you can see on the browser tab that something is loading, whereas before, it was hidden/seamless.

    When you reach the last post, all the other posts go away and you cannot scroll up anymore.

    See vid: https://youtu.be/RDGCIc3bfRI

    EDIT:
    Noticed that the video directly above didn’t really show the back and forward buttons functionality that well, so I made a newer video: https://youtu.be/cAJzTQzfd5Y

    • This reply was modified 7 years, 2 months ago by RoselleCelina. Reason: Better video
    Plugin Author Sébastien Dumont

    (@sebd86)

    I will have to research on it more but I have left some notes on the GitHub issue for now which you can follow.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Hi @rosellecelina

    I had a contributor work on this issue and has already submitted a pull request.

    https://github.com/AutoLoadNextPost/Auto-Load-Next-Post/pull/96

    I would really appreciate it if you could test it out and provide feedback.

    Thank you.

    Thread Starter RoselleCelina

    (@rosellecelina)

    Hi!

    I tested Lex’s code and here’s the video feedback:

    Thanks,
    Roselle

    P.S. BTW, I deactivated all other plugins before testing and switched themes just to make sure it wasn’t my theme.

    P.P.S. I had to change my YouTube channel. So the older videos aren’t up anymore. If you need to reference them, here are the new links to those videos:

    Plugin Author Sébastien Dumont

    (@sebd86)

    Did you have ALNP debug mode enabled? The Javascript change was applied to the debug version only.

    Plugin Author Sébastien Dumont

    (@sebd86)

    Demo site has the code in action and is working well.

    Thread Starter RoselleCelina

    (@rosellecelina)

    How do I turn on debug mode?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Back button doesn’t go to the top of the last post’ is closed to new replies.