@@ -57,21 +57,26 @@ new Vue({
57
57
[ 'getting-started' , 0 ] ,
58
58
[ 'select-primitive' , 0 ] ,
59
59
[ 'select-object' , 0 ] ,
60
- [ 'multiselect ' , 0 ] ,
60
+ [ 'select-search ' , 0 ] ,
61
61
[ 'multiselect-search' , 0 ] ,
62
62
[ 'ajax' , 0 ] ,
63
63
[ 'tagging' , 0 ] ,
64
64
[ 'vuex' , 0 ] ,
65
65
[ 'custom' , 0 ]
66
- ]
66
+ ] ,
67
+ scroll : 0
67
68
}
68
69
} ,
69
70
computed : {
70
71
isInvalid ( ) {
71
72
return this . isTouched && this . exampleValue6 . length === 0
72
73
} ,
73
74
currentPosition ( ) {
74
- return '#getting-started'
75
+ for ( let i = 1 ; i < this . navPositions . length - 1 ; i ++ ) {
76
+ if ( this . scroll >= this . navPositions [ i ] [ 1 ] && this . scroll < this . navPositions [ i + 1 ] [ 1 ] ) {
77
+ return this . navPositions [ i - 1 ] [ 0 ]
78
+ }
79
+ }
75
80
}
76
81
} ,
77
82
methods : {
@@ -145,26 +150,26 @@ new Vue({
145
150
onRemove ( option ) {
146
151
console . log ( '@remove: ' , option )
147
152
} ,
148
- adjustStickyNav ( ) {
153
+ adjustNav ( ) {
154
+ console . log ( 'adjust' )
155
+ this . scroll = window . scrollY
156
+ console . log ( this . scroll )
157
+ console . log ( this . currentPosition )
149
158
this . isNavSticky = window . scrollY > window . innerHeight
150
159
} ,
151
160
calculateNavPositions ( ) {
152
161
/*eslint-disable */
153
162
for ( let position of this . navPositions ) {
154
163
const elem = document . getElementById ( position [ 0 ] )
155
- if ( elem ) position [ 1 ] = elem . offsetTop
164
+ if ( elem ) position [ 1 ] = elem . offsetTop - 200
156
165
}
157
- console . log ( this . navPositions )
158
- this . navPositions . sort ( ( a , b ) => {
159
- return a [ 1 ] - b [ 1 ]
160
- } )
161
- console . log ( this . navPositions )
166
+ this . navPositions = this . navPositions . sort ( ( a , b ) => a [ 1 ] - b [ 1 ] )
162
167
/*eslint-enable */
163
168
}
164
169
} ,
165
170
ready ( ) {
166
- this . adjustStickyNav ( )
167
- window . addEventListener ( 'scroll' , throttle ( this . adjustStickyNav , 50 ) )
171
+ this . adjustNav ( )
172
+ window . addEventListener ( 'scroll' , throttle ( this . adjustNav , 50 ) )
168
173
this . calculateNavPositions ( )
169
174
}
170
175
} )
0 commit comments