jeawin-astro 3.0.87 → 3.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -14
- package/src/components/banner_splide.astro +189 -0
- package/src/components/banner_swiper.astro +1 -1
- package/src/components/index.ts +4 -1
- package/src/components/slide/index.ts +2 -0
- package/src/components/slide/swiper1.astro +178 -0
- package/src/components/slide/swiper3d.astro +226 -0
- package/src/styles/global.css +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jeawin-astro",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.89",
|
|
4
4
|
"author": "chaegumi <chaegumi@qq.com>",
|
|
5
5
|
"description": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test": "mocha test"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.27.
|
|
28
|
+
"@babel/core": "^7.27.4",
|
|
29
29
|
"@babel/preset-env": "^7.27.2",
|
|
30
30
|
"@rollup/plugin-babel": "^6.0.4",
|
|
31
31
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"autoprefixer": "^10.4.21",
|
|
41
41
|
"chai": "^5.2.0",
|
|
42
42
|
"mocha": "^10.8.2",
|
|
43
|
-
"postcss": "^8.5.
|
|
44
|
-
"rollup": "^4.
|
|
43
|
+
"postcss": "^8.5.4",
|
|
44
|
+
"rollup": "^4.43.0",
|
|
45
45
|
"rollup-plugin-node-externals": "^7.1.3",
|
|
46
46
|
"rollup-plugin-postcss": "^4.0.2",
|
|
47
47
|
"typescript": "^5.8.3"
|
|
@@ -49,33 +49,34 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@astrojs/alpinejs": "^0.4.8",
|
|
51
51
|
"@astrojs/check": "^0.9.4",
|
|
52
|
-
"@astrojs/cloudflare": "^12.5.
|
|
53
|
-
"@astrojs/rss": "^4.0.
|
|
52
|
+
"@astrojs/cloudflare": "^12.5.4",
|
|
53
|
+
"@astrojs/rss": "^4.0.12",
|
|
54
54
|
"@astrojs/sitemap": "3.2.1",
|
|
55
55
|
"@astrojs/ts-plugin": "^1.10.4",
|
|
56
56
|
"@astrojs/vue": "^5.1.0",
|
|
57
57
|
"@iconify-json/fa6-brands": "^1.2.5",
|
|
58
58
|
"@iconify-json/fa6-solid": "^1.2.3",
|
|
59
59
|
"@iconify/tools": "^4.1.2",
|
|
60
|
-
"@keyv/compress-brotli": "^2.0.
|
|
60
|
+
"@keyv/compress-brotli": "^2.0.5",
|
|
61
61
|
"@pagefind/default-ui": "^1.3.0",
|
|
62
|
+
"@splidejs/splide": "^4.1.4",
|
|
62
63
|
"@tailwindcss/forms": "^0.5.10",
|
|
63
64
|
"@tailwindcss/typography": "^0.5.16",
|
|
64
|
-
"@tailwindcss/vite": "^4.1.
|
|
65
|
+
"@tailwindcss/vite": "^4.1.8",
|
|
65
66
|
"@types/alpinejs": "^3.13.11",
|
|
66
67
|
"alpinejs": "^3.14.9",
|
|
67
68
|
"aos": "3.0.0-beta.6",
|
|
68
|
-
"astro": "^5.
|
|
69
|
+
"astro": "^5.9.2",
|
|
69
70
|
"astro-color-scheme": "^1.1.5",
|
|
70
71
|
"astro-embed": "^0.9.0",
|
|
71
72
|
"astro-icon": "^1.1.5",
|
|
72
73
|
"astro-integration-kit": "^0.18.0",
|
|
73
74
|
"cacache": "^19.0.1",
|
|
74
|
-
"cheerio": "^1.
|
|
75
|
+
"cheerio": "^1.1.0",
|
|
75
76
|
"dayjs": "^1.11.13",
|
|
76
77
|
"fetch-jsonp": "^1.3.0",
|
|
77
78
|
"glob": "^11.0.2",
|
|
78
|
-
"keyv": "^5.3.
|
|
79
|
+
"keyv": "^5.3.4",
|
|
79
80
|
"keyv-lru": "^3.0.4",
|
|
80
81
|
"lodash": "^4.17.21",
|
|
81
82
|
"pagefind": "^1.3.0",
|
|
@@ -84,10 +85,10 @@
|
|
|
84
85
|
"smartmenus": "2.0.0-alpha.1",
|
|
85
86
|
"sprintf-js": "^1.1.3",
|
|
86
87
|
"string-strip-html": "^13.4.12",
|
|
87
|
-
"swiper": "^11.2.
|
|
88
|
+
"swiper": "^11.2.8",
|
|
88
89
|
"tailwind-scrollbar": "^4.0.2",
|
|
89
|
-
"tailwindcss": "^4.1.
|
|
90
|
+
"tailwindcss": "^4.1.8",
|
|
90
91
|
"tslib": "^2.8.1",
|
|
91
|
-
"zod": "^3.25.
|
|
92
|
+
"zod": "^3.25.58"
|
|
92
93
|
}
|
|
93
94
|
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* banner切换组件
|
|
4
|
+
*
|
|
5
|
+
* jeawin-astro/src/components/banner_swiper.astro
|
|
6
|
+
*
|
|
7
|
+
* @package jeawin-astro
|
|
8
|
+
* @author Chaegumi
|
|
9
|
+
* @copyright Copyright (c) 2024-2099 jeawin.com
|
|
10
|
+
* @email chaegumi@jeawin.com
|
|
11
|
+
* @filesource
|
|
12
|
+
*/
|
|
13
|
+
import '@splidejs/splide/css/skyblue';
|
|
14
|
+
import _ from "lodash";
|
|
15
|
+
import { img_change_attrs, render_value, render_url, render_lang } from "../scripts/util.js";
|
|
16
|
+
import JeawinApi from "../scripts/cms.js";
|
|
17
|
+
import Button from "./button.astro";
|
|
18
|
+
interface Props {
|
|
19
|
+
tag_name?: string;
|
|
20
|
+
style_class?: any; // 包围banner滚动组件的元素class
|
|
21
|
+
show_title?: boolean;
|
|
22
|
+
slide_class?: any; // 滚动项的元素class
|
|
23
|
+
height_radio?: any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {url_suffix} = Astro.locals;
|
|
27
|
+
|
|
28
|
+
const { tag_name, style_class, show_title = false,slide_class, height_radio } = Astro.props;
|
|
29
|
+
|
|
30
|
+
const TagName = tag_name || "section";
|
|
31
|
+
let StyleClass: any = [];
|
|
32
|
+
let SlideClass: any= [];
|
|
33
|
+
if (style_class) {
|
|
34
|
+
if (_.isArray(style_class)) {
|
|
35
|
+
StyleClass = style_class;
|
|
36
|
+
} else if (_.isString(style_class)) {
|
|
37
|
+
StyleClass = _.split(style_class, " ");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if(slide_class){
|
|
41
|
+
if(_.isArray(slide_class)){
|
|
42
|
+
SlideClass = slide_class;
|
|
43
|
+
}else if(_.isString(slide_class)){
|
|
44
|
+
SlideClass = _.split(slide_class, " ");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { jeawin_apikey, jeawin_api_domain, jeawin_api_path, sticky_top_height, is_preview, all_langs, base } = Astro.locals;
|
|
49
|
+
const jeawinapi = new JeawinApi({
|
|
50
|
+
apikey: jeawin_apikey,
|
|
51
|
+
api_domain: jeawin_api_domain,
|
|
52
|
+
api_path: jeawin_api_path,
|
|
53
|
+
sticky_top_height: sticky_top_height,
|
|
54
|
+
is_preview
|
|
55
|
+
});
|
|
56
|
+
const banners = await jeawinapi.get_nodes({ channel_id: 5 });
|
|
57
|
+
// console.log(banners);
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
<custom-banner-splide>
|
|
61
|
+
<input type="hidden" class="heightRadio" value={height_radio} />
|
|
62
|
+
{
|
|
63
|
+
banners && banners.nodes && banners.nodes.length > 0 ? (
|
|
64
|
+
<TagName class:list={['splide', ...StyleClass]}>
|
|
65
|
+
<div class="splide__track">
|
|
66
|
+
<ul class="splide__list">
|
|
67
|
+
{banners.nodes &&
|
|
68
|
+
banners.nodes.map((banner: any, idx: number) => (
|
|
69
|
+
<li class:list={['splide__slide', ...SlideClass]}>
|
|
70
|
+
{show_title && render_value(banner, 'show_text_block', '1') == '1' ? (
|
|
71
|
+
<div class="relative h-full w-full">
|
|
72
|
+
<div class="absolute inset-0 flex items-center justify-center text-white text-center p-4">
|
|
73
|
+
<div class="p-4 px-4 bg-[rgba(0,0,0,0.5)] rounded-sm">
|
|
74
|
+
{
|
|
75
|
+
idx > 0 ? (
|
|
76
|
+
<div class="text-base md:text-3xl lg:text-4xl">{banner.node_title}</div>
|
|
77
|
+
) : (
|
|
78
|
+
<h1 class="text-base md:text-3xl lg:text-4xl">{banner.node_title}</h1>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
<div class="text-xs line-clamp-2 md:line-clamp-none md:text-lg md:mt-4">{render_value(banner, 'sub_title')}</div>
|
|
82
|
+
<Button tag_name="a" class="inline-block md:mt-2" href={render_url(render_value(banner, "linkurl"), base, null, url_suffix)}
|
|
83
|
+
title={render_value(banner, 'btntext') || render_lang(all_langs, 'read more')}>{render_value(banner, 'btntext') || render_lang(all_langs, 'read more')}</Button>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
{idx > 0 ? (
|
|
89
|
+
<Fragment
|
|
90
|
+
set:html={img_change_attrs(
|
|
91
|
+
banner.node_picurl_html,
|
|
92
|
+
{
|
|
93
|
+
width: "100%",
|
|
94
|
+
loading: "lazy",
|
|
95
|
+
fetchpriority: "low",
|
|
96
|
+
},
|
|
97
|
+
["class", "loading"]
|
|
98
|
+
)}
|
|
99
|
+
/>
|
|
100
|
+
) : (
|
|
101
|
+
<Fragment
|
|
102
|
+
set:html={img_change_attrs(
|
|
103
|
+
banner.node_picurl_html,
|
|
104
|
+
{
|
|
105
|
+
width: "100%",
|
|
106
|
+
class: '',
|
|
107
|
+
loading: "eager",
|
|
108
|
+
fetchpriority: "high",
|
|
109
|
+
},
|
|
110
|
+
["class"]
|
|
111
|
+
)}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
</div>
|
|
115
|
+
) : (
|
|
116
|
+
<a href={render_url(render_value(banner, "linkurl"), base, null, url_suffix)} title={banner.node_title}>
|
|
117
|
+
{idx > 0 ? (
|
|
118
|
+
<Fragment
|
|
119
|
+
set:html={img_change_attrs(
|
|
120
|
+
banner.node_picurl_html,
|
|
121
|
+
{
|
|
122
|
+
width: "100%",
|
|
123
|
+
loading: "lazy",
|
|
124
|
+
fetchpriority: "low",
|
|
125
|
+
},
|
|
126
|
+
["class", "loading"]
|
|
127
|
+
)}
|
|
128
|
+
/>
|
|
129
|
+
) : (
|
|
130
|
+
<Fragment
|
|
131
|
+
set:html={img_change_attrs(
|
|
132
|
+
banner.node_picurl_html,
|
|
133
|
+
{
|
|
134
|
+
width: "100%",
|
|
135
|
+
class: "",
|
|
136
|
+
loading: "eager",
|
|
137
|
+
fetchpriority: "high",
|
|
138
|
+
},
|
|
139
|
+
["class"]
|
|
140
|
+
)}
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
</a>
|
|
144
|
+
)}
|
|
145
|
+
</li>
|
|
146
|
+
))}
|
|
147
|
+
</ul>
|
|
148
|
+
</div>
|
|
149
|
+
</TagName>
|
|
150
|
+
) : null
|
|
151
|
+
}
|
|
152
|
+
</custom-banner-splide>
|
|
153
|
+
<style>
|
|
154
|
+
.splide__slide img{
|
|
155
|
+
width:100%;
|
|
156
|
+
/* height: auto; */
|
|
157
|
+
height:100%;
|
|
158
|
+
object-fit: cover;
|
|
159
|
+
}
|
|
160
|
+
</style>
|
|
161
|
+
<script>
|
|
162
|
+
import Splide from "@splidejs/splide";
|
|
163
|
+
|
|
164
|
+
class CustomBannerSplide extends HTMLElement {
|
|
165
|
+
constructor() {
|
|
166
|
+
super();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
connectedCallback(){
|
|
170
|
+
const splideElem: any = this.querySelector('.splide');
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
const heightRadio: any = this.querySelector('.heightRadio')?.value;
|
|
173
|
+
console.log(heightRadio);
|
|
174
|
+
if(splideElem){
|
|
175
|
+
const splide = new Splide(splideElem,{
|
|
176
|
+
// type:'loop',
|
|
177
|
+
// width:'100vw',
|
|
178
|
+
// height:'100vh',
|
|
179
|
+
autoplay: true,
|
|
180
|
+
cover: true,
|
|
181
|
+
heightRatio: Number(heightRadio),
|
|
182
|
+
});
|
|
183
|
+
splide.mount();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
customElements.define("custom-banner-splide", CustomBannerSplide);
|
|
189
|
+
</script>
|
|
@@ -75,7 +75,7 @@ const banners = await jeawinapi.get_nodes({ channel_id: 5 });
|
|
|
75
75
|
{show_title && render_value(banner, 'show_text_block', '1') == '1' ? (
|
|
76
76
|
<div class="relative h-full w-full">
|
|
77
77
|
<div class="absolute inset-0 flex items-center justify-center text-white text-center p-4">
|
|
78
|
-
<div class="p-
|
|
78
|
+
<div class="p-4 px-4 bg-[rgba(0,0,0,0.5)] rounded-sm">
|
|
79
79
|
{
|
|
80
80
|
idx > 0 ? (
|
|
81
81
|
<div class="text-base md:text-3xl lg:text-4xl">{banner.node_title}</div>
|
package/src/components/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export {default as AuthorInfo} from "./author_info.astro";
|
|
2
2
|
export {default as Baidumap} from "./baidumap.astro";
|
|
3
3
|
export {default as BannerSwiper} from "./banner_swiper.astro";
|
|
4
|
+
export {default as BannerSplide} from "./banner_splide.astro";
|
|
4
5
|
export {default as Block} from "./block.astro";
|
|
5
6
|
export {default as BookSiderTree} from "./book_sider_tree.astro";
|
|
6
7
|
export {default as Breadcrumbs} from "./breadcrumbs.astro";
|
|
@@ -83,4 +84,6 @@ export * from "./smartmenus/index.ts";
|
|
|
83
84
|
export * from "./stats/index.ts";
|
|
84
85
|
export * from "./teams/index.ts";
|
|
85
86
|
export * from "./testimonials/index.ts";
|
|
86
|
-
export * from "./timelines/index.ts";
|
|
87
|
+
export * from "./timelines/index.ts";
|
|
88
|
+
|
|
89
|
+
export * from "./slide/index.ts";
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Icon } from "astro-icon/components";
|
|
3
|
+
---
|
|
4
|
+
<jeawin-swiper1>
|
|
5
|
+
<div class="carousel-container">
|
|
6
|
+
<div class="carousel-list">
|
|
7
|
+
<div class="carousel-item item1">1</div>
|
|
8
|
+
<div class="carousel-item item2">2</div>
|
|
9
|
+
<div class="carousel-item item3">3</div>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="carousel-arrow carousel-arrow-left"><Icon name="fa6-solid:arrow-left" /></div>
|
|
12
|
+
<div class="carousel-arrow carousel-arrow-right"><Icon name="fa6-solid:arrow-right" /></div>
|
|
13
|
+
<div class="indicator">
|
|
14
|
+
<span class="active"></span>
|
|
15
|
+
<span></span>
|
|
16
|
+
<span></span>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</jeawin-swiper1>
|
|
20
|
+
<style>
|
|
21
|
+
.carousel-container{
|
|
22
|
+
width:300px;
|
|
23
|
+
height:200px;
|
|
24
|
+
position: relative;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
border:1px solid #000;
|
|
27
|
+
margin:0 auto;
|
|
28
|
+
}
|
|
29
|
+
.carousel-list{
|
|
30
|
+
width:100%;
|
|
31
|
+
height:100%;
|
|
32
|
+
display: flex;
|
|
33
|
+
/* flex-direction: row; */
|
|
34
|
+
/* flex-wrap: nowrap; */
|
|
35
|
+
z-index: -1;
|
|
36
|
+
}
|
|
37
|
+
.carousel-item{
|
|
38
|
+
width:100%;
|
|
39
|
+
height:100%;
|
|
40
|
+
flex: none;
|
|
41
|
+
}
|
|
42
|
+
.carousel-item.item1{
|
|
43
|
+
background-color: red;
|
|
44
|
+
}
|
|
45
|
+
.carousel-item.item2{
|
|
46
|
+
background-color: orange;
|
|
47
|
+
}
|
|
48
|
+
.carousel-item.item3{
|
|
49
|
+
background-color: green;
|
|
50
|
+
}
|
|
51
|
+
.carousel-arrow{
|
|
52
|
+
position: absolute;
|
|
53
|
+
/* border:1px solid #000; */
|
|
54
|
+
width:30px;
|
|
55
|
+
height:30px;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
text-align: center;
|
|
58
|
+
top:50%;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
background: rgba(255,255,255,0.6);
|
|
61
|
+
color:#fff;
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
}
|
|
66
|
+
.carousel-arrow-left{
|
|
67
|
+
left:8px;
|
|
68
|
+
transform: translate3d(0, -50%, 0);
|
|
69
|
+
}
|
|
70
|
+
.carousel-arrow-right{
|
|
71
|
+
right:8px;
|
|
72
|
+
transform: translate3d(0, -50%, 0);
|
|
73
|
+
}
|
|
74
|
+
.indicator{
|
|
75
|
+
display:flex;
|
|
76
|
+
position: absolute;
|
|
77
|
+
bottom:8px;
|
|
78
|
+
left:50%;
|
|
79
|
+
gap:2px;
|
|
80
|
+
transform: translate3d(-50%, 0, 0);
|
|
81
|
+
}
|
|
82
|
+
.indicator span{
|
|
83
|
+
border:1px solid #fff;
|
|
84
|
+
width:10px;
|
|
85
|
+
height:10px;
|
|
86
|
+
border-radius: 50%;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
.indicator span.active{
|
|
90
|
+
background-color: #fff;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
93
|
+
<script>
|
|
94
|
+
class JeawinSwiper1 extends HTMLElement{
|
|
95
|
+
|
|
96
|
+
carouselList: any
|
|
97
|
+
arrowLeft: any
|
|
98
|
+
arrowRight: any
|
|
99
|
+
indicators: any
|
|
100
|
+
count: number
|
|
101
|
+
curIndex: number
|
|
102
|
+
|
|
103
|
+
constructor() {
|
|
104
|
+
super();
|
|
105
|
+
|
|
106
|
+
this.carouselList = this.querySelector('.carousel-list');
|
|
107
|
+
this.arrowLeft = this.querySelector('.carousel-arrow-left');
|
|
108
|
+
this.arrowRight = this.querySelector('.carousel-arrow-right');
|
|
109
|
+
this.indicators = this.querySelectorAll('.indicator span');
|
|
110
|
+
|
|
111
|
+
this.count = this.indicators.length; // 轮播图数量
|
|
112
|
+
this.curIndex = 0;
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
connectedCallback() {
|
|
118
|
+
this.init();
|
|
119
|
+
// 往前
|
|
120
|
+
this.arrowLeft.addEventListener('click', ()=>{
|
|
121
|
+
if(this.curIndex === 0){
|
|
122
|
+
this.carouselList.style.transition = 'none';
|
|
123
|
+
this.carouselList.style.transform = `translateX(-${this.count * 100}%)`;
|
|
124
|
+
// 强制渲染
|
|
125
|
+
this.carouselList.clientWidth;
|
|
126
|
+
this.moveTo(this.count - 1);
|
|
127
|
+
}else{
|
|
128
|
+
this.moveTo(this.curIndex - 1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
});
|
|
132
|
+
// 往后
|
|
133
|
+
this.arrowRight.addEventListener('click', () =>{
|
|
134
|
+
if(this.curIndex === this.count - 1){
|
|
135
|
+
this.carouselList.style.transition = 'none';
|
|
136
|
+
this.carouselList.style.transform = `translateX(100%)`;
|
|
137
|
+
// 强制渲染
|
|
138
|
+
this.carouselList.clientWidth;
|
|
139
|
+
this.moveTo(0);
|
|
140
|
+
}else{
|
|
141
|
+
this.moveTo(this.curIndex + 1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
// 指示器
|
|
145
|
+
this.indicators.forEach((itm: any, index: number) => {
|
|
146
|
+
itm.addEventListener('click', ()=>{
|
|
147
|
+
this.moveTo(index);
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
init(){
|
|
153
|
+
const lastCloned = this.carouselList.lastElementChild.cloneNode(true);
|
|
154
|
+
const firstCloned = this.carouselList.firstElementChild.cloneNode(true);
|
|
155
|
+
this.carouselList.insertBefore(lastCloned, this.carouselList.firstElementChild);
|
|
156
|
+
this.carouselList.appendChild(firstCloned);
|
|
157
|
+
lastCloned.style.marginLeft = '-100%';
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
moveTo(index: number){
|
|
161
|
+
this.curIndex = index;
|
|
162
|
+
if(this.carouselList){
|
|
163
|
+
this.carouselList.style.transform = `translateX(-${index * 100}%)`;
|
|
164
|
+
this.carouselList.style.transition = 'transform 0.5s';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.indicators.forEach((indicator: any, idx: number) => {
|
|
168
|
+
indicator.classList.toggle('active', index === idx);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
customElements.define('jeawin-swiper1', JeawinSwiper1);
|
|
177
|
+
|
|
178
|
+
</script>
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Icon } from "astro-icon/components";
|
|
3
|
+
---
|
|
4
|
+
<jeawin-swiper3d>
|
|
5
|
+
<div class="carousel-container">
|
|
6
|
+
<div class="carousel-list">
|
|
7
|
+
<div class="carousel-item item1">
|
|
8
|
+
<img
|
|
9
|
+
src="https://img.jeawincdn.com/resource/upfiles/245/images/resize/c5090173eec68cbaccb1e6b0576de70a/google-seo-guideline-2025_OGx6L4-1643x1062.webp"
|
|
10
|
+
alt=""
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="carousel-item item2">
|
|
14
|
+
<img
|
|
15
|
+
src="https://img.jeawincdn.com/resource/upfiles/245/images/resize/818bfcbea4bb3fe5d3f641fb06337661/google-seo-2025_VuQ5Ea-1920x1097.webp"
|
|
16
|
+
alt=""
|
|
17
|
+
/></div>
|
|
18
|
+
<div class="carousel-item item3">
|
|
19
|
+
<img
|
|
20
|
+
src="https://img.jeawincdn.com/resource/upfiles/245/images/resize/586833e9e667e28f577b2b6b30486a3f/choosing-the-right-google-seo-company_Qwixn6-960x540.webp"
|
|
21
|
+
alt=""
|
|
22
|
+
/></div>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="carousel-arrow carousel-arrow-left"><Icon name="fa6-solid:arrow-left" /></div>
|
|
25
|
+
<div class="carousel-arrow carousel-arrow-right"><Icon name="fa6-solid:arrow-right" /></div>
|
|
26
|
+
<div class="indicator">
|
|
27
|
+
<span class="active"></span>
|
|
28
|
+
<span></span>
|
|
29
|
+
<span></span>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</jeawin-swiper3d>
|
|
33
|
+
<style>
|
|
34
|
+
.carousel-container{
|
|
35
|
+
width:300px;
|
|
36
|
+
height:400px;
|
|
37
|
+
position: relative;
|
|
38
|
+
/* overflow: hidden; */
|
|
39
|
+
/* border:1px solid #000; */
|
|
40
|
+
margin:0 auto;
|
|
41
|
+
}
|
|
42
|
+
.carousel-list{
|
|
43
|
+
width:100%;
|
|
44
|
+
height:100%;
|
|
45
|
+
/* display: flex; */
|
|
46
|
+
/* flex-direction: row; */
|
|
47
|
+
/* flex-wrap: nowrap; */
|
|
48
|
+
z-index: -1;
|
|
49
|
+
}
|
|
50
|
+
.carousel-item{
|
|
51
|
+
width:100%;
|
|
52
|
+
height:100%;
|
|
53
|
+
position: absolute;
|
|
54
|
+
display: flex;
|
|
55
|
+
background-color: #fff;
|
|
56
|
+
}
|
|
57
|
+
.carousel-item img{
|
|
58
|
+
object-fit: contain;
|
|
59
|
+
}
|
|
60
|
+
/* .carousel-item.item1{
|
|
61
|
+
background-color: red;
|
|
62
|
+
}
|
|
63
|
+
.carousel-item.item2{
|
|
64
|
+
background-color: orange;
|
|
65
|
+
}
|
|
66
|
+
.carousel-item.item3{
|
|
67
|
+
background-color: green;
|
|
68
|
+
} */
|
|
69
|
+
.carousel-arrow{
|
|
70
|
+
position: absolute;
|
|
71
|
+
/* border:1px solid #000; */
|
|
72
|
+
width:30px;
|
|
73
|
+
height:30px;
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
text-align: center;
|
|
76
|
+
top:50%;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
background: rgba(255,255,255,0.6);
|
|
79
|
+
color:#fff;
|
|
80
|
+
z-index:100;
|
|
81
|
+
display:flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
}
|
|
85
|
+
.carousel-arrow-left{
|
|
86
|
+
left:8px;
|
|
87
|
+
transform: translate3d(0, -50%, 0);
|
|
88
|
+
}
|
|
89
|
+
.carousel-arrow-right{
|
|
90
|
+
right:8px;
|
|
91
|
+
transform: translate3d(0, -50%, 0);
|
|
92
|
+
}
|
|
93
|
+
.indicator{
|
|
94
|
+
display:flex;
|
|
95
|
+
position: absolute;
|
|
96
|
+
bottom:8px;
|
|
97
|
+
left:50%;
|
|
98
|
+
gap:2px;
|
|
99
|
+
transform: translate3d(-50%, 0, 0);
|
|
100
|
+
z-index:100;
|
|
101
|
+
}
|
|
102
|
+
.indicator span{
|
|
103
|
+
border:1px solid #fff;
|
|
104
|
+
width:10px;
|
|
105
|
+
height:10px;
|
|
106
|
+
border-radius: 50%;
|
|
107
|
+
cursor: pointer;
|
|
108
|
+
}
|
|
109
|
+
.indicator span.active{
|
|
110
|
+
background-color: #fff;
|
|
111
|
+
}
|
|
112
|
+
</style>
|
|
113
|
+
<script>
|
|
114
|
+
class JeawinSwiper3d extends HTMLElement{
|
|
115
|
+
|
|
116
|
+
carouselList: any;
|
|
117
|
+
arrowLeft: any;
|
|
118
|
+
arrowRight: any;
|
|
119
|
+
indicators: any;
|
|
120
|
+
count: number;
|
|
121
|
+
curIndex: number;
|
|
122
|
+
|
|
123
|
+
constructor(){
|
|
124
|
+
super();
|
|
125
|
+
|
|
126
|
+
this.carouselList = this.querySelector('.carousel-list');
|
|
127
|
+
|
|
128
|
+
this.arrowLeft = this.querySelector('.carousel-arrow-left');
|
|
129
|
+
this.arrowRight = this.querySelector('.carousel-arrow-right');
|
|
130
|
+
this.indicators = this.querySelectorAll('.indicator span');
|
|
131
|
+
this.count = this.indicators.length; // 轮播图数量
|
|
132
|
+
this.curIndex = 0;
|
|
133
|
+
|
|
134
|
+
// this.onPrev = this.onPrev.bind(this);
|
|
135
|
+
// this.onNext = this.onNext.bind(this);
|
|
136
|
+
// this.moveTo = this.moveTo.bind(this);
|
|
137
|
+
}
|
|
138
|
+
connectedCallback() {
|
|
139
|
+
|
|
140
|
+
// 往前
|
|
141
|
+
this.arrowLeft.addEventListener('click', ()=>{
|
|
142
|
+
this.onPrev();
|
|
143
|
+
});
|
|
144
|
+
// 往后
|
|
145
|
+
this.arrowRight.addEventListener('click', () =>{
|
|
146
|
+
this.onNext();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// this.init();
|
|
150
|
+
this.layout();
|
|
151
|
+
|
|
152
|
+
// 指示器
|
|
153
|
+
this.indicators.forEach((itm: any, index: number) => {
|
|
154
|
+
itm.addEventListener('click', ()=>{
|
|
155
|
+
this.moveTo(index);
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
onPrev(){
|
|
160
|
+
if(this.curIndex === 0){
|
|
161
|
+
// this.carouselList.style.transition = 'none';
|
|
162
|
+
// this.carouselList.style.transform = `translateX(-${this.count * 100}%)`;
|
|
163
|
+
// 强制渲染
|
|
164
|
+
// this.carouselList.clientWidth;
|
|
165
|
+
this.moveTo(this.count - 1);
|
|
166
|
+
}else{
|
|
167
|
+
this.moveTo(this.curIndex - 1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
onNext(){
|
|
171
|
+
if(this.curIndex === this.count - 1){
|
|
172
|
+
// this.carouselList.style.transition = 'none';
|
|
173
|
+
// this.carouselList.style.transform = `translateX(100%)`;
|
|
174
|
+
// 强制渲染
|
|
175
|
+
// this.carouselList.clientWidth;
|
|
176
|
+
this.moveTo(0);
|
|
177
|
+
}else{
|
|
178
|
+
this.moveTo(this.curIndex + 1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
moveTo(index: number){
|
|
182
|
+
this.curIndex = index;
|
|
183
|
+
// this.carouselList.style.transform = `translateX(-${index * 100}%)`;
|
|
184
|
+
// this.carouselList.style.transition = 'transform 0.5s';
|
|
185
|
+
this.indicators.forEach((indicator: any, idx: number) => {
|
|
186
|
+
indicator.classList.toggle('active', index === idx);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
this.layout();
|
|
190
|
+
}
|
|
191
|
+
init(){
|
|
192
|
+
const lastCloned = this.carouselList.lastElementChild.cloneNode(true);
|
|
193
|
+
const firstCloned = this.carouselList.firstElementChild.cloneNode(true);
|
|
194
|
+
this.carouselList.insertBefore(lastCloned, this.carouselList.firstElementChild);
|
|
195
|
+
this.carouselList.appendChild(firstCloned);
|
|
196
|
+
lastCloned.style.marginLeft = '-100%';
|
|
197
|
+
}
|
|
198
|
+
layout(){
|
|
199
|
+
const carouselItems = this.querySelectorAll('.carousel-item');
|
|
200
|
+
const offsetStep = 10;
|
|
201
|
+
const scaleStep = 0.6;
|
|
202
|
+
const opacityStep = 0.6;
|
|
203
|
+
|
|
204
|
+
for(let i=0; i<carouselItems.length;i++){
|
|
205
|
+
const item: any = carouselItems[i];
|
|
206
|
+
const dis = i - this.curIndex;
|
|
207
|
+
let xOffset = dis * offsetStep;
|
|
208
|
+
const sign = Math.sign(dis);
|
|
209
|
+
let rotateY = 0;
|
|
210
|
+
if(i !== this.curIndex){
|
|
211
|
+
xOffset = xOffset + 100 * sign;
|
|
212
|
+
rotateY = 45 * -sign;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const scale = scaleStep ** Math.abs(dis);
|
|
216
|
+
item.style.transform = `translatex(${xOffset}px) scale(${scale}) rotateY(${rotateY}deg)`;
|
|
217
|
+
const zIndex = carouselItems.length - Math.abs(dis);
|
|
218
|
+
item.style.zIndex = zIndex;
|
|
219
|
+
const opacity = opacityStep ** Math.abs(dis);
|
|
220
|
+
item.style.opacity = opacity;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
customElements.define('jeawin-swiper3d', JeawinSwiper3d);
|
|
225
|
+
|
|
226
|
+
</script>
|
package/src/styles/global.css
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
@plugin "tailwind-scrollbar";
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
thead tr th{
|
|
8
|
+
.prose thead tr th{
|
|
9
9
|
background: var(--color-blue-50);
|
|
10
10
|
padding: calc(var(--spacing) * 2);
|
|
11
11
|
white-space: nowrap;
|
|
12
12
|
min-width:calc(var(--spacing) * 30);
|
|
13
13
|
}
|
|
14
|
-
tbody tr td{
|
|
14
|
+
.prose tbody tr td{
|
|
15
15
|
padding: calc(var(--spacing) * 2);
|
|
16
16
|
}
|