valaxy-theme-hairy 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,28 +1,40 @@
1
1
  <script lang="ts" setup>
2
2
  import images from '@hairy:images:home'
3
3
  import { Swiper, SwiperSlide } from 'swiper/vue'
4
+ import { ref } from 'vue'
4
5
  import { Autoplay, EffectFade } from 'swiper/modules'
5
6
  import 'swiper/css'
6
7
  import 'swiper/css/autoplay'
7
8
  import 'swiper/css/effect-fade'
9
+ import 'swiper/element/css/virtual'
8
10
 
9
11
  images.sort(() => Math.random() - 0.5)
12
+ const cur = ref<number>(0)
10
13
  </script>
11
14
 
12
15
  <template>
13
16
  <Swiper
14
- effect="fade" :speed="2000" :fade-effect="{ crossFade: true }" :modules="[Autoplay, EffectFade]"
15
- :slides-per-view="1" :space-between="50" :autoplay="{
16
- delay: 4000,
17
- }" class="HairyCarousel swiper-no-swiping"
17
+ class="HairyCarousel swiper-no-swiping transition-none"
18
+ :fade-effect="{ crossFade: true }"
19
+ :modules="[Autoplay, EffectFade]"
20
+ :autoplay="{ delay: 4000 }"
21
+ :slides-per-view="1"
22
+ :space-between="50"
23
+ :speed="2000"
24
+ effect="fade"
25
+ :lazy-preload-prev-next="3"
26
+ @slide-change="cur = $event.activeIndex"
18
27
  >
19
- <SwiperSlide v-for="(item, index) in images" :key="index" class="w-full h-full">
20
- <img class="w-full h-full object-cover" :src="item">
28
+ <SwiperSlide v-for="(item, index) in images.slice(0, 5)" :key="index" lazy class="w-full h-full">
29
+ <img v-if="[cur - 1, cur, cur + 1].includes(index)" class="w-full h-full object-cover" :src="item" loading="lazy">
21
30
  </SwiperSlide>
22
31
  </Swiper>
23
32
  </template>
24
33
 
25
34
  <style lang="scss">
35
+ .swiper-lazy-preloader {
36
+ display: none !important;
37
+ }
26
38
  .HairyCarousel {
27
39
  &::before {
28
40
  content: '';
@@ -4,31 +4,19 @@ import type { ViteSSGContext } from 'vite-ssg'
4
4
  import Seto from '../styles/fonts/Seto.ttf?url'
5
5
  import { createDeferred } from '../utils'
6
6
 
7
- export const fontFaceDeferred = createDeferred<void>()
7
+ let el: HTMLElement
8
+
9
+ showFullLoading()
10
+
11
+ export const deferred = createDeferred<void>()
8
12
 
9
13
  export function install({ router }: ViteSSGContext) {
10
- showFullLoading()
11
14
  loadFonts('Seto', Seto)
12
- router.afterEach(() => {
13
- fontFaceDeferred.then(hideFullLoading)
14
- })
15
+ router.afterEach(() => deferred.then(hideFullLoading))
15
16
  }
16
17
 
17
18
  export const isLoading = ref(false)
18
19
 
19
- let el: HTMLElement
20
-
21
- function createElement() {
22
- const loadingEl = document.createElement('div')
23
- loadingEl.className = 'hy-loading'
24
- loadingEl.innerHTML = `\
25
- <div class="wrapper">
26
- <div id="preloader"></div>
27
- </div>
28
- `
29
- return loadingEl
30
- }
31
-
32
20
  function showFullLoading() {
33
21
  if (typeof window === 'undefined')
34
22
  return
@@ -61,6 +49,17 @@ function loadFonts(fontFamily: string, url: string) {
61
49
  const font = new FontFace(fontFamily, `url(${url})`)
62
50
  font.load().then(() => {
63
51
  ;(document.fonts as any).add(font)
64
- fontFaceDeferred.resolve()
52
+ deferred.resolve()
65
53
  })
66
54
  }
55
+
56
+ function createElement() {
57
+ const loadingEl = document.createElement('div')
58
+ loadingEl.className = 'hy-loading'
59
+ loadingEl.innerHTML = `\
60
+ <div class="wrapper">
61
+ <div id="preloader"></div>
62
+ </div>
63
+ `
64
+ return loadingEl
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-hairy",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "packageManager": "pnpm@8.15.8",
5
5
  "author": {
6
6
  "email": "wwu710632@gmail.com",