Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vue on page link or anchor

// scroll to element using quasar library

// uses example; scrollToElement(this.$route.hash)
// uses example; scrollToElement('#cafe-menu')


import { scroll } from 'quasar'
const { getScrollTarget, setScrollPosition } = scroll

    scrollToElement (id) {
      if (id && id !== '') {
        let el = document.querySelector(id)
        if (el) {
          const target = getScrollTarget(el)
          const offset = el.offsetTop
          const duration = 1000
          setScrollPosition(target, offset, duration)
        }
      }
    },
 
PREVIOUS NEXT
Tagged: #vue #page #link #anchor
ADD COMMENT
Topic
Name
5+5 =