feat(ui): improve gif support (#2752)

This commit is contained in:
lazzzis 2024-04-04 03:27:52 -07:00 committed by GitHub
parent 7dcafa3fe0
commit 8f04ea8eee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 31 additions and 5 deletions

View file

@ -36,6 +36,8 @@ const isPinching = ref(false)
const maxZoomOut = ref(1) const maxZoomOut = ref(1)
const isZoomedIn = computed(() => scale.value > 1) const isZoomedIn = computed(() => scale.value > 1)
const enableAutoplay = usePreferences('enableAutoplay')
function goToFocusedSlide() { function goToFocusedSlide() {
scale.value = 1 scale.value = 1
x.value = slide.value[modelValue.value].offsetLeft * scale.value x.value = slide.value[modelValue.value].offsetLeft * scale.value
@ -264,8 +266,12 @@ const imageStyle = computed(() => ({
items-center items-center
justify-center justify-center
> >
<img <component
:is="item.type === 'gifv' ? 'video' : 'img'"
ref="image" ref="image"
:autoplay="enableAutoplay"
controls
loop
select-none select-none
max-w-full max-w-full
max-h-full max-h-full
@ -273,7 +279,7 @@ const imageStyle = computed(() => ({
:draggable="false" :draggable="false"
:src="item.url || item.previewUrl" :src="item.url || item.previewUrl"
:alt="item.description || ''" :alt="item.description || ''"
> />
</div> </div>
</div> </div>
</div> </div>

View file

@ -68,6 +68,7 @@ const video = ref<HTMLVideoElement | undefined>()
const prefersReducedMotion = usePreferredReducedMotion() const prefersReducedMotion = usePreferredReducedMotion()
const isAudio = computed(() => attachment.type === 'audio') const isAudio = computed(() => attachment.type === 'audio')
const isVideo = computed(() => attachment.type === 'video') const isVideo = computed(() => attachment.type === 'video')
const isGif = computed(() => attachment.type === 'gifv')
const enableAutoplay = usePreferences('enableAutoplay') const enableAutoplay = usePreferences('enableAutoplay')
@ -164,7 +165,7 @@ watch(shouldLoadAttachment, () => {
<button <button
type="button" type="button"
relative relative
@click="!shouldLoadAttachment ? loadAttachment() : null" @click="!shouldLoadAttachment ? loadAttachment() : openMediaPreview(attachments ? attachments : [attachment], attachments?.indexOf(attachment) || 0)"
> >
<video <video
ref="video" ref="video"
@ -248,12 +249,13 @@ watch(shouldLoadAttachment, () => {
</button> </button>
</template> </template>
<div <div
v-if="attachment.description && !getPreferences(userSettings, 'hideAltIndicatorOnPosts')" :class="isAudio ? [] : [ :class="isAudio ? [] : [
'absolute left-2', 'absolute left-2',
isVideo ? 'top-2' : 'bottom-2', isVideo ? 'top-2' : 'bottom-2',
]" ]"
flex gap-col-2
> >
<VDropdown :distance="6" placement="bottom-start"> <VDropdown v-if="attachment.description && !getPreferences(userSettings, 'hideAltIndicatorOnPosts')" :distance="6" placement="bottom-start">
<button <button
font-bold text-sm font-bold text-sm
:class="isAudio :class="isAudio
@ -281,6 +283,14 @@ watch(shouldLoadAttachment, () => {
</div> </div>
</template> </template>
</VDropdown> </VDropdown>
<div v-if="isGif && !getPreferences(userSettings, 'hideGifIndicatorOnPosts')">
<button
aria-hidden font-bold text-sm
rounded-1 bg-black:65 text-white px1.2 py0.2 pointer-events-none
>
{{ $t('status.gif') }}
</button>
</div>
</div> </div>
</div> </div>
</template> </template>

View file

@ -9,6 +9,7 @@ export type ColorMode = 'light' | 'dark' | 'system'
export interface PreferencesSettings { export interface PreferencesSettings {
hideAltIndicatorOnPosts: boolean hideAltIndicatorOnPosts: boolean
hideGifIndicatorOnPosts: boolean
hideBoostCount: boolean hideBoostCount: boolean
hideReplyCount: boolean hideReplyCount: boolean
hideFavoriteCount: boolean hideFavoriteCount: boolean
@ -64,6 +65,7 @@ export function getDefaultLanguage(languages: string[]) {
export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = { export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = {
hideAltIndicatorOnPosts: false, hideAltIndicatorOnPosts: false,
hideGifIndicatorOnPosts: false,
hideBoostCount: false, hideBoostCount: false,
hideReplyCount: false, hideReplyCount: false,
hideFavoriteCount: false, hideFavoriteCount: false,

View file

@ -542,6 +542,7 @@
"hide_boost_count": "Hide boost count", "hide_boost_count": "Hide boost count",
"hide_favorite_count": "Hide favorite count", "hide_favorite_count": "Hide favorite count",
"hide_follower_count": "Hide following/follower count", "hide_follower_count": "Hide following/follower count",
"hide_gif_indi_on_posts": "Hide gif indicator on posts",
"hide_news": "Hide news", "hide_news": "Hide news",
"hide_reply_count": "Hide reply count", "hide_reply_count": "Hide reply count",
"hide_tag_hover_card": "Hide tag hover card", "hide_tag_hover_card": "Hide tag hover card",
@ -614,6 +615,7 @@
"favourited_by": "Favorited By", "favourited_by": "Favorited By",
"filter_hidden_phrase": "Filtered by", "filter_hidden_phrase": "Filtered by",
"filter_show_anyway": "Show anyway", "filter_show_anyway": "Show anyway",
"gif": "GIF",
"img_alt": { "img_alt": {
"ALT": "ALT", "ALT": "ALT",
"desc": "Description", "desc": "Description",

View file

@ -21,6 +21,12 @@ const userSettings = useUserSettings()
> >
{{ $t('settings.preferences.hide_alt_indi_on_posts') }} {{ $t('settings.preferences.hide_alt_indi_on_posts') }}
</SettingsToggleItem> </SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'hideGifIndicatorOnPosts')"
@click="togglePreferences('hideGifIndicatorOnPosts')"
>
{{ $t('settings.preferences.hide_gif_indi_on_posts') }}
</SettingsToggleItem>
<SettingsToggleItem <SettingsToggleItem
:checked="getPreferences(userSettings, 'hideAccountHoverCard')" :checked="getPreferences(userSettings, 'hideAccountHoverCard')"
@click="togglePreferences('hideAccountHoverCard')" @click="togglePreferences('hideAccountHoverCard')"