Skip to content

Commit

Permalink
Revert "wip"
Browse files Browse the repository at this point in the history
This reverts commit af7d86f.
  • Loading branch information
tamaina committed Apr 12, 2023
1 parent c1d94a4 commit bb0036a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 36 deletions.
2 changes: 1 addition & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ regenerate: "再生成"
fontSize: "フォントサイズ"
mediaListWithOneImageAppearance: "画像が1枚のみのメディアリストの高さ"
expandAsImage: "画像に応じて拡張"
limitTo: "{x}を上限に"
fixTo: "{x}に固定"
noFollowRequests: "フォロー申請はありません"
openImageInNewTab: "画像を新しいタブで開く"
dashboard: "ダッシュボード"
Expand Down
41 changes: 7 additions & 34 deletions packages/frontend/src/components/MkMediaList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
<div>
<XBanner v-for="media in mediaList.filter(media => !previewable(media))" :key="media.id" :media="media"/>
<div v-if="mediaList.filter(media => previewable(media)).length > 0" :class="$style.container">
<div
ref="gallery"
:class="[
$style.medias,
count <= 4 ? $style['n' + count] : $style.nMany,
$style[`n1${defaultStore.reactiveState.mediaListWithOneImageAppearance.value}`]
]"
>
<div ref="gallery" :class="[
$style.medias,
count <= 4 ? $style['n' + count] : $style.nMany,
$style[`n1${defaultStore.reactiveState.mediaListWithOneImageAppearance.value}`]]">
<template v-for="media in mediaList.filter(media => previewable(media))">
<XVideo v-if="media.type.startsWith('video')" :key="`video:${media.id}`" :class="$style.media" :video="media"/>
<XImage v-else-if="media.type.startsWith('image')" :key="`image:${media.id}`" :class="$style.media" class="image" :data-id="media.id" :image="media" :raw="raw"/>
Expand All @@ -20,7 +16,7 @@
</template>

<script lang="ts" setup>
import { onMounted, ref, useCssModule, watch } from 'vue';
import { onMounted, ref, useCssModule } from 'vue';
import * as misskey from 'misskey-js';
import PhotoSwipeLightbox from 'photoswipe/lightbox';
import PhotoSwipe from 'photoswipe';
Expand All @@ -39,34 +35,11 @@ const props = defineProps<{
const $style = useCssModule();
const gallery = ref<HTMLDivElement>();
const gallery = ref(null);
const pswpZIndex = os.claimZIndex('middle');
document.documentElement.style.setProperty('--mk-pswp-root-z-index', pswpZIndex.toString());
const count = $computed(() => props.mediaList.filter(media => previewable(media)).length);
function calcAspectRatio() {
if (!gallery.value) return;
let img = props.mediaList[0];
if (!(img.properties.width && img.properties.height)) {
gallery.value.style.aspectRatio = '';
return;
}
switch (defaultStore.state.mediaListWithOneImageAppearance) {
// アスペクト比上限設定では、横長の場合は高さを縮小させる
case '16_9':
gallery.value.style.aspectRatio = Math.max(16 / 9, img.properties.width / img.properties.height).toString();
break;
default:
gallery.value.style.aspectRatio = '';
break;
}
}
watch([defaultStore.reactiveState.mediaListWithOneImageAppearance, gallery], () => calcAspectRatio());
onMounted(() => {
const lightbox = new PhotoSwipeLightbox({
dataSource: props.mediaList
Expand Down Expand Up @@ -199,7 +172,7 @@ const previewable = (file: misskey.entities.DriveFile): boolean => {
&.n116_9 {
max-height: none;
aspect-ratio: 16 / 9; // fallback
aspect-ratio: 16/9;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<MkRadios v-model="mediaListWithOneImageAppearance">
<template #label>{{ i18n.ts.mediaListWithOneImageAppearance }}</template>
<option value="expand">{{ i18n.ts.expandAsImage }}</option>
<option value="16_9">{{ i18n.t('limitTo', { x: '16:9' }) }}</option>
<option value="16_9">{{ i18n.t('fixTo', { x: '16:9' }) }}</option>
</MkRadios>
</div>
</FormSection>
Expand Down

0 comments on commit bb0036a

Please sign in to comment.