Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
119 lines (108 loc) · 3.27 KB
/
Copy pathindex.html
File metadata and controls
119 lines (108 loc) · 3.27 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>图片裁剪</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=0">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<style type="text/css">
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { margin:0; padding:0; }
body { background:#fff; color:#555; font-size:14px; font-family: Verdana, Arial, Helvetica, sans-serif; }
td,th,caption { font-size:14px; }
h1, h2, h3, h4, h5, h6 { font-weight:normal; font-size:100%; }
address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal;}
a { color:#555; text-decoration:none; }
a:hover { text-decoration:underline; }
img { border:none; }
ol,ul,li { list-style:none; }
input, textarea, select, button { font:14px Verdana,Helvetica,Arial,sans-serif; }
table { border-collapse:collapse; }
html {overflow-y: scroll;}
.clearfix:after {content: "."; display: block; height:0; clear:both; visibility: hidden;}
.clearfix { zoom:1 }
</style>
<script type="text/javascript" src="js/jCrop.js"></script>
<style type="text/css">
html,body{
width: 100%;
height: 100%;
}
.view{
width: 100%;
height: 80%;
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
}
.btn{
width: 100%;
height: 30px;
line-height: 30px;
text-align: center;
cursor: pointer;
}
.result{
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
padding: 10px;
border: 1px solid #ccc;
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="view">
</div>
<div class="btn">Click</div>
<div class="result">
</div>
<script type="text/javascript">
window.addEventListener('DOMContentLoaded',ready,false);
function ready(){
var cropper = jCrop('images/result4.jpg',{
croperWidth: 800,
croperHeight: 600,
width: 300,
height: 300,
shadowColor: 'rgba(0,0,0,0.7)',
lineColor: '#fff',
dashLineColor: 'rgba(255,255,255,0.8)',
edgeWidth: 3,
quality: 1,
offBackgroundColor: 'rgba(0,0,0,0.6)',
onBackgroundColor: 'rgba(0,0,0,0.2)',
imgType: 'image/jpeg',
compressOnly: false,
scalable: true,
scaleStep: 0.05,
created: function(canvas,width,height){
document.querySelector('.view').appendChild(canvas);
}
});
console.log(cropper);
document.querySelector('.btn').addEventListener('click',function(){
var resultEl = document.querySelector('.result'),
img = new Image();
img.src = cropper.cut();
img.width = cropper.width;
img.height = cropper.height;
img.onload = function(){
resultEl.firstElementChild && resultEl.removeChild(resultEl.firstElementChild);
resultEl.appendChild(img);
};
/*resultEl.firstElementChild && resultEl.removeChild(resultEl.firstElementChild);
resultEl.appendChild(cropper.cut());*/
},false);
}
function logout(){
window.removeEventListener('DOMContentLoaded',ready,false);
window.removeEventListener('unload',logout,false);
}
window.addEventListener('unload',logout,false);
</script>
</body>
</html>