@etsoo/materialui 1.4.29 → 1.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/UserAvatarEditor.d.ts +1 -1
- package/lib/UserAvatarEditor.js +10 -9
- package/package.json +1 -1
- package/src/UserAvatarEditor.tsx +20 -16
|
@@ -8,7 +8,7 @@ export interface UserAvatarEditorToBlob {
|
|
|
8
8
|
* User avatar editor on done handler
|
|
9
9
|
*/
|
|
10
10
|
export interface UserAvatarEditorOnDoneHandler {
|
|
11
|
-
(canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob, type: string): void | false
|
|
11
|
+
(canvas: HTMLCanvasElement, toBlob: UserAvatarEditorToBlob, type: string): Promise<void | false | undefined>;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* User avatar editor props
|
package/lib/UserAvatarEditor.js
CHANGED
|
@@ -134,20 +134,21 @@ export function UserAvatarEditor(props) {
|
|
|
134
134
|
to.height = heightCalculated;
|
|
135
135
|
// Large photo, resize it
|
|
136
136
|
// https://github.com/nodeca/pica
|
|
137
|
-
picaInstance
|
|
138
|
-
.resize(data, to, {
|
|
137
|
+
const canvas = await picaInstance.resize(data, to, {
|
|
139
138
|
unsharpAmount: 160,
|
|
140
139
|
unsharpRadius: 0.6,
|
|
141
140
|
unsharpThreshold: 1
|
|
142
|
-
})
|
|
143
|
-
.then((result) => {
|
|
144
|
-
if (onDone(result, toBlob, type.current) === false) {
|
|
145
|
-
resetUI();
|
|
146
|
-
}
|
|
147
141
|
});
|
|
142
|
+
const result = await onDone(canvas, toBlob, type.current);
|
|
143
|
+
if (result === false) {
|
|
144
|
+
resetUI();
|
|
145
|
+
}
|
|
148
146
|
}
|
|
149
|
-
else
|
|
150
|
-
|
|
147
|
+
else {
|
|
148
|
+
const result = await onDone(data, toBlob, type.current);
|
|
149
|
+
if (result === false) {
|
|
150
|
+
resetUI();
|
|
151
|
+
}
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
154
|
// Load the component
|
package/package.json
CHANGED
package/src/UserAvatarEditor.tsx
CHANGED
|
@@ -36,9 +36,11 @@ export interface UserAvatarEditorToBlob {
|
|
|
36
36
|
* User avatar editor on done handler
|
|
37
37
|
*/
|
|
38
38
|
export interface UserAvatarEditorOnDoneHandler {
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
(
|
|
40
|
+
canvas: HTMLCanvasElement,
|
|
41
|
+
toBlob: UserAvatarEditorToBlob,
|
|
42
|
+
type: string
|
|
43
|
+
): Promise<void | false | undefined>;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
/**
|
|
@@ -269,19 +271,21 @@ export function UserAvatarEditor(props: UserAvatarEditorProps) {
|
|
|
269
271
|
|
|
270
272
|
// Large photo, resize it
|
|
271
273
|
// https://github.com/nodeca/pica
|
|
272
|
-
picaInstance
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
274
|
+
const canvas = await picaInstance.resize(data, to, {
|
|
275
|
+
unsharpAmount: 160,
|
|
276
|
+
unsharpRadius: 0.6,
|
|
277
|
+
unsharpThreshold: 1
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const result = await onDone(canvas, toBlob, type.current);
|
|
281
|
+
if (result === false) {
|
|
282
|
+
resetUI();
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
const result = await onDone(data, toBlob, type.current);
|
|
286
|
+
if (result === false) {
|
|
287
|
+
resetUI();
|
|
288
|
+
}
|
|
285
289
|
}
|
|
286
290
|
};
|
|
287
291
|
|