refactor: 画面サイズのしきい値をconstにまとめる

This commit is contained in:
kakkokari-gtyih 2024-06-25 20:04:59 +09:00
parent e88fc369d9
commit 05ca36f400
9 changed files with 17 additions and 15 deletions

View file

@ -48,6 +48,7 @@ import { scrollToTop } from '@/scripts/scroll.js';
import { globalEvents } from '@/events.js';
import { injectReactiveMetadata } from '@/scripts/page-metadata.js';
import { $i, openAccountMenu as openAccountMenu_ } from '@/account.js';
import { MOBILE_THRESHOLD } from '@/const.js';
import { PageHeaderItem } from '@/types/page-header.js';
const props = withDefaults(defineProps<{
@ -112,10 +113,10 @@ onMounted(() => {
globalEvents.on('themeChanged', calcBg);
if (el.value && el.value.parentElement) {
narrow.value = el.value.parentElement.offsetWidth < 500;
narrow.value = el.value.parentElement.offsetWidth < MOBILE_THRESHOLD;
ro = new ResizeObserver((entries, observer) => {
if (el.value && el.value.parentElement && document.body.contains(el.value as HTMLElement)) {
narrow.value = el.value.parentElement.offsetWidth < 500;
narrow.value = el.value.parentElement.offsetWidth < MOBILE_THRESHOLD;
}
});
ro.observe(el.value.parentElement as HTMLElement);