Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { query } from '@pluginjs/dom'
import ScrollSpy from '@pluginjs/scroll-spy'
const element = query('#navbar')
ScrollSpy.of(element, {
selector: 'a',
activeClass: 'active',
onReady() {
console.info('ready')
},
onChange(value) {
console.info('change', value)
}
})
bind() {
const dots = this.instance.Dots.dots
ScrollSpy.of(dots, {
selector: 'li',
hrefFrom: this.instance.options.dots.valueFrom || 'href',
disableRootMargin: true,
rootMargin: '-50% 0px -50% 0px',
onChange: id => {
if (!this.instance.is('moveing') && this.instance.is('initialized')) {
this.instance.trigger(EVENTS.CHANGE, id)
this.instance.Dots.setActive(id)
this.instance.currIndex = this.instance.getIndexById(id)
if (this.options.changeHash) {
this.instance.history.changeHash()
}
}
}
})
}