Merge branch 'develop' into pag-back

This commit is contained in:
tamaina
2023-07-26 12:23:13 +00:00
22 changed files with 1768 additions and 135 deletions

View File

@@ -22,6 +22,41 @@
</div>
</template>
<script lang="ts">
/**
* アスペクト比算出のためにHTMLElement.clientWidthを使うが、
* 大変重たいのでコンテナ要素とメディアリスト幅のペアをキャッシュする
* (タイムラインごとにスクロールコンテナが存在する前提だが……)
*/
const widthCache = new Map<Element, number>();
/**
* コンテナ要素がリサイズされたらキャッシュを削除する
*/
const ro = new ResizeObserver(entries => {
for (const entry of entries) {
widthCache.delete(entry.target);
}
});
async function getClientWidthWithCache(targetEl: HTMLElement, containerEl: HTMLElement, count = 0) {
if (_DEV_) console.log('getClientWidthWithCache', { targetEl, containerEl, count, cache: widthCache.get(containerEl) });
if (widthCache.has(containerEl)) return widthCache.get(containerEl)!;
const width = targetEl.clientWidth;
if (count <= 10 && width < 64) {
// widthが64未満はおかしいのでリトライする
await new Promise(resolve => setTimeout(resolve, 50));
return getClientWidthWithCache(targetEl, containerEl, count + 1);
}
widthCache.set(containerEl, width);
ro.observe(containerEl);
return width;
}
</script>
<script lang="ts" setup>
import { onMounted, shallowRef } from 'vue';
import * as misskey from 'misskey-js';
@@ -52,7 +87,7 @@ const count = $computed(() => props.mediaList.filter(media => previewable(media)
* アスペクト比をmediaListWithOneImageAppearanceに基づいていい感じに調整する
* aspect-ratioではなくheightを使う
*/
function calcAspectRatio() {
async function calcAspectRatio() {
if (!gallery.value || !root.value) return;
let img = props.mediaList[0];
@@ -62,7 +97,8 @@ function calcAspectRatio() {
return;
}
const width = gallery.value.clientWidth;
if (!container.value) container.value = getScrollContainer(root.value);
const width = container.value ? await getClientWidthWithCache(root.value, container.value) : root.value.clientWidth;
const heightMin = (ratio: number) => {
const imgResizeRatio = width / img.properties.width;
@@ -84,7 +120,6 @@ function calcAspectRatio() {
gallery.value.style.height = heightMin(3 / 2);
break;
default: {
if (!container.value) container.value = getScrollContainer(root.value);
const maxHeight = Math.max(64, (container.value ? container.value.clientHeight : getBodyScrollHeight()) * 0.5 || 360);
if (width === 0 || !maxHeight) return;
const imgResizeRatio = width / img.properties.width;

View File

@@ -431,6 +431,7 @@ defineExpose({
margin: auto;
padding: 32px;
display: flex;
overflow: auto;
@media (max-width: 500px) {
padding: 16px;

View File

@@ -758,6 +758,7 @@ function showReactions(): void {
padding: 16px;
border: dashed 1px var(--renote);
border-radius: 8px;
overflow: clip;
}
.channel {

View File

@@ -595,6 +595,7 @@ if (appearNote.replyId) {
padding: 16px;
border: dashed 1px var(--renote);
border-radius: 8px;
overflow: clip;
}
.channel {

View File

@@ -37,7 +37,6 @@ const showContent = $ref(false);
display: flex;
margin: 0;
padding: 0;
overflow: clip;
font-size: 0.95em;
}

View File

@@ -907,7 +907,6 @@ defineExpose({
display: flex;
flex-wrap: nowrap;
gap: 4px;
margin-bottom: -10px;
}
.headerLeft {
@@ -1025,7 +1024,7 @@ defineExpose({
}
.targetNote {
padding: 10px 20px 16px 20px;
padding: 0 20px 16px 20px;
}
.withQuote {

View File

@@ -110,7 +110,7 @@ const selectAll = () => {
if (selectedEmojis.value.length > 0) {
selectedEmojis.value = [];
} else {
selectedEmojis.value = emojisPaginationComponent.value.items.map(item => item.id);
selectedEmojis.value = Array.from(emojisPaginationComponent.value.items.values(), item => item.id);
}
};

View File

@@ -166,7 +166,7 @@ const headerActions = $computed(() => []);
const headerTabs = $computed(() => []);
definePageMetadata(computed(() => page ? {
title: computed(() => page.title || page.name),
title: page.title || page.name,
avatar: page.user,
path: `/@${page.user.username}/pages/${page.name}`,
share: {

View File

@@ -6,11 +6,13 @@
--marginHalf: 10px;
--margin: var(--marginFull);
--minBottomSpacing: 0px;
// switch dynamically
--minBottomSpacingMobile: calc(72px + max(12px, env(safe-area-inset-bottom, 0px)));
--minBottomSpacing: var(--minBottomSpacingMobile);
@media (max-width: 500px) {
--margin: var(--marginHalf);
--minBottomSpacing: calc(72px + max(12px, env(safe-area-inset-bottom, 0px)));
}
//--ad: rgb(255 169 0 / 10%);

View File

@@ -206,9 +206,11 @@ watch($$(navFooter), () => {
if (navFooter) {
navFooterHeight = navFooter.offsetHeight;
document.body.style.setProperty('--stickyBottom', `${navFooterHeight}px`);
document.body.style.setProperty('--minBottomSpacing', 'var(--minBottomSpacingMobile)');
} else {
navFooterHeight = 0;
document.body.style.setProperty('--stickyBottom', '0px');
document.body.style.setProperty('--minBottomSpacing', '0px');
}
}, {
immediate: true,