|
@@ -1,15 +1,35 @@
|
|
1
|
+// 请求接口前缀
|
|
2
|
+var Baseurl = "https://xhwebapitest.xhkjedu.com/dh/list";
|
|
3
|
+// $.ajax({
|
|
4
|
+// type: "POST",
|
|
5
|
+// url: Baseurl,
|
|
6
|
+// data: JSON.stringify({
|
|
7
|
+// examid: 434,
|
|
8
|
+// classid: 9666
|
|
9
|
+// }),
|
|
10
|
+// dataType: "json",
|
|
11
|
+// contentType: "application/json; charset=utf-8",
|
|
12
|
+// success: function (data) {
|
|
13
|
+// if (data.code === 0) {
|
|
14
|
+// loadSectionHtml(data.obj);
|
|
15
|
+// } else {
|
|
16
|
+// alert(data.msg);
|
|
17
|
+// }
|
|
18
|
+// }
|
|
19
|
+// });
|
1
|
20
|
var datalist = [
|
2
|
21
|
{ time: 2023 },
|
3
|
22
|
{ time: 2022 },
|
4
|
23
|
{ time: 2021 },
|
5
|
24
|
{ time: 2020 },
|
6
|
25
|
{ time: 2019 },
|
7
|
|
- { time: 2018 }
|
|
26
|
+ { time: 2018 },
|
|
27
|
+ { time: 2017 }
|
8
|
28
|
];
|
9
|
29
|
|
10
|
30
|
var html = "";
|
11
|
31
|
$.each(datalist, (idx, item) => {
|
12
|
|
- html += `<div class="round_q">
|
|
32
|
+ html += `<div class="round_q" index = "${idx + 1}">
|
13
|
33
|
<div class="round_item">
|
14
|
34
|
<div class="round_i"></div>
|
15
|
35
|
<div class="round_d">${item.time}</div>
|
|
@@ -28,30 +48,51 @@ var prev = $(".leftjt");
|
28
|
48
|
var next = $(".rightjt");
|
29
|
49
|
|
30
|
50
|
var index = 1; //存放当前显示的图片的下标
|
31
|
|
-var len = 5;
|
|
51
|
+var len = 5; //显示数量
|
32
|
52
|
var interval = 5000; //位移时间间隔
|
33
|
53
|
var timer;
|
34
|
|
-
|
|
54
|
+var offsetpx = (datalist.length - len) * divwidth; //可偏移度
|
|
55
|
+var offleft = 0; //当前偏移量
|
|
56
|
+console.log(offsetpx);
|
35
|
57
|
function animate(offset) {
|
36
|
58
|
console.log(index);
|
37
|
59
|
var left = parseInt(list.css("left")) + offset;
|
38
|
60
|
console.log(left, offset);
|
|
61
|
+ var absnum = Math.abs(offset);
|
|
62
|
+ if (left < 0 - offsetpx) {
|
|
63
|
+ //右侧没有数据时不偏移
|
|
64
|
+ return;
|
|
65
|
+ }
|
39
|
66
|
// 边界判断
|
40
|
67
|
if (offset > 0) {
|
41
|
68
|
offset = "+=" + offset;
|
|
69
|
+ offleft = offleft + absnum;
|
|
70
|
+ console.log(offset);
|
42
|
71
|
} else {
|
43
|
72
|
offset = "-=" + Math.abs(offset);
|
|
73
|
+ offleft = offleft - absnum;
|
|
74
|
+ console.log(0 - absnum, absnum);
|
|
75
|
+ }
|
|
76
|
+ // if (index == datalist.length) {
|
|
77
|
+ // offset = 0 - (datalist.length - 5) * absnum;
|
|
78
|
+ // offleft = offset;
|
|
79
|
+ // console.log(offset);
|
|
80
|
+ // }
|
|
81
|
+ console.log(offset, offleft, "当前偏移量");
|
|
82
|
+ if (offset >= 0) {
|
|
83
|
+ console.log(44444);
|
|
84
|
+ return;
|
44
|
85
|
}
|
45
|
|
-
|
46
|
86
|
list.animate({ left: offset }, 300, function () {
|
47
|
87
|
if (left > -200) {
|
48
|
|
- console.log(22);
|
|
88
|
+ console.log(22, (0 - offset) * len);
|
49
|
89
|
list.css("left", (0 - offset) * len);
|
50
|
90
|
}
|
51
|
|
- console.log(offset * len);
|
52
|
|
- if (left < offset * len) {
|
53
|
|
- console.log(111);
|
54
|
|
- list.css("left", 0 - offset);
|
|
91
|
+ if (index == datalist.length) {
|
|
92
|
+ offset = 0 - (datalist.length - 5) * absnum;
|
|
93
|
+ offleft = offset;
|
|
94
|
+ list.css("left", offset);
|
|
95
|
+ console.log(offset, 1231312);
|
55
|
96
|
}
|
56
|
97
|
});
|
57
|
98
|
}
|
|
@@ -59,7 +100,7 @@ function animate(offset) {
|
59
|
100
|
//亮起小圆点
|
60
|
101
|
function showButton() {
|
61
|
102
|
//当前图片的小圆点亮起,其他小圆点不亮
|
62
|
|
- console.log("gaoliang");
|
|
103
|
+ console.log(index, "gaoliang");
|
63
|
104
|
buts
|
64
|
105
|
.eq(index - 1)
|
65
|
106
|
.addClass("active")
|
|
@@ -67,6 +108,12 @@ function showButton() {
|
67
|
108
|
.removeClass("active");
|
68
|
109
|
}
|
69
|
110
|
|
|
111
|
+$(".develop_container").bind("mouseenter", () => {
|
|
112
|
+ stop();
|
|
113
|
+});
|
|
114
|
+$(".develop_container").bind("mouseleave", () => {
|
|
115
|
+ play();
|
|
116
|
+});
|
70
|
117
|
// 鼠标离开图片区域时,轮播继续
|
71
|
118
|
function play() {
|
72
|
119
|
timer = setTimeout(function () {
|
|
@@ -88,14 +135,19 @@ next.bind("click", function () {
|
88
|
135
|
}
|
89
|
136
|
|
90
|
137
|
// 判断当前图片是否是最后一张
|
91
|
|
- if (index == 5) {
|
|
138
|
+ if (index == datalist.length) {
|
92
|
139
|
index = 1;
|
|
140
|
+ console.log(222222);
|
|
141
|
+ offleft = 0;
|
|
142
|
+ list.animate({ left: 0 }, 300, () => {});
|
93
|
143
|
} else {
|
94
|
144
|
index += 1;
|
95
|
145
|
}
|
|
146
|
+ console.log(offleft, "当前偏移量");
|
96
|
147
|
console.log("you", index);
|
97
|
148
|
animate(0 - divwidth);
|
98
|
149
|
showButton();
|
|
150
|
+ stop();
|
99
|
151
|
});
|
100
|
152
|
|
101
|
153
|
// 左按钮事件
|
|
@@ -104,39 +156,45 @@ prev.bind("click", function () {
|
104
|
156
|
if (list.is(":animated")) {
|
105
|
157
|
return;
|
106
|
158
|
}
|
107
|
|
-
|
|
159
|
+ console.log(index);
|
108
|
160
|
// 判断当前图片是否是第一张
|
109
|
161
|
if (index == 1) {
|
110
|
|
- index = 5;
|
|
162
|
+ index = datalist.length;
|
111
|
163
|
} else {
|
112
|
164
|
index -= 1;
|
113
|
165
|
}
|
114
|
|
- console.log(zuo, index);
|
|
166
|
+ console.log("zuo", index);
|
|
167
|
+ console.log(offleft, "当前偏移量");
|
115
|
168
|
animate(divwidth);
|
116
|
169
|
showButton();
|
|
170
|
+ stop();
|
117
|
171
|
});
|
118
|
172
|
|
119
|
173
|
// 小圆点点击事件
|
120
|
|
-// buttons.each(function () {
|
121
|
|
-// $(this).bind("click", function () {
|
122
|
|
-// // 判断当前是否在进行动画
|
123
|
|
-// if (list.is(":animated") || $(this).attr("class") == "on") {
|
124
|
|
-// return;
|
125
|
|
-// }
|
126
|
|
-// // 获取属性
|
127
|
|
-// var myIndex = parseInt($(this).attr("index"));
|
128
|
|
-
|
129
|
|
-// //计算偏移量
|
130
|
|
-// var offset = -600 * (myIndex - index);
|
131
|
|
-
|
132
|
|
-// animate(offset);
|
|
174
|
+buts.each(function () {
|
|
175
|
+ $(this).bind("click", function () {
|
|
176
|
+ // 判断当前是否在进行动画
|
|
177
|
+ if (list.is(":animated") || $(this).attr("class") == "on") {
|
|
178
|
+ return;
|
|
179
|
+ }
|
|
180
|
+ // 获取属性
|
|
181
|
+ var myIndex = parseInt($(this).attr("index"));
|
|
182
|
+ console.log(myIndex);
|
|
183
|
+ //计算偏移量
|
|
184
|
+ var offset = (0 - divwidth) * (myIndex - index);
|
|
185
|
+ if (myIndex <= 2) {
|
|
186
|
+ offset = 0;
|
|
187
|
+ console.log(myIndex, 33333);
|
|
188
|
+ }
|
|
189
|
+ console.log(offleft, "当前偏移量");
|
|
190
|
+ animate(offset);
|
133
|
191
|
|
134
|
|
-// //切换后,更新当前的偏移量
|
135
|
|
-// index = myIndex;
|
|
192
|
+ //切换后,更新当前的偏移量
|
|
193
|
+ index = myIndex;
|
136
|
194
|
|
137
|
|
-// showButton();
|
138
|
|
-// });
|
139
|
|
-// });
|
|
195
|
+ showButton();
|
|
196
|
+ });
|
|
197
|
+});
|
140
|
198
|
|
141
|
199
|
container.hover(stop, play);
|
142
|
200
|
|