|
1 | 1 | <template> |
2 | 2 | <div class="about"> |
3 | | - <Logo3D/> |
| 3 | + <a class="dreaming" |
| 4 | + >Dreaming about our Vue Valentine ❤️</a |
| 5 | + > |
| 6 | + <Logo3D /> |
4 | 7 | </div> |
5 | 8 | </template> |
6 | 9 |
|
|
13 | 16 | padding: 0 1rem; |
14 | 17 | } |
15 | 18 | } |
| 19 | +.dreaming { |
| 20 | + background-color: #42b883cc; |
| 21 | + border-radius: 0.75rem; |
| 22 | + user-select: none; |
| 23 | + display: block; |
| 24 | + font-weight: bold; |
| 25 | + color: #35495e; |
| 26 | + font-size: x-large; |
| 27 | + margin: 15px auto 8px; |
| 28 | + padding: 1rem; |
| 29 | + text-align: center; |
| 30 | +} |
| 31 | +@keyframes heartfade { |
| 32 | + 0% { |
| 33 | + opacity : 1; |
| 34 | + } |
| 35 | + 50% { |
| 36 | + opacity : 0; |
| 37 | + } |
| 38 | +} |
| 39 | +.heart { |
| 40 | + z-index : 999; |
| 41 | + animation : heartfade 6s linear; |
| 42 | + position : absolute; |
| 43 | +} |
| 44 | +.heart:before, |
| 45 | +.heart:after { |
| 46 | + content : ""; |
| 47 | + background-color : #fc2a62; |
| 48 | + position : absolute; |
| 49 | + height : 30px; |
| 50 | + width : 45px; |
| 51 | + border-radius : 15px 0px 0px 15px; |
| 52 | +} |
| 53 | +
|
| 54 | +.heart:before { |
| 55 | + transform : rotate(45deg); |
| 56 | +} |
| 57 | +
|
| 58 | +.heart:after { |
| 59 | + left : 10.5px; |
| 60 | + transform : rotate(135deg); |
| 61 | +} |
16 | 62 | </style> |
17 | 63 |
|
18 | 64 | <script setup lang="ts"> |
19 | 65 | import Logo3D from '../app/components/Logo3D.vue'; |
| 66 | +
|
| 67 | +var brd = document.createElement("DIV"); |
| 68 | +document.body.insertBefore(brd, document.getElementById("board")); |
| 69 | +
|
| 70 | +const duration = 3000; |
| 71 | +const speed = 0.5; |
| 72 | +const cursorXOffset = 0; |
| 73 | +const cursorYOffset = -5; |
| 74 | +
|
| 75 | +let hearts = []; |
| 76 | + |
| 77 | +function generateHeart(x, y, xBound, xStart, scale) |
| 78 | +{ |
| 79 | + var heart = document.createElement("DIV") as any; |
| 80 | + heart.setAttribute('class', 'heart'); |
| 81 | + brd.appendChild(heart); |
| 82 | + heart.time = duration; |
| 83 | + heart.x = x; |
| 84 | + heart.y = y; |
| 85 | + heart.bound = xBound; |
| 86 | + heart.direction = xStart; |
| 87 | + heart.style.left = heart.x + "px"; |
| 88 | + heart.style.top = heart.y + "px"; |
| 89 | + heart.scale = scale; |
| 90 | + heart.style.transform = "scale(" + scale + "," + scale + ")"; |
| 91 | + if(hearts == null) |
| 92 | + hearts = []; |
| 93 | + hearts.push(heart); |
| 94 | + return heart; |
| 95 | +} |
| 96 | +
|
| 97 | +var down = false; |
| 98 | +var event = null; |
| 99 | +
|
| 100 | +document.onmousedown = function(e) { |
| 101 | + down = true; |
| 102 | + event = e; |
| 103 | +} |
| 104 | +
|
| 105 | +document.onmouseup = function(e) { |
| 106 | + down = false; |
| 107 | +} |
| 108 | +
|
| 109 | +document.onmousemove = function(e) { |
| 110 | + event = e; |
| 111 | +} |
| 112 | +
|
| 113 | +document.ontouchstart = function(e) { |
| 114 | + down = true; |
| 115 | + event = e.touches[0]; |
| 116 | +} |
| 117 | +
|
| 118 | +document.ontouchend = function(e) { |
| 119 | + down = false; |
| 120 | +} |
| 121 | +
|
| 122 | +document.ontouchmove = function(e) { |
| 123 | + event = e.touches[0]; |
| 124 | +} |
| 125 | +
|
| 126 | +var before = Date.now(); |
| 127 | +var id = setInterval(frame, 5); |
| 128 | +var gr = setInterval(check, 100); |
| 129 | +
|
| 130 | +function frame() |
| 131 | +{ |
| 132 | + var current = Date.now(); |
| 133 | + var deltaTime = current - before; |
| 134 | + before = current; |
| 135 | + for(const i in hearts) |
| 136 | + { |
| 137 | + var heart = hearts[i]; |
| 138 | + heart.time -= deltaTime; |
| 139 | + if(heart.time > 0) |
| 140 | + { |
| 141 | + heart.y -= speed; |
| 142 | + heart.style.top = heart.y + "px"; |
| 143 | + heart.style.left = heart.x + heart.direction * heart.bound * Math.sin(heart.y * heart.scale / 30) / heart.y * 100 + "px"; |
| 144 | + } |
| 145 | + else |
| 146 | + { |
| 147 | + heart.parentNode.removeChild(heart); |
| 148 | + hearts.splice(i, 1); |
| 149 | + } |
| 150 | + } |
| 151 | +} |
| 152 | +
|
| 153 | +function check() |
| 154 | +{ |
| 155 | + if(down) |
| 156 | + { |
| 157 | + var start = 1 - Math.round(Math.random()) * 2; |
| 158 | + var scale = Math.random() * Math.random() * 0.8 + 0.2; |
| 159 | + var bound = 30 + Math.random() * 20; |
| 160 | + generateHeart(event.pageX - brd.offsetLeft + cursorXOffset, event.pageY - brd.offsetTop + cursorYOffset, bound, start, scale); |
| 161 | + } |
| 162 | +} |
20 | 163 | </script> |
0 commit comments