@@ -35,6 +35,7 @@ export default function install (Vue, options) {
3535
3636 options = Object . assign ( {
3737 allowNoActive : false ,
38+ sectionSelector : null ,
3839 data : null ,
3940 offset : 0 ,
4041 time : 500 ,
@@ -86,14 +87,15 @@ export default function install (Vue, options) {
8687 return 'default'
8788 }
8889
89- function initScrollSections ( el , selector ) {
90+ function initScrollSections ( el , sectionSelector ) {
9091 const id = scrollSpyId ( el )
91- const idScrollSections = findElements ( el , selector )
92+ const scrollSpyContext = el [ scrollSpyContext ]
93+ const idScrollSections = findElements ( el , sectionSelector )
9294 scrollSpySections [ id ] = idScrollSections
9395
9496 if ( idScrollSections [ 0 ] && idScrollSections [ 0 ] . offsetParent !== el ) {
95- el [ scrollSpyContext ] . eventEl = window
96- el [ scrollSpyContext ] . scrollEl = bodyScrollEl
97+ scrollSpyContext . eventEl = window
98+ scrollSpyContext . scrollEl = bodyScrollEl
9799 }
98100 }
99101
@@ -203,18 +205,17 @@ export default function install (Vue, options) {
203205 delete currentIndex [ id ]
204206 } ,
205207 inserted : function ( el ) {
206- initScrollSections ( el )
208+ const { eventEl , onScroll , options : { sectionSelector } } = el [ scrollSpyContext ]
207209
208- const { eventEl , onScroll } = el [ scrollSpyContext ]
210+ initScrollSections ( el , sectionSelector )
209211 eventEl . addEventListener ( 'scroll' , onScroll )
210212
211213 onScroll ( )
212214 } ,
213215 componentUpdated : function ( el ) {
214- initScrollSections ( el )
215-
216- const { onScroll} = el [ scrollSpyContext ]
216+ const { onScroll, options : { sectionSelector} } = el [ scrollSpyContext ]
217217
218+ initScrollSections ( el , sectionSelector )
218219 onScroll ( )
219220 } ,
220221 unbind : function ( el ) {
0 commit comments