diff options
author | ThibG <thib@sitedethib.com> | 2021-01-31 21:25:31 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-02-03 17:16:22 +0100 |
commit | e1fa06c459a28a575d0da540432c61b702e99cdd (patch) | |
tree | d6d5e7b07e24248da5c237726dca874727c10b38 /app/javascript/flavours/glitch/features/directory/components | |
parent | 4d40685850ea211ecc0d0d0735b5a4c084333858 (diff) |
[Glitch] Change custom emoji to be animated when hovering container
Port 3efa0c54b6656fba189baab0857e60c0bc4f3c7d to glitch-soc Co-authored-by: Claire <claire.github-309c@sitedethib.com> Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/features/directory/components')
-rw-r--r-- | app/javascript/flavours/glitch/features/directory/components/account_card.js | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/app/javascript/flavours/glitch/features/directory/components/account_card.js b/app/javascript/flavours/glitch/features/directory/components/account_card.js index 5f952b382..9fe84c10b 100644 --- a/app/javascript/flavours/glitch/features/directory/components/account_card.js +++ b/app/javascript/flavours/glitch/features/directory/components/account_card.js @@ -102,42 +102,31 @@ class AccountCard extends ImmutablePureComponent { onMute: PropTypes.func.isRequired, }; - _updateEmojis() { - const node = this.node; - - if (!node || autoPlayGif) { + handleMouseEnter = ({ currentTarget }) => { + if (autoPlayGif) { return; } - const emojis = node.querySelectorAll('.custom-emoji'); + const emojis = currentTarget.querySelectorAll('.custom-emoji'); for (var i = 0; i < emojis.length; i++) { let emoji = emojis[i]; - if (emoji.classList.contains('status-emoji')) { - continue; - } - emoji.classList.add('status-emoji'); - - emoji.addEventListener('mouseenter', this.handleEmojiMouseEnter, false); - emoji.addEventListener('mouseleave', this.handleEmojiMouseLeave, false); + emoji.src = emoji.getAttribute('data-original'); } } - componentDidMount() { - this._updateEmojis(); - } - - componentDidUpdate() { - this._updateEmojis(); - } + handleMouseLeave = ({ currentTarget }) => { + if (autoPlayGif) { + return; + } - handleEmojiMouseEnter = ({ target }) => { - target.src = target.getAttribute('data-original'); - }; + const emojis = currentTarget.querySelectorAll('.custom-emoji'); - handleEmojiMouseLeave = ({ target }) => { - target.src = target.getAttribute('data-static'); - }; + for (var i = 0; i < emojis.length; i++) { + let emoji = emojis[i]; + emoji.src = emoji.getAttribute('data-static'); + } + } handleFollow = () => { this.props.onFollow(this.props.account); @@ -151,10 +140,6 @@ class AccountCard extends ImmutablePureComponent { this.props.onMute(this.props.account); }; - setRef = (c) => { - this.node = c; - }; - render() { const { account, intl } = this.props; @@ -239,7 +224,7 @@ class AccountCard extends ImmutablePureComponent { </div> </div> - <div className='directory__card__extra' ref={this.setRef}> + <div className='directory__card__extra' onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}> <div className='account__header__content translate' dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }} |