aboutsummaryrefslogtreecommitdiff
path: root/src/components/emoji_picker/emoji_picker.js
diff options
context:
space:
mode:
authorTusooa Zhu <tusooa@kazv.moe>2022-01-08 02:17:59 -0500
committerTusooa Zhu <tusooa@kazv.moe>2022-09-18 13:19:53 -0400
commit38861fc6cc1e30c6ef3c429db222a303ed1c321d (patch)
treee15643c008ecc2f64aa5f223be13d3e7ab1031b6 /src/components/emoji_picker/emoji_picker.js
parentd9e428ebab3ea575e622fadd47150c39684648aa (diff)
Scroll active tab header into view in emoji picker
Diffstat (limited to 'src/components/emoji_picker/emoji_picker.js')
-rw-r--r--src/components/emoji_picker/emoji_picker.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js
index 315364d5..26c767ac 100644
--- a/src/components/emoji_picker/emoji_picker.js
+++ b/src/components/emoji_picker/emoji_picker.js
@@ -87,8 +87,26 @@ const EmojiPicker = {
this.activeGroup = group.id
}
})
+ this.scrollHeader()
})
},
+ scrollHeader () {
+ // Scroll the active tab's header into view
+ const headerRef = this.$refs['group-header-' + this.activeGroup][0]
+ const left = headerRef.offsetLeft
+ const right = left + headerRef.offsetWidth
+ const headerCont = this.$refs.header
+ const currentScroll = headerCont.scrollLeft
+ const currentScrollRight = currentScroll + headerCont.clientWidth
+ const setScroll = s => { headerCont.scrollLeft = s }
+
+ const margin = 7 // .emoji-tabs-item: padding
+ if (left - margin < currentScroll) {
+ setScroll(left - margin)
+ } else if (right + margin > currentScrollRight) {
+ setScroll(right + margin - headerCont.clientWidth)
+ }
+ },
highlight (key) {
const ref = this.$refs['group-' + key]
const top = ref.offsetTop