better scroll/touch handling on mobiles

This commit is contained in:
Joffrey JAFFEUX 2017-07-19 14:05:16 +02:00
parent b3454b535f
commit 33c1ce8d55
1 changed files with 20 additions and 4 deletions

View File

@ -239,9 +239,8 @@ export default Ember.Component.extend({
},
_bindEmojiClick($emojisContainer) {
// $emojisContainer.off("click", "a");
$emojisContainer.on("click", "a", e => {
const code = this._codeForEmojiLink($(e.currentTarget));
let handler = (event) => {
const code = this._codeForEmojiLink($(event.currentTarget));
this._trackEmojiUsage(code);
this.sendAction("emojiSelected", code);
@ -251,7 +250,24 @@ export default Ember.Component.extend({
}
return false;
});
};
if(this.site.isMobileDevice) {
const self = this;
$emojisContainer
.off("touchstart")
.on("touchstart", "a", (touchStartEvent) => {
const $this = $(touchStartEvent.currentTarget);
$this.on('touchend', (touchEndEvent) => {
handler.bind(self)(touchEndEvent);
$this.off('touchend');
});
$this.on('touchmove', () => $this.off('touchend') );
});
} else {
$emojisContainer.on("click", "a", e => handler.bind(this)(e) );
}
},
_bindSectionsScroll() {