Play timeline in reverse and skip pauses?

Hello!
I have a timeline with a series of pauses to enable the continuation of timeline on each step. (See Hype file). Is it possible to make the Reverse button play the whole time line in reverse skipping over the pauses? (I know you can “Go to time in timeline” but I would like the ability to see the timeline played back in reverse all the way back to the start.

Thanks!
timelineReverse.zip (20.2 KB)

You could look at the playback direction and only pause the timeline if the direction is ‘forward’:

if (hypeDocument.currentDirectionForTimelineNamed('timeline1') == hypeDocument.kDirectionForward) {
		hypeDocument.pauseTimelineNamed('timeline1');
	}

timelineReverse.hype.zip (20.4 KB)

I added this to our documentation here. Thanks for the nudge, @JimScott

4 Likes

Oh my… The constructions I’ve build to to do this… :grimacing:

Extremely helpful Daniel. :kissing_heart:

1 Like

I never really realised that the return

hypeDocument.kDirectionForward
hypeDocument.kDirectionReverse

was just true / false 1/0

:roll_eyes:

Indeed!

@MarkHunte
If You were a member of Hype's "Platinum Circle" :tada: then You would get the full documentation for Hype, annotated with nifty useful coding tips like the one above.

@Daniel
This information would be valuable in the non "Platinum Circle" Documentation too. :pushpin:

Huh, I thought it was called the "Golden Ellipse" and it was for people who did not want to follow the normal circle of fulfillment that a non cluttered documentation offers :grinning:

There are reasons Hype abstracts it’s constant with names. This are the same reasons that many useful function from the runtime are not exposed to the API. In many cases a bit very restrictive, though. Hype maintains the product for beginners and also wants to keep support to a minimum. As every function you expose also binds you to sustain functionality and the function signature in the future (meaning the way you pass parameters to it).

About these long descriptive names (in this case for constants)… they are used in the Runtime all over the place but you don’t see them in the final minimized runtime as they are optimized in the minification process. Only the string literals exposed in the API keep their long form as they are defined as Object keys and they still need to be human readable.

The naming schema starting with k is an old convention also used at one point in Apple (based on the Hungarian notation) going back to XEROX Parc. It indicates a variable as k --> constant (Although the Javascript the Runtime is written in doesn’t support real constants).

To print out the constants and their mapping from the API run the following in Hype:

// loop over API
for(var found in hypeDocument) {
	//check if key starts with a 'k' --> constant
	if (found.charAt(0) == 'k') {
		// print the key and content to the console
		console.log (found+' --> '+hypeDocument[found]);
	}
}
3 Likes

Thanks @MaxZieb ,
I did understand all this about the naming of constants and how beginners would need to use Hype

For some reason it just did not enter my mind that concept of forward or reverse would be a constant of 1/0 in this case.

thanks for the snippet.

Your welcome, but the point is not only for beginners (maybe I got that wrongly explained) although human readable makes it arguably more easy for beginners. It's more about abstraction and in that sense Daniel did it wrong as the whole goal to provide the constant would be that if you use them as hypeDocument.kDirectionForward or hypeDocument.kDirectionReverse (even though it involves more typing) Tumult can eventually update/refactor the underlying numerology/mapping without breaking your code. If you reference it directly you are committing to the current state of the code mapping. Well I don't think that forward and backwards need anything more then a "boolean" but you never know. I guess that's the reasoning for Daniel too as each Hype exports includes the current runtime and this hasn't changed for quite some while we are save using direct codes in this case (but nor best practice).

Lol.

I really do understand that and you did make it clear for any one who did not... :wink:

1 Like

Yes, please use the constants and not actual values! I’ve updated the example and documentation.