-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Expand file tree
/
Copy pathcropper.scss
More file actions
185 lines (159 loc) · 3.79 KB
/
cropper.scss
File metadata and controls
185 lines (159 loc) · 3.79 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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// Handle touch target size — used both for the handle ::before hit area and
// for the inner canvas inset (half the touch target on each side so the full
// reach extends to the crop edge).
$handle-touch-target-size: 44px;
.wp-media-editor-image-editor {
position: relative;
overflow: hidden;
width: 100%;
height: 100%;
touch-action: none;
user-select: none;
cursor: grab;
// Inner gutter for resize handles. Handles use negative offsets and a
// touch target that extends past the crop edge; the root clips overflow
// (required for the dimming overlay's box-shadow trick), so a flush
// handle would be clipped. The inner `__canvas` wrapper is inset by half
// the touch target, reserving reach room on all sides while keeping the
// root as the clipping boundary.
&__canvas {
position: absolute;
inset: calc($handle-touch-target-size / 2);
}
&--dragging {
cursor: grabbing;
}
&__image {
position: absolute;
top: 0;
left: 0;
will-change: transform;
transform-origin: center center;
}
&__stencil {
position: absolute;
pointer-events: none;
}
&__dimming {
position: absolute;
pointer-events: none;
/* Large shadow spread dims everything outside the crop area.
Darker at rest for clear crop framing, lighter during drag
so the user can see where they're panning. */
box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
transition: box-shadow 0.15s ease;
}
&--dragging &__dimming {
box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}
&__grid {
position: absolute;
pointer-events: none;
overflow: hidden;
transition: opacity 0.2s ease;
}
&__grid-line {
position: absolute;
background: rgba(255, 255, 255, 0.4);
&--horizontal {
left: 0;
width: 100%;
height: 1px;
}
&--vertical {
top: 0;
height: 100%;
width: 1px;
}
}
&__stencil-rect {
position: absolute;
border: 1px solid rgba(255, 255, 255, 0.7);
box-sizing: border-box;
pointer-events: none;
}
&__handle {
// Reset native <button> UA styles — the handle is a button for
// accessibility (native keyboard focus, button semantics), but
// it's styled as a small draggable circle.
appearance: none;
margin: 0;
padding: 0;
font: inherit;
cursor: default;
position: absolute;
width: 12px;
height: 12px;
background: rgba(255, 255, 255, 0.6);
border: 1px solid rgba(255, 255, 255, 0.9);
border-radius: 50%;
box-sizing: border-box;
pointer-events: auto;
transition: background-color 0.15s ease, box-shadow 0.15s ease;
&:focus {
outline: none;
}
// Double ring (white inner + theme-color outer) for legibility
// over the dark dimming overlay.
&:focus-visible {
background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
border-color: transparent;
box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
}
// Extend touch target to the minimum accessible hit area.
&::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: $handle-touch-target-size;
height: $handle-touch-target-size;
transform: translate(-50%, -50%);
}
/* Offset by half the handle width (12px / 2 = 6px) to center on crop edge */
&--n {
top: -6px;
left: 50%;
margin-left: -6px;
cursor: ns-resize;
}
&--s {
bottom: -6px;
left: 50%;
margin-left: -6px;
cursor: ns-resize;
}
&--e {
top: 50%;
right: -6px;
margin-top: -6px;
cursor: ew-resize;
}
&--w {
top: 50%;
left: -6px;
margin-top: -6px;
cursor: ew-resize;
}
&--nw {
top: -6px;
left: -6px;
cursor: nwse-resize;
}
&--ne {
top: -6px;
right: -6px;
cursor: nesw-resize;
}
&--sw {
bottom: -6px;
left: -6px;
cursor: nesw-resize;
}
&--se {
bottom: -6px;
right: -6px;
cursor: nwse-resize;
}
}
}