I get the purpose of the relative start frame option in a timeline, but is there any way to make the end frame relative too? Say you want to achieve something like this: a click on an object causes it to jump up and return almost to the same point; you want to be able to achieve this effect no matter where the object is in the scene, ie falling back close to the relative start-frame position.
I’m guessing this is common requirement, so I’m sure I must be missing something obvious. How do you do it?
In case anyone is interested the relevant JS code is …
var topOfElement = hypeDocument.getElementProperty(element, 'top');
hypeDocument.setElementProperty(element, 'top', topOfElement - 50, 0.5, 'easeout'); // rise by 50 px
setTimeout(restoreTop,500); // 500 mS for element to rise by 50 px
function restoreTop() {
hypeDocument.setElementProperty(element, 'top', topOfElement, 0.5, 'easein');
}
You can’t just run two setElementProperty calls in succession (one with -50 pixels and the other +50 pixels) as the second one will be executed before the first has really got going and the element will just drop 50 pixels. Hence the need for the setTimeout() with a delay equal to the time spent easing the element upwards. The second (time-delayed) call of setElementProperty just uses the original top value as this parameter is loaded immediately after the first call (ie the value of ‘top’ is the original value).
This all works fine: the element jumps up 50 px and then drops down again.
Depending on your needs, you could do a Continue Timeline action set to playback in reverse. This would mean your first keyframe would be your last, and assume the relative position that was set when the timeline was originally started.
Well the title says “Making both the start frame AND the end frame relative?”. What @beemerbiker is then doing in the script is ALL relative. That is only possible with script or by introducing a wrapper group to move the whole thing around… example:
RelativPingPong_Movable.hype.zip (20,1 KB) Drag black square! To move the whole thing around but that obviously also could be a key framed animation
PS: Just realized I was using the german pronunciation “relativ”… it needs that extra “e” in english
Thanks for the various useful suggestions. Very helpful. For my particular application, in the end the JS function technique suits me best. It can be done in 3 lines of code and it will work with any element in any scene with no edits (assuming you need a 50px up and down jump lasting 1 second each time). The trimmed down function code I’m using is …