Change state of the shape based on the value of the variable using Javascript

Feb 22, 2023

I do have a shape(Rectangle 1) in my timeline and added multiple states(10, 20, 30). I have also created few variables which changes based on check box status. Now I want to edit the state of the rectangle based on these variable values using javascript.

var getprogressrectangle = document.querySelectorAll("[data-acc-text='Rectangle 1']");
if (userval1 == 1 && userval2 == 0){
getprogressrectangle.setState({state: "30"});

}else{getprogressrectangle.setState({state: "10"});}

But I'm getting "getprogressrectangle.setState is not a function" error.

 

Any help would be much appreciated!!

3 Replies
Math Notermans

If you make a simple sample with a few states and run this in your console....
DS.shadowDOM.state.children
you will get a list of ( i presume ) all elements in view with their states and a lot more info.
Selecting one of them...
DS.shadowDOM.state.children[0]
will simplify the info and you can see quite a lot of info on your element.
including a property called hideShowState: "show"
That one might be the one needed.
But as is the code inthere is way to complicated to decipher. For me at least.