Force Scrollspy to update with new options
See original GitHub issueI 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:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
@jdvivar Is this demo helpful?