diff options
Diffstat (limited to 'app/javascript/mastodon/components/avatar.js')
-rw-r--r-- | app/javascript/mastodon/components/avatar.js | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/app/javascript/mastodon/components/avatar.js b/app/javascript/mastodon/components/avatar.js index 76c561c91..90c84f32a 100644 --- a/app/javascript/mastodon/components/avatar.js +++ b/app/javascript/mastodon/components/avatar.js @@ -3,23 +3,31 @@ import PropTypes from 'prop-types'; class Avatar extends React.PureComponent { - constructor (props, context) { - super(props, context); - - this.state = { - hovering: false - }; - - this.handleMouseEnter = this.handleMouseEnter.bind(this); - this.handleMouseLeave = this.handleMouseLeave.bind(this); - } - - handleMouseEnter () { + static propTypes = { + src: PropTypes.string.isRequired, + staticSrc: PropTypes.string, + size: PropTypes.number.isRequired, + style: PropTypes.object, + animate: PropTypes.bool, + inline: PropTypes.bool + }; + + static defaultProps = { + animate: false, + size: 20, + inline: false + }; + + state = { + hovering: true + }; + + handleMouseEnter = () => { if (this.props.animate) return; this.setState({ hovering: true }); } - handleMouseLeave () { + handleMouseLeave = () => { if (this.props.animate) return; this.setState({ hovering: false }); } @@ -59,19 +67,4 @@ class Avatar extends React.PureComponent { } -Avatar.propTypes = { - src: PropTypes.string.isRequired, - staticSrc: PropTypes.string, - size: PropTypes.number.isRequired, - style: PropTypes.object, - animate: PropTypes.bool, - inline: PropTypes.bool -}; - -Avatar.defaultProps = { - animate: false, - size: 20, - inline: false -}; - export default Avatar; |