Skip to content

Commit

Permalink
fixed pid parse in gain example
Browse files Browse the repository at this point in the history
  • Loading branch information
MeijisIrlnd committed Sep 21, 2024
1 parent 7f94468 commit fc61de5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions examples/gain/gain-gui/src/SliderComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import {useEffect, useState} from "react";

function SliderComponent({pid, name, min, max}) {
const [val, setVal] = useState(0.0);
const paramCallback = (ev) => {
const eventPid = ev.detail.paramId;
// console.log(ev);
if(parseInt(eventPid) !== pid) return;
const value = parseFloat(ev.detail.value);
setVal(value);
}
useEffect(() => {
addEventListener("param", (ev) => {
console.log("Param event");
const eventPid = ev.detail.paramId;
console.log(ev);
if (eventPid !== pid) return;
setVal(parseFloat(ev.detail.value));
});
addEventListener("param", paramCallback);
return function cleanup() {
removeEventListener("param", paramCallback);
}
}, []);

const sliderDragStarted = (v) => {
Expand Down

0 comments on commit fc61de5

Please sign in to comment.