How to use @pluginjs/scroll-spy - 2 common examples

To help you get started, we’ve selected a few @pluginjs/scroll-spy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pluginjs / pluginjs / modules / scroll-spy / samples / src / sections / default / index.js View on Github external
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)
  }
})
github pluginjs / pluginjs / modules / section-scroll / src / type / scroll.js View on Github external
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()
          }
        }
      }
    })
  }

@pluginjs/scroll-spy

A flexible modern scroll-spy js plugin.

GPL-3.0
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis

Popular @pluginjs/scroll-spy functions

Similar packages