Skip to content

Commit 0c29c8a

Browse files
committed
add jquery-cropper demo
1 parent 1621bc9 commit 0c29c8a

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

jquery-cropper图像裁剪/demo.html

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>itstrive--cropper-demo</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
7+
<meta name="apple-mobile-web-app-capable" content="yes">
8+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
9+
<style>
10+
.container{ width:500px; height:500px;}
11+
.container,#btn1{
12+
display: block;
13+
vertical-align: middle;
14+
float: left;
15+
}
16+
#btn1{ padding: 10px 20px; margin: 0 50px;}
17+
.box-container{float: left;}
18+
</style>
19+
<link rel="stylesheet" href="lib/cropper.min.css">
20+
<script src="lib/jquery.min.js"></script>
21+
<script src="lib/cropper.min.js"></script>
22+
<script>
23+
// 官网: https://fengyuanchen.github.io/cropper/
24+
$(function(){
25+
var oImg=$('.img1')[0];
26+
var oC=document.getElementById('c1');
27+
var gd=oC.getContext('2d');
28+
29+
var scale=2;
30+
31+
$('.container img').cropper({
32+
aspectRatio: NaN,
33+
crop: function(data){
34+
var sx=data.x;
35+
var sy=data.y;
36+
var sw=data.width;
37+
var sh=data.height;
38+
39+
//生成图形操作
40+
$('#btn1').click(function(){
41+
gd.clearRect(0,0,oC.width,oC.height);
42+
gd.drawImage(oImg,
43+
sx,sy,sw,sh,
44+
0,0,sw/scale,sh/scale
45+
);
46+
});
47+
}
48+
});
49+
50+
51+
});
52+
</script>
53+
</head>
54+
<body>
55+
<div class="container">
56+
<img src="m.jpg" class="img1">
57+
</div>
58+
<input type="button" value="生成" id="btn1">
59+
<div class="box-container">
60+
<canvas id="c1" width="500" height="500"></canvas>
61+
</div>
62+
</body>
63+
</html>
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+

jquery-cropper图像裁剪/lib/cropper.min.css

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery-cropper图像裁剪/lib/cropper.min.js

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery-cropper图像裁剪/lib/jquery.min.js

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery-cropper图像裁剪/m.jpg

521 KB
Loading

0 commit comments

Comments
 (0)