100-project-100-days-website/100_projects/81-emoji-range-slider/main.js
2023-05-13 08:50:20 +03:00
Ask

34 lines
1.0 KiB
JavaScript

{8b3b61dd910da9e9a610e6293359e98c72ba1f4e true 1064 main.js 0xc002d7d0a0}

const body = document.querySelector("body");
const emoji = document.querySelector(".slide-emoji");
const input = document.querySelector("input");
const bar = document.querySelector(".progress-bar");
const thumb = document.querySelector(".thumb");
input.oninput = ()=>{
let sliderValue = input.value;
thumb.style.left = sliderValue + '%';
bar.style.width = sliderValue + '%';
if(sliderValue < 20){
emoji.style.marginTop = "0px";
body.classList.add("angry");
body.classList.remove("confuse");
body.classList.remove("like");
}
if(sliderValue >= 20){
emoji.style.marginTop = "-140px";
body.classList.add("confuse");
body.classList.remove("angry");
body.classList.remove("like");
}
if(sliderValue >= 40){
emoji.style.marginTop = "-280px";
}
if(sliderValue >= 60){
emoji.style.marginTop = "-420px";
body.classList.add("like");
body.classList.remove("confuse");
body.classList.remove("angry");
}
if(sliderValue >= 80){
emoji.style.marginTop = "-560px";
}
}