parallax-home.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <script setup lang="ts">
  2. import { computed, reactive, ref } from 'vue'
  3. import { useEventListener, useParallax, useThrottleFn } from '@vueuse/core'
  4. import { useLang } from '../../composables/lang'
  5. import homeLocale from '../../../i18n/pages/home.json'
  6. import HomeSponsors from '../home/home-sponsors.vue'
  7. import HomeCards from '../home/home-cards.vue'
  8. import HomeFooter from './vp-footer.vue'
  9. import type { CSSProperties } from 'vue'
  10. const target = ref<HTMLElement | null>(null)
  11. const parallax = reactive(useParallax(target))
  12. const jumbotronRedOffset = ref(0)
  13. const jumbotronRef = ref<HTMLElement | null>(null)
  14. const lang = useLang()
  15. const homeLang = computed(() => homeLocale[lang.value])
  16. function jumpTo(path: string) {
  17. // vitepress has not router
  18. location.href = `/${lang.value}/${path}`
  19. }
  20. const containerStyle: CSSProperties = {
  21. display: 'flex',
  22. flexDirection: 'column',
  23. justifyContent: 'center',
  24. alignItems: 'center',
  25. transition: '.3s ease-out all',
  26. position: 'relative',
  27. perspective: '300px',
  28. }
  29. const cardStyle = computed(() => ({
  30. height: '30rem',
  31. width: '100%',
  32. transition: '.3s ease-out all',
  33. transform: `rotateX(${parallax.roll}deg) rotateY(${parallax.tilt}deg)`,
  34. }))
  35. const layerBase: CSSProperties = {
  36. position: 'absolute',
  37. width: '100%',
  38. height: '100%',
  39. transition: '.3s ease-out all',
  40. }
  41. const screenLayer = computed(() => ({
  42. ...layerBase,
  43. width: '80%',
  44. height: '80%',
  45. transform: `translateX(${parallax.tilt * 10 + 80}px) translateY(${parallax.roll * 10 + 50}px)`,
  46. }))
  47. const peopleLayer = computed(() => ({
  48. ...layerBase,
  49. width: '30%',
  50. height: '30%',
  51. right: 0,
  52. bottom: 0,
  53. transform: `translateX(${parallax.tilt * 25 + 25}px) translateY(${parallax.roll * 25}px) scale(1)`,
  54. }))
  55. // center layer
  56. const leftLayer = computed(() => ({
  57. ...layerBase,
  58. width: '20%',
  59. height: '20%',
  60. transform: `translateX(${parallax.tilt * 12 + 205}px) translateY(${parallax.roll * 12 + 210}px)`,
  61. }))
  62. const leftBottomLayer = computed(() => ({
  63. ...layerBase,
  64. width: '30%',
  65. height: '30%',
  66. left: 0,
  67. bottom: 0,
  68. transform: `translateX(${parallax.tilt * 30 - 10}px) translateY(${parallax.roll * 30}px)`,
  69. }))
  70. const rightLayer = computed(() => ({
  71. ...layerBase,
  72. width: '33%',
  73. height: '33%',
  74. top: 0,
  75. right: 0,
  76. transform: `translateX(${parallax.tilt * 25 + 5}px) translateY(${parallax.roll * 25}px)`,
  77. }))
  78. const handleScroll = useThrottleFn(() => {
  79. const ele = jumbotronRef.value
  80. if (ele) {
  81. const rect = ele.getBoundingClientRect()
  82. const eleHeight = ele.clientHeight
  83. let calHeight = (180 - rect.top) * 2
  84. if (calHeight < 0) calHeight = 0
  85. if (calHeight > eleHeight) calHeight = eleHeight
  86. jumbotronRedOffset.value = calHeight
  87. }
  88. }, 10)
  89. useEventListener(window, 'scroll', handleScroll)
  90. </script>
  91. <template>
  92. <div ref="target" class="home-page">
  93. <div class="banner" text="center">
  94. <div class="banner-desc" m="t-4">
  95. <h1>{{ homeLang['title'] }}</h1>
  96. <p m="t-2">{{ homeLang['title_sub'] }}</p>
  97. </div>
  98. </div>
  99. <!-- <div ref="jumbotronRef" class="jumbotron">
  100. <div class="parallax-container" :style="containerStyle">
  101. <div :style="cardStyle">
  102. <screen-svg :style="screenLayer" alt="banner" />
  103. <people-svg :style="peopleLayer" alt="banner" class="cursor-pointer" @click="jumpTo('guide/quickstart.html')" />
  104. <left-layer-svg :style="leftLayer" alt="banner" />
  105. <left-bottom-layer-svg :style="leftBottomLayer" alt="banner" />
  106. <right-layer-svg :style="rightLayer" alt="banner" />
  107. </div>
  108. </div>
  109. </div> -->
  110. <!-- <img src="/images/theme-index-blue.png" alt="banner" class="mobile-banner" /> -->
  111. <!-- <HomeSponsors /> -->
  112. <!-- <HomeCards /> -->
  113. </div>
  114. <HomeFooter :is-home="true" />
  115. </template>
  116. <style lang="scss">
  117. @use '../../styles/mixins' as *;
  118. .home-page {
  119. .mobile-banner {
  120. display: none;
  121. }
  122. .banner-dot h1 span {
  123. position: relative;
  124. &::after {
  125. content: '';
  126. position: absolute;
  127. right: -12px;
  128. bottom: 8px;
  129. background: var(--el-color-primary);
  130. height: 8px;
  131. width: 8px;
  132. border-radius: 100%;
  133. }
  134. }
  135. .banner-desc {
  136. h1 {
  137. font-size: 34px;
  138. margin: 0;
  139. line-height: 48px;
  140. color: var(--text-color);
  141. }
  142. p {
  143. font-size: 18px;
  144. color: var(--text-color-light);
  145. }
  146. }
  147. .count-down {
  148. .cd-main {
  149. background: #f1f6fe;
  150. border-radius: 10px;
  151. width: 50%;
  152. margin: 60px auto 120px;
  153. padding: 30px 0;
  154. font-size: 24px;
  155. color: #666;
  156. text-align: center;
  157. font-weight: 600;
  158. }
  159. .cd-date {
  160. font-size: 28px;
  161. }
  162. .cd-time {
  163. display: flex;
  164. justify-content: space-between;
  165. width: 80%;
  166. margin: 10px auto 0;
  167. }
  168. .cd-num {
  169. color: var(--el-color-primary);
  170. font-size: 78px;
  171. font-weight: bold;
  172. }
  173. .cd-num span {
  174. width: 50%;
  175. display: inline-block;
  176. }
  177. .cd-str {
  178. font-size: 22px;
  179. margin-top: -5px;
  180. }
  181. }
  182. .jumbotron {
  183. width: 800px;
  184. margin: 20px auto;
  185. position: relative;
  186. img {
  187. width: 100%;
  188. }
  189. .parallax-container {
  190. width: 800px;
  191. }
  192. }
  193. @media screen and (max-width: 959px) {
  194. .jumbotron {
  195. display: none !important;
  196. }
  197. .mobile-banner {
  198. display: inline-block;
  199. }
  200. }
  201. @media (max-width: 768px) {
  202. .jumbotron {
  203. width: 50%;
  204. display: flex;
  205. margin: auto;
  206. justify-content: center;
  207. align-items: center;
  208. .parallax-container {
  209. width: 100%;
  210. }
  211. }
  212. }
  213. @media (max-width: 768px) {
  214. .banner-desc {
  215. padding-top: 0px;
  216. }
  217. .cards {
  218. li {
  219. width: 80%;
  220. margin: 0 auto 20px;
  221. float: none;
  222. }
  223. .card {
  224. height: auto;
  225. padding-bottom: 54px;
  226. }
  227. }
  228. .banner-stars {
  229. display: none;
  230. }
  231. .banner-desc {
  232. h1 {
  233. font-size: 22px;
  234. }
  235. #line2 {
  236. display: none;
  237. }
  238. h2 {
  239. font-size: 32px;
  240. }
  241. p {
  242. width: auto;
  243. }
  244. }
  245. .banner-dot h1 span {
  246. &::after {
  247. right: -8px;
  248. bottom: 2px;
  249. height: 6px;
  250. width: 6px;
  251. }
  252. }
  253. .count-down {
  254. .cd-main {
  255. width: 90%;
  256. margin: 40px auto 40px;
  257. padding: 20px 0;
  258. }
  259. .cd-date {
  260. font-size: 22px;
  261. }
  262. .cd-num {
  263. font-size: 38px;
  264. }
  265. .cd-str {
  266. font-size: 12px;
  267. margin-top: 0px;
  268. }
  269. }
  270. .sponsors-list {
  271. display: flex;
  272. flex-direction: column;
  273. align-content: center;
  274. .sponsor {
  275. justify-content: left;
  276. }
  277. }
  278. }
  279. .theme-intro-b {
  280. position: fixed;
  281. left: 0;
  282. right: 0;
  283. top: 0;
  284. bottom: 0;
  285. z-index: 200;
  286. .intro-banner {
  287. position: absolute;
  288. }
  289. img {
  290. width: 300px;
  291. }
  292. .title {
  293. position: absolute;
  294. top: 0;
  295. bottom: 0;
  296. left: 0;
  297. right: 0;
  298. color: #fff;
  299. text-align: center;
  300. font-weight: bold;
  301. font-size: 20px;
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. p {
  306. padding: 0;
  307. margin: 10px 0;
  308. }
  309. }
  310. }
  311. .theme-intro-a {
  312. position: fixed;
  313. left: 0;
  314. right: 0;
  315. top: 0;
  316. bottom: 0;
  317. z-index: 200;
  318. .mask {
  319. position: fixed;
  320. left: 0;
  321. right: 0;
  322. top: 0;
  323. bottom: 0;
  324. background: #000;
  325. opacity: 0.5;
  326. }
  327. .intro-banner {
  328. top: 50%;
  329. left: 50%;
  330. position: fixed;
  331. transform: translate(-50%, -50%);
  332. box-sizing: border-box;
  333. text-align: center;
  334. z-index: 100;
  335. img {
  336. width: 100%;
  337. }
  338. .intro-text {
  339. position: absolute;
  340. top: 50%;
  341. left: 0;
  342. right: 0;
  343. p {
  344. padding: 0;
  345. margin: 0;
  346. font-size: 48px;
  347. font-weight: bold;
  348. color: #fff;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. </style>