-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdemo.html
145 lines (132 loc) · 3.4 KB
/
demo.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
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
<title>iCropper - Javascript Image Cropper</title>
<link href="icropper.css" rel="stylesheet"/>
<script type="text/javascript" src="icropper.js"></script>
<style type="text/css">
.demoWrapper {
padding: 20px;
border-top: 2px solid #eee;
width: 800px;
margin: auto;
}
.cropperContainer {
float: left;
border: 0px solid #eee;
min-width: 440px;/*Used to improve layout during loading the image.*/
min-height: 327px;
}
.previews {
float: left;
margin-left: 0px;
}
.previewSmall {
margin: 40px;
width: 60px;
height: 60px;
}
.previewBig {
margin: 40px;
width: 100px;
height: 100px;
}
.info {
clear: both;
padding: 5px;
font-family: Arial;
font-size: 12px;
color: #777;
}
h1 {
font-family: Arial;
color: #777;
text-align: center;
}
h2 {
font-family: Arial;
color: #777;
}
</style>
</head>
<body>
<h1>Demos</h1>
<div id="demo1" class="demoWrapper">
<h2>Keep crop area square</h2>
<div id="cropperContainer1" class="cropperContainer"></div>
<div class="previews">
<div id="previewSmall1" class="previewSmall"></div>
<div id="previewBig1" class="previewBig"></div>
</div>
<div id="info1" class="info"></div>
</div>
<div id="demo2" class="demoWrapper">
<h2>Free resizing (shift key to keep square)</h2>
<div id="cropperContainer2" class="cropperContainer"></div>
<div class="previews">
<div id="previewSmall2" class="previewSmall"></div>
<div id="previewBig2" class="previewBig"></div>
</div>
<div id="info2" class="info"></div>
</div>
<div id="demo3" class="demoWrapper">
<h2>Keep width:height = 2:1</h2>
<div id="cropperContainer3" class="cropperContainer"></div>
<div class="previews">
<div id="previewSmall3" class="previewSmall"></div>
<div id="previewBig3" class="previewBig"></div>
</div>
<div id="info3" class="info"></div>
</div>
</body>
<script type="text/javascript">
var infoNode1 = document.getElementById('info1');
var ic1 = new ICropper(
'cropperContainer1'
,{
ratio: 1
,image: 'demo.png'
,onChange: function(info){ //onChange must be set when constructing.
infoNode1.innerHTML = 'Left: ' + info.l + 'px, Top: '+info.t
+ 'px, Width: ' + info.w + 'px, Height: ' + info.h+'px';
}
,preview: [
'previewSmall1'
]
});
//use bindPreview to dynamically add preview nodes
ic1.bindPreview('previewBig1');
var infoNode2 = document.getElementById('info2');
var ic2 = new ICropper(
'cropperContainer2'
,{
ratio: 0
,image: 'demo.png'
,onChange: function(info){ //onChange must be set when constructing.
infoNode2.innerHTML = 'Left: ' + info.l + 'px, Top: ' + info.t
+ 'px, Width: ' + info.w + 'px, Height: ' + info.h + 'px';
}
,preview: [
'previewSmall2'
]
});
//use bindPreview to dynamically add preview nodes
ic2.bindPreview('previewBig2');
var infoNode3 = document.getElementById('info3');
var ic3 = new ICropper(
'cropperContainer3'
,{
ratio: 2
,image: 'demo.png'
,onChange: function(info){ //onChange must be set when constructing.
infoNode3.innerHTML = 'Left: ' + info.l + 'px, Top: ' + info.t
+ 'px, Width: ' + info.w + 'px, Height: ' + info.h + 'px';
}
,preview: [
'previewSmall3'
]
});
//use bindPreview to dynamically add preview nodes
ic3.bindPreview('previewBig3');
</script>
</html>