-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Помощь друга #10
Помощь друга #10
Conversation
js/form.js
Outdated
const formErorrorsMessages = { | ||
hashTag: 'Уникальные хештеги, каждый не более 20 символов, должны быть разделены пробелом', | ||
comment: 'Комментарий не более 140 символов' | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ErrorMessage
перечитывайте критерии
js/image-effects.js
Outdated
@@ -0,0 +1,58 @@ | |||
const EFFECT = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effect
js/image-effects.js
Outdated
options: {range: {min: 1, max: 4}, step: 0.1, start: 4}, | ||
} | ||
}; | ||
const DefaultSliderParams = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param
js/form.js
Outdated
|
||
const MAX_HASHTAG_LENGTH = 20; | ||
const MAX_COMMENT_LENGTH = 140; | ||
const MAX_HASHTAG_COUNT = 5; | ||
const VALID_IMAGE_TYPES = ['image/gif', 'image/jpeg', 'image/png']; | ||
const HASHTAG_RULE = /^#[А-яа-яA-za-zёЁ]{1,19}$/; | ||
const ErrorMessage = { | ||
hashTag: 'Уникальные хештеги, каждый не более 20 символов, должны быть разделены пробелом', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BAD_HASHTAG: '',
BAD_COMMENT: '',
js/image-effects.js
Outdated
'none': { name: 'none', filter: '', unit: '', | ||
options: {range: {min: 0, max: 100}, step: 1, start: 100}, | ||
}, | ||
'chrome': {name: 'chrome', filter: 'grayscale', unit: '%', | ||
options: { range: {min: 0, max: 100}, step: 1, start: 100}, | ||
}, | ||
'sepia': { name: 'sepia', filter: 'sepia', unit: '%', | ||
options: { range: {min: 0, max: 100}, step: 1, start: 100}, | ||
}, | ||
'marvin': { name: 'marvin', filter: 'invert', unit: '%', | ||
options: {range: {min: 0, max: 100}, step: 1, start: 100}, | ||
}, | ||
'phobos': {name: 'phobos', filter: 'blur', unit: 'px', | ||
options: {range: {min: 1, max: 10}, step: 0.1, start: 10}, | ||
}, | ||
'heat': {name: 'heat', filter: 'brightness', unit: '', | ||
options: {range: {min: 1, max: 4}, step: 0.1, start: 4}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NONE CHROME и тд
js/image-effects.js
Outdated
} | ||
}; | ||
const DefaultSliderParam = { | ||
range: {min: 0, max: 100}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
форматирование как везде должно быть ( перенос на др строки)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
я не понял
js/image-effects.js
Outdated
}; | ||
|
||
export const resetFilters = () => { | ||
image.style.filter = Effect['none'].name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none в константу
js/image-effects.js
Outdated
}; | ||
|
||
export const onEffectsFilterChange = (evt) =>{ | ||
const effect = evt.target.value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evt.target.value.toUpperCase() - чтобы под новый формат константы соответствовать
js/image-effects.js
Outdated
range: {min: 0, max: 100}, start: 100, step: 0.1 | ||
}; | ||
|
||
const NONE = 'NONE'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT_FILTER
js/image-effects.js
Outdated
export const createEffectSlider = () =>{ | ||
sliderWrapper.classList.add('hidden'); | ||
noUiSlider.create(slider, DefaultSliderParam); | ||
}; | ||
|
||
export const resetFilters = () => { | ||
image.style.filter = Effect[NONE].name; | ||
sliderWrapper.classList.add('hidden'); | ||
}; | ||
|
||
export const onEffectsFilterChange = (evt) =>{ | ||
const effect = evt.target.value.toUpperCase(); | ||
if(effect === Effect[NONE].name){ | ||
resetFilters(); | ||
} | ||
else{ | ||
sliderWrapper.classList.remove('hidden'); | ||
image.removeAttribute('class'); | ||
image.classList.add(`effects__preview--${effect}`); | ||
slider.noUiSlider.updateOptions(Effect[effect].options); | ||
slider.noUiSlider.on('update', () => { | ||
sliderValue.value = slider.noUiSlider.get(); | ||
image.style.filter = `${Effect[effect].filter}(${sliderValue.value}${Effect[effect].unit})`; | ||
}); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В итоге получился не модуль а файл с набором функций. Если делаете модуль, делайте его инкапсулированым, без лишго путающего и ненужного экспорта его внутренних органов ( слушателей, или каких-то функций внтуреннего жизненного цикла). Создайте функции которые запускают модуль (вешают обработчики событий, меняют классы), тормозят модуль (ставят все значения в дефолт, удаляют обработчики и тд) и возможно меняют его состояние (допустим нужно просто вернуть все в дефолт
js/image-scale.js
Outdated
const onScaleBiggerClick = updateScale; | ||
|
||
const onScaleSmallerClick = updateScale; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(evt) => updateScale(evt.target.dataset.value);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и соответственно поправить updateScale
const DefaultSliderParam = { | ||
range: {min: 0, max: 100}, start: 100, step: 0.1 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DefaultSliderParam = {
RANGE: {min: 0, max: 100}, START: 100, STEP: 0.1
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
к сожалению, noUiSlider не поддерживает критерии html академии
18af112
into
htmlacademy-univer-javascript-1:master
🎓 Помощь друга