FIX: keep scroll position when adding first recent emoji

This commit is contained in:
Joffrey JAFFEUX 2017-07-21 20:57:17 +02:00
parent cdefb58018
commit 8c17596aa5
1 changed files with 5 additions and 0 deletions

View File

@ -86,6 +86,7 @@ export default Ember.Component.extend({
@observes("recentEmojis") @observes("recentEmojis")
recentEmojisChanged() { recentEmojisChanged() {
const previousScrollTop = $list.scrollTop();
const $recentSection = $list.find(".section[data-section='recent']"); const $recentSection = $list.find(".section[data-section='recent']");
const $recentSectionGroup = $recentSection.find(".section-group"); const $recentSectionGroup = $recentSection.find(".section-group");
const $recentCategory = $picker.find(".category-icon button[data-section='recent']").parent(); const $recentCategory = $picker.find(".category-icon button[data-section='recent']").parent();
@ -105,6 +106,10 @@ export default Ember.Component.extend({
const template = findRawTemplate("emoji-picker-recent")({recentEmojis}); const template = findRawTemplate("emoji-picker-recent")({recentEmojis});
$recentSectionGroup.html(template); $recentSectionGroup.html(template);
this._bindHover($recentSectionGroup); this._bindHover($recentSectionGroup);
if(this.get("recentEmojis").length === 1) {
$list.scrollTop(previousScrollTop + $recentSection.outerHeight());
}
}, },
close() { close() {