Both JS and timeline based should be possible but probably the time line way would still require some us actions.
Not at Mac at moment but will have. Look when I get back
You're the code above, it works as expected. ( with the added missing vars )
var targetElement = hypeDocument.getElementById('target')
var startWidth = hypeDocument.getElementProperty(targetElement, 'width')
var maxWidth = 500
// Animate the width of the rectangle
var startWidth = 0;
var endWidth = maxWidth;
var duration = 1000;
var stepTime = 10;
var widthIncrement = (endWidth - startWidth) / (duration / stepTime);
var currentWidth = startWidth;
var animationInterval = setInterval(function() {
currentWidth += widthIncrement;
if (currentWidth >= endWidth) {
currentWidth = endWidth;
clearInterval(animationInterval);
}
//targetElement.style.width = currentWidth + "px";
hypeDocument.setElementProperty(targetElement, 'width',currentWidth)
}, stepTime);
Is it possible that you have something else going on that reverts it.
Also you could simply do this in the code which pretty much does what the above is doing.
// Animate the width of the rectangle
var targetElement = hypeDocument.getElementById('target')
var startWidth = hypeDocument.getElementProperty(targetElement, 'width')// or set to a number
var maxWidth = 500
var duration = 1.0;
hypeDocument.setElementProperty(targetElement, 'width', maxWidth, duration)
Thank you. I'll do some more exploring this evening (I'm US, Eastern). I appreciate the simplified code. Currently there is no easing, but I'll figure that out later.
I'd love to have everything on the timeline, even with JavaScript in the background, because I have a sequence of other animations that are part of the overall, but more straightforward.
I'm curious why you're using a custom animation script when you could utilize the 'setElementProperty' function for animation. Have you considered simply adding the time parameter as specified in the API documentation? Is there a specific reason you're opting for a custom interval-based approach?