UIMagnifyApe.js
1.9 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
//*
// 控制UI界面的模块
// */
import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
let loger = Loger.getLoger('PC-UIMagnifyApe');
class UIMagnifyApe extends Ape {
constructor() {
super();
this.parentBox = null;
// this.init();
}
init(_box){
if(_box){
this.parentBox=_box;
}else {
console.error("没有父级盒子");
return;
}
let newDiv = document.createElement('div');
newDiv.className = 'imagesLargerBox';
let magnifyHeadline = document.createElement('div');
magnifyHeadline.className = 'magnifyHeadline';
newDiv.appendChild(magnifyHeadline);
let magnifyHeadlineA = document.createElement('a');
magnifyHeadlineA.innerHTML = "";
magnifyHeadlineA.className = 'magnifyHeadlineA iconfont';
magnifyHeadlineA.setAttribute('href','javascript: void(0)')
magnifyHeadline.appendChild(magnifyHeadlineA);
let magnifyImgBox = document.createElement('div');
magnifyImgBox.className = 'magnifyImgBox';
newDiv.appendChild(magnifyImgBox);
let magnifyImg = document.createElement('img');
magnifyImg.className = 'magnifyImg';
magnifyImg.setAttribute('src',"")
magnifyImgBox.appendChild(magnifyImg);
this.parentBox.append(newDiv);
//添加关闭事件
$('.magnifyHeadlineA').on('click',this.hide.bind(this));
}
show(_url){
$('#magnifyBox').show();
this._showImagesLarger(_url);
}
//隐藏图片大图
hide(){
$('#magnifyBox').hide();
$('.magnifyImg').attr('src','')
}
//显示图片大图
_showImagesLarger(_url){
$('.magnifyImg').attr('src',_url)
}
}
export default new UIMagnifyApe;