• Resolved Chris

    (@renaissancedesign)


    If a link to a different page contains a fragment identifier that’s the same as an ID on the current page the plugin will scroll to the targeted element instead of allowing the user to navigate to the other page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Just for our visual sake, and to see if we can offer any help with this, can you provide us with a couple links for this so we can see what you’re seeing?

    Thread Starter Chris

    (@renaissancedesign)

    I’m afraid I’ve already removed the plugin, it was causing issues on a live site.

    Easy enough to reproduce though, create two pages, each with #hash1, #hash2 and #hash3 and populate a menu with absolute URLs to them. The problem is on lines 30-39 of assets/js/hash-link-scroll-offset.js – a link on /page1 to /page2#hash1 will scroll to /page1#hash1 if #hash1 exists on /page1.

    Should be able to fix it by comparing this.pathname with location.pathname before calling app.scrollToHash.

    • This reply was modified 6 years, 3 months ago by Chris. Reason: Clarity
    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Understandable with the need to remove if it was causing issues with things. I’d prefer we aren’t the cause of headaches longer than necessary ??

    Regarding the original issue at hand, thanks for the bits above to use to recreate. At the same time, it’s a question of do we want to offer it across pages, or is it simply meant to be all within the current page.

    Nonetheless, thanks for the feedback and conversation.

    Thread Starter Chris

    (@renaissancedesign)

    If you do decide to fix it this should do the trick on line 34:

    if ( ! $( app.hash ) )

    change to:

    if ( ! $( app.hash ) || location.pathname.replace(/^\//,'') != this.pathname.replace(/^\//,'') )

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    For anyone wanting to keep an eye on this, or if you want to implement yourself.

    https://github.com/WebDevStudios/Hash-Link-Scroll-Offset/issues/18

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Breaks between pages’ is closed to new replies.