diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-03-01 02:48:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-01 02:48:44 +0100 |
commit | 51310125051a75ef7af4e8ffc8b6532c151e96b6 (patch) | |
tree | e8edf2d2ba432913bcb9ff1f12bd6cfd1f30f489 /app/javascript/mastodon/features/account_gallery/components/media_item.js | |
parent | 473a69ab18c17551c99dc0806aa948b7edaf7cb0 (diff) |
Add "Toots/Toots with replies/Media" tab below profile header (#6572)
* Add "Toots/Toots with replies/Media" tab below profile header * Add focal point display to account gallery timeline * Fix visual glitch of standalone GIFV
Diffstat (limited to 'app/javascript/mastodon/features/account_gallery/components/media_item.js')
-rw-r--r-- | app/javascript/mastodon/features/account_gallery/components/media_item.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/javascript/mastodon/features/account_gallery/components/media_item.js b/app/javascript/mastodon/features/account_gallery/components/media_item.js index dda3d4e37..59c805c38 100644 --- a/app/javascript/mastodon/features/account_gallery/components/media_item.js +++ b/app/javascript/mastodon/features/account_gallery/components/media_item.js @@ -12,24 +12,26 @@ export default class MediaItem extends ImmutablePureComponent { render () { const { media } = this.props; const status = media.get('status'); + const focusX = media.getIn(['meta', 'focus', 'x']); + const focusY = media.getIn(['meta', 'focus', 'y']); + const x = ((focusX / 2) + .5) * 100; + const y = ((focusY / -2) + .5) * 100; + const style = {}; - let content, style; + let content; if (media.get('type') === 'gifv') { content = <span className='media-gallery__gifv__label'>GIF</span>; } if (!status.get('sensitive')) { - style = { backgroundImage: `url(${media.get('preview_url')})` }; + style.backgroundImage = `url(${media.get('preview_url')})`; + style.backgroundPosition = `${x}% ${y}%`; } return ( <div className='account-gallery__item'> - <Permalink - to={`/statuses/${status.get('id')}`} - href={status.get('url')} - style={style} - > + <Permalink to={`/statuses/${status.get('id')}`} href={status.get('url')} style={style}> {content} </Permalink> </div> |