Upload: fix backgroundPosition

This commit is contained in:
Alex Gleason 2022-05-30 14:53:50 -05:00
parent 0051fd8eec
commit 887302d642
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 3 additions and 3 deletions

View File

@ -130,8 +130,8 @@ const Upload: React.FC<IUpload> = (props) => {
const description = dirtyDescription || (dirtyDescription !== '' && props.media.get('description')) || ''; const description = dirtyDescription || (dirtyDescription !== '' && props.media.get('description')) || '';
const focusX = props.media.getIn(['meta', 'focus', 'x']) as number | undefined; const focusX = props.media.getIn(['meta', 'focus', 'x']) as number | undefined;
const focusY = props.media.getIn(['meta', 'focus', 'y']) as number | undefined; const focusY = props.media.getIn(['meta', 'focus', 'y']) as number | undefined;
const x = focusX ? ((focusX / 2) + .5) * 100 : 0; const x = focusX ? ((focusX / 2) + .5) * 100 : undefined;
const y = focusY ? ((focusY / -2) + .5) * 100 : 0; const y = focusY ? ((focusY / -2) + .5) * 100 : undefined;
const mediaType = props.media.get('type'); const mediaType = props.media.get('type');
const mimeType = props.media.getIn(['pleroma', 'mime_type']) as string | undefined; const mimeType = props.media.getIn(['pleroma', 'mime_type']) as string | undefined;
@ -152,7 +152,7 @@ const Upload: React.FC<IUpload> = (props) => {
style={{ style={{
transform: `scale(${scale})`, transform: `scale(${scale})`,
backgroundImage: mediaType === 'image' ? `url(${props.media.get('preview_url')})` : undefined, backgroundImage: mediaType === 'image' ? `url(${props.media.get('preview_url')})` : undefined,
backgroundPosition: `${x}% ${y}%` }} backgroundPosition: typeof x === 'number' && typeof y === 'number' ? `${x}% ${y}%` : undefined }}
> >
<div className={classNames('compose-form__upload__actions', { active })}> <div className={classNames('compose-form__upload__actions', { active })}>
<IconButton <IconButton