forked from htmlacademy-javascript/144485-kekstagram-31
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Сделаны фильты для загрузки фотографий
- Loading branch information
1 parent
a20ccfc
commit 91a692b
Showing
11 changed files
with
80 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {effectLevelSliderParrent, effectLevelSlider, effectLevelInput, effectChecked, uploaPreviewImage} from './slider-variables'; | ||
|
||
const sliderVisableToggle = (isShown = true) => { | ||
effectLevelSliderParrent.classList.toggle('hidden', isShown); | ||
}; | ||
|
||
noUiSlider.create(effectLevelSlider, { | ||
range: { | ||
min: 0, | ||
max: 100, | ||
}, | ||
start: 0, | ||
connect: 'lower' | ||
}); | ||
|
||
const sliderUpdateOptions = (min, max, start, step, addStyleFunction) => { | ||
effectLevelSlider.noUiSlider.updateOptions({ | ||
range: { | ||
min: min, | ||
max: max, | ||
}, | ||
start: start, | ||
step: step | ||
}); | ||
effectLevelSlider.noUiSlider.on('update', () => { | ||
let effectLevelInputValue = effectLevelInput.value; | ||
effectLevelInputValue = effectLevelSlider.noUiSlider.get(); | ||
effectLevelInput.value = effectLevelInputValue; | ||
uploaPreviewImage.style.filter = addStyleFunction(effectLevelInputValue); | ||
}); | ||
}; | ||
|
||
effectChecked.addEventListener('change', (evt) => { | ||
if (evt.target.checked) { | ||
switch (evt.target.value) { | ||
case 'chrome': | ||
sliderVisableToggle(false); | ||
sliderUpdateOptions(0, 1, 0, 0.1, (value) => `grayscale(${value})`); | ||
break; | ||
|
||
case 'sepia': | ||
sliderVisableToggle(false); | ||
sliderUpdateOptions(0, 1, 0, 0.1, (value) => `sepia(${value})`); | ||
break; | ||
|
||
case 'marvin': | ||
sliderVisableToggle(false); | ||
sliderUpdateOptions(0, 100, 0, 1, (value) => `invert(${value}%)`); | ||
break; | ||
|
||
case 'phobos': | ||
sliderVisableToggle(false); | ||
sliderUpdateOptions(0, 3, 0, 0.1, (value) => `blur(${value}px)`); | ||
break; | ||
|
||
case 'heat': | ||
sliderVisableToggle(false); | ||
sliderUpdateOptions(0, 3, 1, 0.1, (value) => `brightness(${value})`); | ||
break; | ||
|
||
default: | ||
sliderVisableToggle(); | ||
uploaPreviewImage.style.removeProperty('filter'); | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const effectLevelSliderParrent = document.querySelector('.img-upload__effect-level'); | ||
export const effectLevelSlider = effectLevelSliderParrent.querySelector('.effect-level__slider'); | ||
export const effectLevelInput = document.querySelector('.effect-level__value'); | ||
export const effectChecked = document.querySelector('.effects'); | ||
export const uploaPreviewImage = document.querySelector('.img-upload__preview img'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters