question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Force Scrollspy to update with new options

See original GitHub issue

I haven’t found a way to force Scrollspy to update with new options. My offset for instance, can change. I have the value saved in a store’s state. With this implementation, when the value of the offset changes in the store, it keeps being the original one set when calling Vue.use(Scrollspy, ...) for the first time. What am I missing?

<template>
  <nav class="navigation no-print">
    <ul
      v-scroll-spy-active
      v-scroll-spy-link>
      <li
        v-for="section in sections"
        :key="section.id">
        <a :href="`#${section.id}`">{{ section.heading }}</a>
      </li>
    </ul>
  </nav>

</template>

<script>
// Scrollspy
import Scrollspy, { Easing } from 'vue2-scrollspy'
import Vue from 'vue'
import store from '../store'

Vue.use(Scrollspy, {
  easing: Easing.Cubic.InOut,
  offset: store.state.scrollSpyOffset
})

export default {
  name: 'Navigation',
  props: {
    sections: {
      type: Array,
      default: () => []
    }
  }
}
</script>

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jdvivarcommented, Sep 21, 2018

@ibufu it works in your demo! Thanks so much for the demo! I used similar code and didn’t work for me, but I’ll reconsider.

0reactions
ibufucommented, Sep 14, 2018

@jdvivar Is this demo helpful?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I set the offset for ScrollSpy in Bootstrap?
Bootstrap uses offset to resolve spying only, not scrolling. This means that scrolling to the proper place is up to you. Try this,...
Read more >
Scrollspy · Bootstrap v5.0
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport.
Read more >
Bootstrap Scrollspy -- Tutorials with advanced examples
Automatically update Bootstrap navigation or list group components based on scroll position to indicate which link is currently active in the viewport. ·...
Read more >
Scrollspy: highlights wrong navigation item when a page is ...
Update I was able to fix my problem by calling ScrollSpy explicitly before the hotfix. window.onload = function () { new bootstrap.
Read more >
Scrollspy · Boosted v5.0
Scrollspy has a few requirements to function properly: ... When successfully implemented, your nav or list group will update accordingly, moving the .active...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found