diff --git a/bin/svgs.js b/bin/svgs.js index 933d58fb..1f046974 100644 --- a/bin/svgs.js +++ b/bin/svgs.js @@ -52,5 +52,6 @@ module.exports = [ { id: 'fa-clock', src: 'src/thirdparty/font-awesome-svg-png/white/svg/clock-o.svg' }, { id: 'fa-refresh', src: 'src/thirdparty/font-awesome-svg-png/white/svg/refresh.svg' }, { id: 'fa-plus', src: 'src/thirdparty/font-awesome-svg-png/white/svg/plus.svg' }, - { id: 'fa-info-circle', src: 'src/thirdparty/font-awesome-svg-png/white/svg/info-circle.svg' } + { id: 'fa-info-circle', src: 'src/thirdparty/font-awesome-svg-png/white/svg/info-circle.svg' }, + { id: 'fa-crosshairs', src: 'src/thirdparty/font-awesome-svg-png/white/svg/crosshairs.svg' } ] diff --git a/package.json b/package.json index f3f484bb..f458a11e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@babel/core": "^7.5.0", "@gamestdio/websocket": "^0.3.2", "@webcomponents/custom-elements": "^1.2.4", + "@wessberg/pointer-events": "^1.0.9", "babel-loader": "^8.0.6", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "cheerio": "^1.0.0-rc.2", diff --git a/src/routes/_actions/compose.js b/src/routes/_actions/compose.js index a97b8745..0dcd7fcb 100644 --- a/src/routes/_actions/compose.js +++ b/src/routes/_actions/compose.js @@ -4,7 +4,7 @@ import { postStatus as postStatusToServer } from '../_api/statuses' import { addStatusOrNotification } from './addStatusOrNotification' import { database } from '../_database/database' import { emit } from '../_utils/eventBus' -import { putMediaDescription } from '../_api/media' +import { putMediaMetadata } from '../_api/media' export async function insertHandleForReply (statusId) { let { currentInstance } = store.get() @@ -22,7 +22,7 @@ export async function insertHandleForReply (statusId) { export async function postStatus (realm, text, inReplyToId, mediaIds, sensitive, spoilerText, visibility, - mediaDescriptions, inReplyToUuid, poll) { + mediaDescriptions, inReplyToUuid, poll, mediaFocalPoints) { let { currentInstance, accessToken, online } = store.get() if (!online) { @@ -31,17 +31,27 @@ export async function postStatus (realm, text, inReplyToId, mediaIds, } text = text || '' - mediaDescriptions = mediaDescriptions || [] - store.set({ - postingStatus: true + let mediaMetadata = (mediaIds || []).map((mediaId, idx) => { + return { + description: mediaDescriptions && mediaDescriptions[idx], + focalPoint: mediaFocalPoints && mediaFocalPoints[idx] + } }) + + store.set({ postingStatus: true }) try { - await Promise.all(mediaDescriptions.map(async (description, i) => { - return description && putMediaDescription(currentInstance, accessToken, mediaIds[i], description) + await Promise.all(mediaMetadata.map(async ({ description, focalPoint }, i) => { + description = description || '' + focalPoint = focalPoint || [0, 0] + focalPoint[0] = focalPoint[0] || 0 + focalPoint[1] = focalPoint[1] || 0 + if (description || focalPoint[0] || focalPoint[1]) { + return putMediaMetadata(currentInstance, accessToken, mediaIds[i], description, focalPoint) + } })) let status = await postStatusToServer(currentInstance, accessToken, text, - inReplyToId, mediaIds, sensitive, spoilerText, visibility, poll) + inReplyToId, mediaIds, sensitive, spoilerText, visibility, poll, mediaFocalPoints) addStatusOrNotification(currentInstance, 'home', status) store.clearComposeData(realm) emit('postedStatus', realm, inReplyToUuid) diff --git a/src/routes/_api/media.js b/src/routes/_api/media.js index 370cd448..c06dd40a 100644 --- a/src/routes/_api/media.js +++ b/src/routes/_api/media.js @@ -11,7 +11,7 @@ export async function uploadMedia (instanceName, accessToken, file, description) return post(url, formData, auth(accessToken), { timeout: MEDIA_WRITE_TIMEOUT }) } -export async function putMediaDescription (instanceName, accessToken, mediaId, description) { +export async function putMediaMetadata (instanceName, accessToken, mediaId, description, focus) { let url = `${basename(instanceName)}/api/v1/media/${mediaId}` - return put(url, { description }, auth(accessToken), { timeout: WRITE_TIMEOUT }) + return put(url, { description, focus: (focus && focus.join(',')) }, auth(accessToken), { timeout: WRITE_TIMEOUT }) } diff --git a/src/routes/_components/Draggable.html b/src/routes/_components/Draggable.html new file mode 100644 index 00000000..56882678 --- /dev/null +++ b/src/routes/_components/Draggable.html @@ -0,0 +1,102 @@ +
+
+
+ +
+
+
+ + diff --git a/src/routes/_components/LazyImage.html b/src/routes/_components/LazyImage.html index 95142606..6644ead0 100644 --- a/src/routes/_components/LazyImage.html +++ b/src/routes/_components/LazyImage.html @@ -65,7 +65,9 @@ // Here we do a pure css version instead of using // https://github.com/jonom/jquery-focuspoint#1-calculate-your-images-focus-point - if (!focus) return 'background-position: center;' + if (!focus) { + return 'background-position: center;' + } return `object-position: ${coordsToPercent(focus.x)}% ${100 - coordsToPercent(focus.y)}%;` }, fillFixSize: ({ forceSize, $largeInlineMedia }) => !$largeInlineMedia && !forceSize, diff --git a/src/routes/_components/compose/ComposeBox.html b/src/routes/_components/compose/ComposeBox.html index d5a3883d..38f9bff0 100644 --- a/src/routes/_components/compose/ComposeBox.html +++ b/src/routes/_components/compose/ComposeBox.html @@ -193,6 +193,7 @@ let sensitive = media.length && !!contentWarning let mediaIds = media.map(_ => _.data.id) let mediaDescriptions = media.map(_ => _.description) + let mediaFocalPoints = media.map(_ => [_.focusX, _.focusY]) let inReplyTo = inReplyToId || ((realm === 'home' || realm === 'dialog') ? null : realm) if (overLimit || (!text && !media.length)) { @@ -217,7 +218,8 @@ /* no await */ postStatus(realm, text, inReplyTo, mediaIds, sensitive, contentWarning, postPrivacyKey, - mediaDescriptions, inReplyToUuid, pollToPost) + mediaDescriptions, inReplyToUuid, pollToPost, + mediaFocalPoints) } } } diff --git a/src/routes/_components/compose/ComposeMediaItem.html b/src/routes/_components/compose/ComposeMediaItem.html index c3dc8acb..99fa088e 100644 --- a/src/routes/_components/compose/ComposeMediaItem.html +++ b/src/routes/_components/compose/ComposeMediaItem.html @@ -1,14 +1,24 @@ -
  • +
  • -
    - +
    @@ -18,7 +28,9 @@ ref:textarea bind:value=rawText > - +
  • + diff --git a/src/routes/_components/dialog/components/MediaInDialog.html b/src/routes/_components/dialog/components/MediaInDialog.html index baa4a040..bdd1b62f 100644 --- a/src/routes/_components/dialog/components/MediaInDialog.html +++ b/src/routes/_components/dialog/components/MediaInDialog.html @@ -69,6 +69,8 @@ }