Fix header indicator
This commit is contained in:
parent
afd7f5fabe
commit
314a4474f6
@ -81,6 +81,13 @@ const filterByKeyword = (list, keyword = '', languages, nameLocalizer) => {
|
|||||||
return orderedEmojiList.flat()
|
return orderedEmojiList.flat()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getOffset = (elem) => {
|
||||||
|
const style = elem.style.transform
|
||||||
|
const res = /translateY\((\d+)px\)/.exec(style)
|
||||||
|
if (!res) { return 0 }
|
||||||
|
return res[1]
|
||||||
|
}
|
||||||
|
|
||||||
const EmojiPicker = {
|
const EmojiPicker = {
|
||||||
props: {
|
props: {
|
||||||
enableStickerPicker: {
|
enableStickerPicker: {
|
||||||
@ -144,12 +151,25 @@ const EmojiPicker = {
|
|||||||
this.$emit('emoji', { insertion: value, keepOpen: this.keepOpen })
|
this.$emit('emoji', { insertion: value, keepOpen: this.keepOpen })
|
||||||
},
|
},
|
||||||
onScroll (startIndex, endIndex, visibleStartIndex, visibleEndIndex) {
|
onScroll (startIndex, endIndex, visibleStartIndex, visibleEndIndex) {
|
||||||
|
console.log('onScroll', startIndex, endIndex, visibleStartIndex, visibleEndIndex)
|
||||||
const current = this.filteredEmojiGroups[visibleStartIndex].id
|
const current = this.filteredEmojiGroups[visibleStartIndex].id
|
||||||
this.scrolledGroup(current)
|
const target = this.$refs['emoji-groups'].$el
|
||||||
|
this.scrolledGroup(target, current, visibleStartIndex, visibleEndIndex)
|
||||||
},
|
},
|
||||||
scrolledGroup (groupId) {
|
scrolledGroup (target, groupId, start, end) {
|
||||||
this.activeGroup = groupId
|
const top = target.scrollTop + 5
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.filteredEmojiGroups.slice(start, end + 1).forEach(group => {
|
||||||
|
const ref = this.groupRefs['group-' + group.id]
|
||||||
|
if (!ref) { return }
|
||||||
|
const elem = ref.$el.parentElement
|
||||||
|
if (!elem) { return }
|
||||||
|
if (elem && getOffset(elem) <= top) {
|
||||||
|
this.activeGroup = group.id
|
||||||
|
}
|
||||||
|
})
|
||||||
this.scrollHeader()
|
this.scrollHeader()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
scrollHeader () {
|
scrollHeader () {
|
||||||
// Scroll the active tab's header into view
|
// Scroll the active tab's header into view
|
||||||
|
@ -80,10 +80,12 @@
|
|||||||
:class="groupsScrolledClass"
|
:class="groupsScrolledClass"
|
||||||
:min-item-size="minItemSize"
|
:min-item-size="minItemSize"
|
||||||
:items="filteredEmojiGroups"
|
:items="filteredEmojiGroups"
|
||||||
|
:emit-update="true"
|
||||||
@update="onScroll"
|
@update="onScroll"
|
||||||
>
|
>
|
||||||
<template #default="{ item: group, index, active }">
|
<template #default="{ item: group, index, active }">
|
||||||
<DynamicScrollerItem
|
<DynamicScrollerItem
|
||||||
|
:ref="setGroupRef('group-' + group.id)"
|
||||||
:item="group"
|
:item="group"
|
||||||
:active="active"
|
:active="active"
|
||||||
:data-index="index"
|
:data-index="index"
|
||||||
|
Loading…
Reference in New Issue
Block a user