Browse Source

Autocomplete helper: fix scrolling to start

master
morethanwords 4 years ago
parent
commit
ce033077f7
  1. 14
      src/components/chat/emojiHelper.ts
  2. 10
      src/components/chat/stickersHelper.ts

14
src/components/chat/emojiHelper.ts

@ -21,10 +21,20 @@ export default class EmojiHelper extends AutocompleteHelper {
this.container.append(this.list); this.container.append(this.list);
this.scrollable = new ScrollableX(this.container); this.scrollable = new ScrollableX(this.container);
this.addEventListener('visible', () => {
setTimeout(() => { // it is not rendered yet
this.scrollable.container.scrollLeft = 0;
}, 0);
});
} }
public renderEmojis(emojis: string[]) { public renderEmojis(emojis: string[]) {
if(this.init) { if(this.init) {
if(!emojis.length) {
return;
}
this.init(); this.init();
this.init = null; this.init = null;
} }
@ -36,10 +46,6 @@ export default class EmojiHelper extends AutocompleteHelper {
}); });
} }
if(!this.hidden) {
this.scrollable.container.scrollLeft = 0;
}
this.toggle(!emojis.length); this.toggle(!emojis.length);
} }
} }

10
src/components/chat/stickersHelper.ts

@ -25,6 +25,12 @@ export default class StickersHelper extends AutocompleteHelper {
}, 'ArrowUp'); }, 'ArrowUp');
this.container.classList.add('stickers-helper'); this.container.classList.add('stickers-helper');
this.addEventListener('visible', () => {
setTimeout(() => { // it is not rendered yet
this.scrollable.container.scrollTop = 0;
}, 0);
});
} }
public checkEmoticon(emoticon: string) { public checkEmoticon(emoticon: string) {
@ -75,10 +81,6 @@ export default class StickersHelper extends AutocompleteHelper {
} }
ready.then(() => { ready.then(() => {
if(!this.hidden) {
this.scrollable.container.scrollTop = 0;
}
this.list.replaceWith(container); this.list.replaceWith(container);
this.list = container; this.list = container;

Loading…
Cancel
Save