• Resolved tobiasmalikowski

    (@tobiasmalikowski)


    Hi Darren,

    got everything working with the Previous Post Addon except one thing and it looks like i need your help to solve it.

    I have a menu on my page which uses a url hash parameter. So if you click a link on the menu “#menu-open” is added to the url. But then your plugin kicks-in, resets the url of <div class=”alm-reveal alm-previous-post post-2404″ data-url=”https://example.com/news/post-1/&#8221;> and let the window jump to this div.

    I can live with the reset of the url, but not with the jump. The jump will annoy users which want to use the menu on a news article, cause the menu opens but the window jumps to the post and users have to scroll up again.

    Any ideas how to tackle this?

    Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Can you turn off the Enable Window scrolling in the ALM settings for Previous post?

    Thread Starter tobiasmalikowski

    (@tobiasmalikowski)

    Turned it off, so if I load a new post the window is not scrolling to the new post. But the bug remains.

    If I open my menu, wich adds a #menu-open to the url the window jumps. But somehow the hash gets removed instantly and it looks like this is causing the jump. Could this come from your plugin? Cause the menu works on every page except my news pages, where I’m also using your plugin.

    Update #1:
    Ok now I now that the following of your code in alm-previous-post.js (line 68) removes my #menu-open url hash. But even when i comment that line out the jump still happens.

    if(url !== permalink){
      almPreviousPost.setURL(id, permalink, title);
    }
    Thread Starter tobiasmalikowski

    (@tobiasmalikowski)

    Update #2:
    Ok now I now that the following code in alm-previous-post.js (line 143) is causing the page jump.

    var top = $('.alm-reveal.alm-previous-post.post-'+id).offset().top - almPreviousPost.offset + 5;
    $('html, body').animate({ scrollTop: top +'px' }, 1, function(){
      almPreviousPost.popstate = false;
    });

    Since this code gets executed on “popstate” it looks like that my script fires an “popstate” when I add that hash to the url.

    Thread Starter tobiasmalikowski

    (@tobiasmalikowski)

    Hi Darren,

    I was able to solve this by changing my menu code to not fire any popstates.
    So from my perspective this is resolved.

    However I suggest you to think about these parts of code.

    Destroys the basic use of internal anchor links cause it always checks the url on a scroll event and removes added hashes! Thats not very nice ??

    if(url !== permalink){
      almPreviousPost.setURL(id, permalink, title);
    }

    Shouldn’t this code also be disabled if the user decided to set the “Scroll to Post” setting to false?

    var top = $('.alm-reveal.alm-previous-post.post-'+id).offset().top - almPreviousPost.offset + 5;
    $('html, body').animate({ scrollTop: top +'px' }, 1, function(){
      almPreviousPost.popstate = false;
    });

    If you want you can mark this as resolved (just leaving it open to make sure you read this last comment).

    Plugin Author Darren Cooney

    (@dcooney)

    I guess so, but what’s the point in clicking the back/fwd button if you don’t move to that post?

    Thread Starter tobiasmalikowski

    (@tobiasmalikowski)

    Just wanted to mention, maybe there is a better solution, but I have no suggestion at the moment. If you want make a note or just leave it as it is ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Previous Post Addon and Url Parameters’ is closed to new replies.