|
23 | 23 | }) |
24 | 24 | } |
25 | 25 |
|
26 | | - onMounted(() => { |
27 | | - const html_text = "Ri-oneの<span id='target'>新入生歓迎講座</span>へようこそ。" |
28 | | - const conv_text = "Ri-oneの新入生歓迎講座へようこそ。"; |
29 | | - const orig_text = "Ri-oneのしんにゅうせいかんげいこうざへようこそ。"; |
30 | | - const speed = 130; // Typing speed in milliseconds |
31 | | - var index = 0; |
32 | | -
|
33 | | - function typeNextCharacter() { |
34 | | - output.value += (orig_text[index]); |
35 | | - index++; |
36 | | - if (index < orig_text.length) { |
37 | | - if (index == 14){ |
38 | | - output.value = (conv_text.slice(0, 11)); |
39 | | - } else if (index == 18){ |
40 | | - output.value = (conv_text.slice(0, 13)); |
41 | | - } else if (index == 22){ |
42 | | - output.value = (conv_text.slice(0, 15)); |
43 | | - } |
44 | | - setTimeout(typeNextCharacter, speed); |
45 | | - } else if (index == orig_text.length) { |
46 | | - output.value = html_text; |
| 26 | + const html_text = "Ri-oneの<span id='target'>新入生歓迎講座</span>へようこそ。" |
| 27 | + const conv_text = "Ri-oneの新入生歓迎講座へようこそ。"; |
| 28 | + const orig_text = "Ri-oneのしんにゅうせいかんげいこうざへようこそ。"; |
| 29 | + const speed = 130; // Typing speed in milliseconds |
| 30 | + var index = 0; |
| 31 | +
|
| 32 | + function typeNextCharacter() { |
| 33 | + output.value += (orig_text[index]); |
| 34 | + index++; |
| 35 | + if (index < orig_text.length) { |
| 36 | + if (index == 14){ |
| 37 | + output.value = (conv_text.slice(0, 11)); |
| 38 | + } else if (index == 18){ |
| 39 | + output.value = (conv_text.slice(0, 13)); |
| 40 | + } else if (index == 22){ |
| 41 | + output.value = (conv_text.slice(0, 15)); |
| 42 | + } |
| 43 | + setTimeout(typeNextCharacter, speed); |
| 44 | + } else if (index == orig_text.length) { |
| 45 | + output.value = html_text; |
| 46 | + } |
| 47 | + }; |
| 48 | +
|
| 49 | + let isScrolling = false; |
| 50 | +
|
| 51 | + function startScrolling() { |
| 52 | + isScrolling = true; |
| 53 | + var scrollText = document.getElementById('scroll-text'); |
| 54 | + var scrollContainer = document.getElementById('scroll-container'); |
| 55 | + var containerWidth = scrollContainer.offsetWidth; |
| 56 | + var textWidth = scrollText.offsetWidth; |
| 57 | +
|
| 58 | + // Reset position |
| 59 | + scrollText.style.left = containerWidth + 'px'; |
| 60 | +
|
| 61 | + function animate() { |
| 62 | + if (!isScrolling) return; |
| 63 | + var currentLeft = parseFloat(scrollText.style.left); |
| 64 | + scrollText.style.left = (currentLeft - 2) + 'px'; // Adjust speed by changing 2 |
| 65 | + if (currentLeft + textWidth > 0) { |
| 66 | + requestAnimationFrame(animate); |
| 67 | + } else { |
| 68 | + startScrolling(); // Repeat animation |
47 | 69 | } |
48 | | - }; |
| 70 | + } |
| 71 | + requestAnimationFrame(animate); |
| 72 | + } |
| 73 | +
|
| 74 | + function stopScrolling() { |
| 75 | + isScrolling = false; |
| 76 | + } |
49 | 77 |
|
50 | | - typeNextCharacter(); |
| 78 | + onMounted(() => { |
| 79 | + typeNextCharacter(); |
| 80 | + startScrolling(); |
51 | 81 | }); |
52 | 82 |
|
53 | 83 | onUnmounted(() => { |
| 84 | + stopScrolling() |
54 | 85 | output.value = ""; |
55 | 86 | }); |
56 | 87 | </script> |
57 | 88 |
|
58 | 89 | <template> |
59 | 90 | <div class="container mx-auto my-16"> |
60 | 91 | <h1 v-html="output" id="output" class="text-5xl"></h1><span class="typing-cursor"></span> |
61 | | - <div class="mt-2">※レスポンシブ非対応なのは内緒です。だって面倒くさ(ry</div> |
| 92 | + <!-- <div class="mt-2">※レスポンシブ非対応なのは内緒です。だって面倒くさ(ry</div> --> |
| 93 | + <div id="scroll-container" class="mx-auto w-4/6 mt-2"> |
| 94 | + <div id="scroll-text" class="text-md">ついにレスポンシブ対応しました! ところで、誰がこのページをスマホで開くのでしょうか...</div> |
| 95 | + </div> |
62 | 96 | </div> |
63 | 97 |
|
64 | | - <table class="mx-auto mt-20 sm:w-5/6 md:w-3/6 bg-neutral-900 rounded-lg border-2 border-solid border-green-700"> |
| 98 | + |
| 99 | + |
| 100 | + <table class="mx-auto mt-20 w-full sm:w-5/6 md:w-4/6 bg-neutral-900 rounded-lg border-2 border-solid border-green-700"> |
65 | 101 | <div class="flex-col space-y-0 space-x-0 text-start divide-y divide-green-600"> |
66 | 102 | <div v-for="(lecture, index) in lectures" class="w-full py-5 pl-5 hover:bg-green-600 hover:scale-105" @click="navigate(index)"> |
67 | 103 | 第{{ oneOriented(index) }}講 {{ lecture.title }} |
|
80 | 116 | display: inline-block; |
81 | 117 | } |
82 | 118 |
|
| 119 | + #scroll-container { |
| 120 | + overflow: hidden; |
| 121 | + white-space: nowrap; |
| 122 | + box-sizing: border-box; |
| 123 | + } |
| 124 | +
|
| 125 | + #scroll-text { |
| 126 | + display: inline-block; |
| 127 | + padding-right: 10%; /* Ensures the text starts off-screen */ |
| 128 | + position: relative; |
| 129 | + } |
| 130 | +
|
83 | 131 | .typing-cursor { |
84 | 132 | display: inline-block; |
85 | 133 | width: 15px; |
|
0 commit comments