This snippet of code changes the brightness and contrast of an image. However, when setting the contrast to 150% for example and then attempting to change the brightness the contrast value defaults back to 100%. How can I prevent these style attributes from changing back to their default value after being changed?
<p>
Contrast Bar
</p>
<input id='contrast_bar' type="range" min="50" max="150" value="100">
<p>
Brightness Bar
</p>
<input id='brightness_bar' type="range" min="50" max="150" value="100">
<BR><BR>
<img id='img_selection' src="photo.jpg">
<script>
let contrast_bar = document.querySelector('[id=contrast_bar]')
let brightness_bar = document.querySelector('[id=brightness_bar]')
let img = document.querySelector('#img_selection')
contrast_bar.addEventListener('input', con_bar => {
img.style.filter = 'contrast(' + con_bar.target.value + '%)'
})
brightness_bar.addEventListener('input', bright_bar => {
img.style.filter = 'brightness(' + bright_bar.target.value + '%)'
})
</script>