2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-12-30 16:22:20 +01:00
|
|
|
<template>
|
2024-07-11 11:41:04 +02:00
|
|
|
<div :class="$style.root" class="_gaps">
|
|
|
|
<div
|
|
|
|
ref="notesMainContainerEl"
|
|
|
|
class="_gaps"
|
|
|
|
:class="[$style.scrollBoxMain, { [$style.scrollIntro]: (scrollState === 'intro'), [$style.scrollLoop]: (scrollState === 'loop') }]"
|
|
|
|
@animationend="changeScrollState"
|
|
|
|
>
|
|
|
|
<XNote v-for="note in notes" :key="`${note.id}_1`" :class="$style.note" :note="note"/>
|
|
|
|
</div>
|
|
|
|
<div v-if="isScrolling" class="_gaps" :class="[$style.scrollBoxSub, { [$style.scrollIntro]: (scrollState === 'intro'), [$style.scrollLoop]: (scrollState === 'loop') }]">
|
|
|
|
<XNote v-for="note in notes" :key="`${note.id}_2`" :class="$style.note" :note="note"/>
|
2020-12-30 16:22:20 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2023-02-17 04:38:30 +01:00
|
|
|
<script lang="ts" setup>
|
2023-09-04 06:33:38 +02:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-12-07 06:42:09 +01:00
|
|
|
import { onUpdated, ref, shallowRef } from 'vue';
|
2024-07-11 11:41:04 +02:00
|
|
|
import XNote from '@/pages/welcome.timeline.note.vue';
|
2024-01-04 10:32:46 +01:00
|
|
|
import { misskeyApiGet } from '@/scripts/misskey-api.js';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { getScrollContainer } from '@/scripts/scroll.js';
|
2020-12-30 16:22:20 +01:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const notes = ref<Misskey.entities.Note[]>([]);
|
|
|
|
const isScrolling = ref(false);
|
2024-07-11 11:41:04 +02:00
|
|
|
const scrollState = ref<null | 'intro' | 'loop'>(null);
|
|
|
|
const notesMainContainerEl = shallowRef<HTMLElement>();
|
2020-12-30 16:22:20 +01:00
|
|
|
|
2024-01-04 10:32:46 +01:00
|
|
|
misskeyApiGet('notes/featured').then(_notes => {
|
2023-12-07 06:42:09 +01:00
|
|
|
notes.value = _notes;
|
2023-02-17 04:38:30 +01:00
|
|
|
});
|
2021-07-09 19:55:12 +02:00
|
|
|
|
2024-07-11 11:41:04 +02:00
|
|
|
function changeScrollState() {
|
|
|
|
if (scrollState.value !== 'loop') {
|
|
|
|
scrollState.value = 'loop';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-17 04:38:30 +01:00
|
|
|
onUpdated(() => {
|
2024-07-11 11:41:04 +02:00
|
|
|
if (!notesMainContainerEl.value) return;
|
|
|
|
const container = getScrollContainer(notesMainContainerEl.value);
|
2023-02-17 04:38:30 +01:00
|
|
|
const containerHeight = container ? container.clientHeight : window.innerHeight;
|
2024-07-11 11:41:04 +02:00
|
|
|
if (notesMainContainerEl.value.offsetHeight > containerHeight) {
|
|
|
|
if (scrollState.value === null) {
|
|
|
|
scrollState.value = 'intro';
|
|
|
|
}
|
2023-12-07 06:42:09 +01:00
|
|
|
isScrolling.value = true;
|
2023-02-17 04:38:30 +01:00
|
|
|
}
|
2020-12-30 16:22:20 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-02-17 04:38:30 +01:00
|
|
|
<style lang="scss" module>
|
2024-07-11 11:41:04 +02:00
|
|
|
@keyframes scrollIntro {
|
2021-07-09 19:55:12 +02:00
|
|
|
0% {
|
|
|
|
transform: translate3d(0, 0, 0);
|
|
|
|
}
|
2024-07-11 11:41:04 +02:00
|
|
|
100% {
|
|
|
|
transform: translate3d(0, calc(calc(-100% - 128px) - var(--margin)), 0);
|
2021-07-09 19:55:12 +02:00
|
|
|
}
|
2024-07-11 11:41:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes scrollConstant {
|
|
|
|
0% {
|
|
|
|
transform: translate3d(0, -128px, 0);
|
2021-07-09 19:55:12 +02:00
|
|
|
}
|
2024-07-11 11:41:04 +02:00
|
|
|
100% {
|
|
|
|
transform: translate3d(0, calc(calc(-100% - 128px) - var(--margin)), 0);
|
2021-07-09 19:55:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-17 04:38:30 +01:00
|
|
|
.root {
|
2020-12-30 16:22:20 +01:00
|
|
|
text-align: right;
|
2023-02-17 04:38:30 +01:00
|
|
|
}
|
2020-12-30 16:22:20 +01:00
|
|
|
|
2024-07-11 11:41:04 +02:00
|
|
|
.scrollBoxMain {
|
|
|
|
&.scrollIntro {
|
|
|
|
animation: scrollIntro 30s linear forwards;
|
|
|
|
}
|
|
|
|
&.scrollLoop {
|
|
|
|
animation: scrollConstant 30s linear infinite;
|
2023-02-17 04:38:30 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-09 19:55:12 +02:00
|
|
|
|
2024-07-11 11:41:04 +02:00
|
|
|
.scrollBoxSub {
|
|
|
|
&.scrollIntro {
|
|
|
|
animation: scrollIntro 30s linear forwards;
|
|
|
|
}
|
|
|
|
&.scrollLoop {
|
|
|
|
animation: scrollConstant 30s linear infinite;
|
|
|
|
}
|
2023-02-17 04:38:30 +01:00
|
|
|
}
|
2020-12-30 16:22:20 +01:00
|
|
|
|
2024-07-11 11:41:04 +02:00
|
|
|
.root:has(.note:hover) .scrollBoxMain,
|
|
|
|
.root:has(.note:hover) .scrollBoxSub {
|
|
|
|
animation-play-state: paused;
|
2020-12-30 16:22:20 +01:00
|
|
|
}
|
|
|
|
</style>
|