forked from 929467350/swiper.animate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
90 lines (84 loc) · 3.22 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css" id="style0" rel="stylesheet">
<link href="https://cdn.bootcss.com/Swiper/4.5.1/css/swiper.min.css" id="style1" rel="stylesheet">
<script src="https://cdn.bootcss.com/Swiper/4.5.1/js/swiper.min.js" id="swiper" type="text/javascript"
charset="utf-8"></script>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<p class="ani"
swiper-animate-effect='[{"value":"fadeInRight","duration":1,"loop":1,"delay":0},{"value":"fadeInLeft","duration":1,"loop":2,"delay":0}]'>
slider1</p>
</div>
<div class="swiper-slide">
<p class="ani"
swiper-animate-effect='[{"value":"fadeInRight","duration":1,"loop":1,"delay":0},{"value":"fadeInLeft","duration":1,"loop":1,"delay":0}]'>
slider2</p>
</div>
<div class="swiper-slide">
<p class="ani"
swiper-animate-effect='[{"value":"fadeInRight","duration":1,"loop":1,"delay":0},{"value":"fadeInLeft","duration":1,"loop":1,"delay":0}]'>
slider3</p>
</div>
</div>
</div>
<script src="./swiper.animate.js"></script>
<script>
let mySwiper = new Swiper('.swiper-container', {
on: {
init() {
window.swiperAnimate(this);
},
slideChangeTransitionEnd() {
window.swiperAnimate(this);
}
}
});
// 动态设置动画
let ani = [{
"value": "fadeInRight",
"duration": 1,
"loop": 1,
"delay": 0
}, {
"value": "fadeInLeft",
"duration": 1,
"loop": 1,
"delay": 0
}, {
"value": "fadeIn",
"duration": 1,
"loop": 0,
"delay": 0
}, ];
for (let i = 0; i < 3; i++) {
let div = document.createElement('div');
let p = document.createElement('p');
p.innerText = '这是一个新的Slide';
p.className = 'ani';
p.setAttribute('swiper-animate-effect', JSON.stringify(ani));
div.appendChild(p);
div.className = 'swiper-slide';
mySwiper.addSlide(1, div);
mySwiper.updateSlides();
}
</script>
</body>
</html>