eddiemf / vue-scrollactive

Lightweight and simple to use vue component that highlights menu items as you scroll the page, also scrolling to target section when clicked.
MIT License
542 stars 70 forks source link

how to prevent replacing the URL with tag #84

Open mesqueeb opened 3 years ago

mesqueeb commented 3 years ago

this is what happens:

2020-10-08 09 44 18

eg. me.me/background when a link is clicked: me.me/background#about-me

instead of background being replaced... right?

mesqueeb commented 3 years ago

I was able to "workaround" this by doing :modifyUrl="false" and then I added a "click" event on each <a> element on which I execute:

    /**
     * @param {MouseEvent} event
     */
    setUrlHash(event) {
      const activeTocHash = event.srcElement.getAttribute('href')
      const activeTocId = activeTocHash.replace('#', '')

      setTimeout(() => {
        location.hash = activeTocId
      }, SCROLL_DURATION)
    },
Sogl commented 1 year ago

:modifyUrl="false" doesn't have any effect for me