Skip to content

Commit 3937bb3

Browse files
committed
Added auto scroll / Removed map controls
1 parent 91aa613 commit 3937bb3

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

components/Map/index.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export default {
2929
zoom: 1.6
3030
})
3131
32-
map.addControl(new mapboxgl.NavigationControl())
33-
3432
const addLayers = map => {
3533
map.addSource('covid', {
3634
type: 'geojson',
@@ -183,13 +181,6 @@ export default {
183181
width: 100%;
184182
height: 100%;
185183
186-
.mapboxgl-ctrl-top-right {
187-
.mapboxgl-ctrl {
188-
margin-top: 24px;
189-
margin-right: 24px;
190-
}
191-
}
192-
193184
.mapboxgl-ctrl-bottom-left {
194185
.mapboxgl-ctrl {
195186
margin: 0 0 16px 24px;

components/Search/index.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</svg>
4848
</button>
4949
</div>
50-
<ul class="dropdown-menu">
50+
<ul ref="dropdown" class="dropdown-menu">
5151
<li
5252
v-for="(suggestion, index) in matches"
5353
:key="index"
@@ -132,10 +132,16 @@ export default {
132132
}
133133
},
134134
up() {
135-
if (this.current > 0) this.current--
135+
if (this.current > 0) {
136+
this.current--
137+
this.onKeyPress()
138+
}
136139
},
137140
down() {
138-
if (this.current < this.matches.length - 1) this.current++
141+
if (this.current < this.matches.length - 1) {
142+
this.current++
143+
this.onKeyPress()
144+
}
139145
},
140146
isActive(index) {
141147
return index === this.current
@@ -177,7 +183,6 @@ export default {
177183
value: this.locationId
178184
})
179185
})
180-
181186
},
182187
onFocus(e) {
183188
if (e.target.value) {
@@ -197,6 +202,13 @@ export default {
197202
event_label: 'province change',
198203
value: this.locationId
199204
})
205+
},
206+
onKeyPress() {
207+
this.$nextTick(_ => {
208+
const parentHeight = parseFloat(getComputedStyle(this.$refs.dropdown, null).height.replace('px', ''))
209+
this.$refs.dropdown.scrollTop = 0
210+
this.$refs.dropdown.scrollTop = (document.querySelector('li.is-active').offsetTop + 40) - parentHeight
211+
})
200212
}
201213
}
202214
}

0 commit comments

Comments
 (0)