Skip to content

Commit 3f57a50

Browse files
committed
fix focal point reset
1 parent 5afa4b0 commit 3f57a50

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/image-cropper-focus-setter.element.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ export class UmbImageCropperFocusSetterElement extends UmbLitElement {
122122

123123
const focalPoint = { left, top } as UmbFocalPointModel;
124124

125-
console.log('setFocalPoint', focalPoint);
126-
127125
this.dispatchEvent(new UmbFocalPointChangeEvent(focalPoint));
128126
}
129127

src/Umbraco.Web.UI.Client/src/packages/media/media/components/input-image-cropper/input-image-cropper.element.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,21 @@ import './image-cropper-focus-setter.element.js';
1313
import './image-cropper-preview.element.js';
1414
import './image-cropper-field.element.js';
1515

16+
const DefaultFocalPoint = { left: 0.5, top: 0.5 };
17+
const DefaultValue = {
18+
temporaryFileId: null,
19+
src: '',
20+
crops: [],
21+
focalPoint: DefaultFocalPoint,
22+
};
23+
1624
@customElement('umb-input-image-cropper')
1725
export class UmbInputImageCropperElement extends UmbLitElement {
1826
@query('#dropzone')
1927
private _dropzone?: UUIFileDropzoneElement;
2028

2129
@property({ attribute: false })
22-
value: UmbImageCropperPropertyEditorValue = {
23-
temporaryFileId: null,
24-
src: '',
25-
crops: [],
26-
focalPoint: { left: 0.5, top: 0.5 },
27-
};
30+
value: UmbImageCropperPropertyEditorValue = DefaultValue;
2831

2932
@property({ attribute: false })
3033
crops: UmbImageCropperPropertyEditorValue['crops'] = [];
@@ -68,7 +71,7 @@ export class UmbInputImageCropperElement extends UmbLitElement {
6871
}
6972

7073
#onRemove = () => {
71-
this.value = assignToFrozenObject(this.value, { src: '', temporaryFileId: null });
74+
this.value = assignToFrozenObject(this.value, DefaultValue);
7275
if (this.fileUnique) {
7376
this.#manager?.removeOne(this.fileUnique);
7477
}
@@ -116,13 +119,13 @@ export class UmbInputImageCropperElement extends UmbLitElement {
116119
const value = (e.target as UmbInputImageCropperFieldElement).value;
117120

118121
if (!value) {
119-
this.value = { src: '', crops: [], focalPoint: { left: 0.5, top: 0.5 }, temporaryFileId: null };
122+
this.value = DefaultValue;
120123
this.dispatchEvent(new UmbChangeEvent());
121124
return;
122125
}
123126

124-
if(this.value && this.value.temporaryFileId){
125-
value.temporaryFileId = this.value.temporaryFileId
127+
if (this.value && this.value.temporaryFileId) {
128+
value.temporaryFileId = this.value.temporaryFileId;
126129
}
127130

128131
this.value = value;

0 commit comments

Comments
 (0)