Hi John,
There should be no reason to use any delays to accomplish what you are trying to do.
PowerPac's
userProperty() is a rather complex function that accomplishes a lot of things. However, when it is manipulating classNames, it has to distinguish exactly what you want to do. Consider these details:
- If all you want to do is set a className to your field, then:
userProperty( "a1", "className", "pause1", "set");
- Now suppose that after setting the className to "pause1", you want to change it to "pause2".
Then this execution would appear to fail to accomplish the task:
userProperty( "a1", "className", "pause2", "set");
The above fails because what it really does is APPEND the class to the previous one. So in the DOM, your object would look like this:
<span id="myID" class="pause1 pause2"> ... </span>
To fix this problem, you would need to tell the function NOT TO APPEND the classes to what is already there.
Therefore, this would give the correct result:
userProperty( "a1", "className", "pause2", "set", false, false);
- So what about your scenario, where you want to clear the className AFTER setting it to "pause1"?
There are two ways to do this.
The FIRST way is to use the "toggle" value instead of "set". As the Parameter Help API indicates this will remove a className IF it is present or ADD it if it is not present on the object. In your scenario this may be all that is needed:
userProperty( "a1", "className", "pause1", "toggle");
The SECOND way to remove a className is to set the val parameter to an emtpy string, but tell the function NOT TO APPEND classes. In this case, the usage would look like this, but gives the same result as above.
userProperty( "a1", "className", "", "set", false, false);
The ability to append multiple classes onto a single object using
userProperty() was added a long time ago. The Parameter Help API is a little ambiguous in that is says you can clear a property with an empty string. While that is true, it does not work when manipulating classes because the function needs to know what to do with any classes that are already assigned to the object. Basically, this ability enables using classes to add styling to objects that have already been assigned styling that should never be removed. For example, if you assign a className that sets an object's font family to a web font loaded with a CSS file, you likely never want
userProperty() to remove that className when assigning additional styling to the object. So the ability the preserve styles while assigning new ones is among the more powerful features of
userProperty().
I tried all of the above scenarios on your submitted example and they work as designed (using TB v9.01). Another parameter to keep in the mind is the parseGroup parameter. When set to true and the function is set to target a group (tbName = [group name]), then each object in the group will have its className set to the class you define. This is a useful feature when setting the styling of lots of objects all at once.