Skip to content

Commit

Permalink
feat: change effects preview icons the same as user loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
KseniaTry committed Aug 11, 2024
1 parent 0bd33c1 commit efc55c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion js/upload-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const scale = document.querySelector('.scale__control--value');
const photoPreview = document.querySelector('.img-upload__preview');
const submitButton = document.querySelector('.img-upload__submit');
const photoPreviewImg = document.querySelector('.img-upload__preview img');
const effectsPreviewIcons = document.querySelectorAll('.effects__preview');

const isFieldFocused = () => document.activeElement === textCommentField || document.activeElement === hashtagField;

Expand Down Expand Up @@ -72,7 +73,13 @@ const setLoadedPhotoPreview = () => {
const matches = FILE_TYPES.some((it) => fileName.endsWith(it));

if (matches) {
photoPreviewImg.src = URL.createObjectURL(file);
const filePath = URL.createObjectURL(file);

photoPreviewImg.src = filePath;

effectsPreviewIcons.forEach((icon) => {
icon.style.backgroundImage = `url(${ filePath })`;
});
}
};

Expand Down

0 comments on commit efc55c5

Please sign in to comment.