diff options
author | ThibG <thib@sitedethib.com> | 2021-01-31 21:25:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 21:25:31 +0100 |
commit | 3efa0c54b6656fba189baab0857e60c0bc4f3c7d (patch) | |
tree | 4842ed3f889d2a94e3f7bbd834748dce18380bf1 /app/javascript/mastodon/features/account/components | |
parent | 7ab53f221a3d66a0bbc94b36d847b7bcf62fbd16 (diff) |
Change custom emoji to be animated when hovering container (#15637)
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/mastodon/features/account/components')
-rw-r--r-- | app/javascript/mastodon/features/account/components/header.js | 43 |
1 files changed, 14 insertions, 29 deletions
diff --git a/app/javascript/mastodon/features/account/components/header.js b/app/javascript/mastodon/features/account/components/header.js index 2087fc3b8..8e49486bd 100644 --- a/app/javascript/mastodon/features/account/components/header.js +++ b/app/javascript/mastodon/features/account/components/header.js @@ -96,45 +96,30 @@ class Header extends ImmutablePureComponent { return !location.pathname.match(/\/(followers|following)\/?$/); } - _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(); - } - - handleEmojiMouseEnter = ({ target }) => { - target.src = target.getAttribute('data-original'); - } + handleMouseLeave = ({ currentTarget }) => { + if (autoPlayGif) { + return; + } - handleEmojiMouseLeave = ({ target }) => { - target.src = target.getAttribute('data-static'); - } + const emojis = currentTarget.querySelectorAll('.custom-emoji'); - setRef = (c) => { - this.node = c; + for (var i = 0; i < emojis.length; i++) { + let emoji = emojis[i]; + emoji.src = emoji.getAttribute('data-static'); + } } render () { @@ -276,7 +261,7 @@ class Header extends ImmutablePureComponent { } return ( - <div className={classNames('account__header', { inactive: !!account.get('moved') })} ref={this.setRef}> + <div className={classNames('account__header', { inactive: !!account.get('moved') })} onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}> <div className='account__header__image'> <div className='account__header__info'> {!suspended && info} |