Skip to content

Commit

Permalink
Merge pull request #100 from huguangju/dev
Browse files Browse the repository at this point in the history
feat: 选择图标时自动滚动到已选图标位置
  • Loading branch information
JakHuang authored Apr 25, 2021
2 parents 0aeed02 + 11b54e8 commit eb29908
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/views/index/IconsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
clearable
/>
</div>
<ul class="icon-ul">
<ul ref="iconWrap" class="icon-ul">
<li
v-for="icon in iconList"
:key="icon"
Expand Down Expand Up @@ -61,12 +61,21 @@ export default {
onOpen() {
this.active = this.current
this.key = ''
this.scrollToActive()
},
onClose() {},
onSelect(icon) {
this.active = icon
this.$emit('select', icon)
this.$emit('update:visible', false)
},
scrollToActive() {
this.$nextTick(() => {
const $activeItem = this.active
? document.getElementsByClassName('active-item')[0]
: this.$refs.iconWrap.childNodes[0]
$activeItem && $activeItem.scrollIntoView && $activeItem.scrollIntoView()
})
}
}
}
Expand Down

0 comments on commit eb29908

Please sign in to comment.