Slideshow.js
4.5 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//*
// 图片轮播
// */
import Loger from "../Loger";
import Ape from "./Ape";
import xdysdk from "libs/xdysdk";
import DrawTool from "./DrawTool";
import LaserPen from "./LaserPen";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-Slideshow');
class Slideshow extends Ape {
constructor() {
super();
this._timer = null;
this.windowWidth = 0;
this.num = 0;
this.len = 0;
this.addEvent();
this.init();
}
init() {
$(window).on('resize',this._imgReload.bind(this));
this.slideImg();
this._imgReload();
$(".slidesImg").on('load', this._onLoadImage.bind(this));
$('#dots').on('mouseenter',this._mouseenterHandler.bind(this));
$('#dots').on('mouseleave',this._mouseleaveHandler.bind(this));
}
addEvent() {
}
_onLoadImage(){
this._imgReload();
}
slideImg(){
let oli = document.getElementById('dots').getElementsByTagName("li");
let _num = 0;
let clone=$(".slidesMap").first().clone();
$("#motionMapBox").append(clone);
let li = document.getElementById('motionMapBox').getElementsByTagName("li");
let size = li.length
this.num = _num;
this.len = size;
this._timer = setInterval(function(){
li[_num].style.display="none";
_num=++_num==size ? 0:_num;
li[_num].style.display="inline-block";
// $("#motionMapBox").stop().animate({left:-this.num*this.windowWidth},500);
$("#dots li").eq(_num).addClass('active').siblings().removeClass('active');
},3000);//切换时间
}
_mouseenterHandler(){
clearInterval(this._timer);
}
_mouseleaveHandler(){
setInterval(this._timer);
}
_move(){
let li = document.getElementById('motionMapBox').getElementsByTagName("li");
this._timer = setInterval(function(){
li[_num].style.display="none";
_num=++_num==size ? 0:_num;
li[_num].style.display="inline-block";
// $("#motionMapBox").stop().animate({left:-this.num*this.windowWidth},500);
$("#dots li").eq(_num).addClass('active').siblings().removeClass('active');
},3000);//切换时间
}
slideImg(){
let i = 0;
let width = $('.slidesMap').width();
let clone=$(".slidesMap").first().clone();
$("#motionMapBox").append(clone);
let size = document.getElementById('motionMapBox').getElementsByTagName("li").length;
for(let j=0;j<size-1;j++){
$("#dots").append("<li></li>");
}
$("#dots li").first().addClass('active');
/* $(".dots li").hover(function(){
let index=$(this).index();
i=index;
$(".motionMapBox").stop().animate({left:-index*width},500);
$(this).addClass('active').siblings().removeClass('active');
})*/
/* let t=setInterval(function(){
i++;
move();
},2000);
//对banner定时器的操作
$(".slideshow").hover(function(){
clearInterval(t);
},function(){
t=setInterval(move,2000);
})*/
/*function move(){
if(i==size){
$("#motionMapBox").css({left:0});
i=1;
}
if(i==-1){
$("#motionMapBox").css({left:-(size-1)*width});
i=size-2;
}
$("#motionMapBox").stop().animate({left:-i*width},500);
if(i==size-1){
$("#dots li").eq(0).addClass('active').siblings().removeClass('active');
}else{
$("#dots li").eq(i).addClass('active').siblings().removeClass('active');
}
}*/
}
_imgReload(){
let _windowWidth = $("body").width();
this.windowWidth = _windowWidth;
$('.slidesMap').css({width:_windowWidth + "px"});
$('.slidesImg').css({width:_windowWidth + "px"});
/* let imgHeight = 0;
let wtmp = $("body").width();
$("#motionMapBox li").each(function(){
$(this).css({width:wtmp + "px"});
});
$(".slidesImg").each(function(){
$(this).css({width:wtmp + "px"});
imgHeight = $(this).height();
});*/
$('#motionMapBox').width($(".slidesMap").length * _windowWidth)
}
}
export default new Slideshow;