Skip to content Skip to sidebar Skip to footer

Is There Any Method To Put Data Into Js Function?

This is the function which is getting two values from firebase.I want a progress-bar which will work as soon as any data from the firebase is retrieved. function toggleVideoState(f

Solution 1:

Looking at your code it seems like you were playing with multiple values at first, but now you have only one set of values.

So In that case you should something like this

functiontoggleVideoState(fvalues, fthreshold) {
   const progressBar = document.querySelector(".progress-bar");
   const progressContainer = document.querySelector(".progress-container");

   let percentValue = Math.floor((fvalues/ (2 * fthreshold)) * 100);
   let percentMargin = Math.floor((25 * fvalues) / 100);
   console.log(percentValue, percentMargin);
   if (fvalues < 100) {
      progressBar.style.height = `calc(${fvalues}% - ${percentMargin}px)`;
   } elseif (fvalues=>100) {
      progressBar.style.height = `calc(100% - 25px)`;
   } else {
      progressBar.style.height = `0px`;
   }
   if (percentValue < 50) {
     progressBar.style.backgroundColor = "red";
     progressContainer.style.borderColor = "red";
   } else {
     progressBar.style.backgroundColor = "green";
     progressContainer.style.borderColor = "green";
   }
 }

Or specify in the question, the dummy inputs you get in your function toggleVideoState. Also html structure of your progress bars.

Post a Comment for "Is There Any Method To Put Data Into Js Function?"