-
Notifications
You must be signed in to change notification settings - Fork 6
/
cropcircletest.html
117 lines (104 loc) · 3.88 KB
/
cropcircletest.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
<html>
<head>
<script type="text/javascript">
var CropCircle;
function init() {
CropCircle($("#testBox"), {
handles: 8,
forceAspect: 1,
showHelp: true,
onFrameChanged: function(frame) {
console.log(frame);
var preview = $('#preview-box');
var testBox = $('#testBox');
var bounds = {
top: -(frame.top/frame.height*preview.height()),
bottom: -(frame.bottom/frame.height*preview.height()),
left: -(frame.left/frame.width*preview.width()),
right: -(frame.right/frame.width*preview.width()),
};
bounds.width = Math.abs(bounds.left) + preview.width() + Math.abs(bounds.right);
bounds.height = Math.abs(bounds.top) + preview.height() + Math.abs(bounds.bottom);
bounds.right = undefined;
bounds.bottom = undefined;
$('#preview').css(bounds);
},
circle: true,
});
}
//superhaxored requirejs stub
function define(deps, func) {
CropCircle = func($);
}
</script>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="cropcircle.js"></script>
<style>
body {
text-align: center;
font-family: Helvetica, sans-serif;
margin: 20px;
}
#testBox {
border: 1px solid #666;
background: grey;
margin: auto;
position: relative;
overflow: hidden;
}
#testBox img {
width: 100%;
}
.crop-circle-crop-frame {
border: 40px solid rgba(0, 0, 0, 0.8);
}
.crop-circle-handle {
width: 10px;
height: 10px;
background-color: white;
box-shadow: 0 0 5px black;
}
.crop-circle-touch .crop-circle-handle {
display: none;
}
.crop-circle-help {
color: white;
text-shadow: 2px 2px 2px black;
font-size: 20px;
position: absolute;
z-index: 1000;
top: 10px;
left: 10px;
}
#preview-box {
overflow: hidden;
width: 150px;
height: 150px;
border-radius: 50%;
margin-top: 20px;
margin-right: 20px;
float: left;
}
#preview {
position: relative;
}
#caption {
margin-top: 20px;
margin-left: 20px;
text-align: left;
}
</style>
</head>
<body onload="init()">
<a href="https://github.com/AvocadoCorp/CropCircle"><img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a>
<div id="testBox">
<!-- image credit: https://www.flickr.com/photos/three_french_hens/ -->
<img src="crop-circle.jpg">
</div>
<div id="preview-box">
<img id="preview" src="crop-circle.jpg"/>
</div>
<div id="caption">
Try it on mobile too! Also, fork this repo and play with the settings. You can have nonsquare or unconstrained crop area aspect ratios, four or eight handles, and a configurable initial crop region. Also try resizing the window or changing orientation on a mobile device.
</body>
</html>