-
-
Notifications
You must be signed in to change notification settings - Fork 4
Hype Functions
Hype offers a built-in JavaScript code editor based on Tumult HyperEdit (currently being revamped as Whisk) offering limited access to the source of your Hype Project. The code editor can be used to edit Head HTML and custom Hype Functions.
Hype Functions can be triggered from four different locations from within the IDE:
There are two places to trigger Hype Functions through JavaScript.
As long as we are inside another Hype Function of the same document we can call other Hype Functions using the current hypeDocument (API) we receive through the signature. Presuming we have created a Hype Function called myFunction in our Hype Document, this would be the code to call it and forward the element and event of our current Hype Function.
hypeDocument.functions().myFunction( hypeDocument, element, event );
Each Hype Function and Hype Document API is also available from the window scope under HYPE.documents[DOCUMENTNAME].functions()[FUNCTIONNAME]
. DOCUMENTNAME would be your Hype Document Name and FUNCTIONNAME would be the name of the function you are trying to call. As an example we presume you created a Hype Function called myFunction
in your Hype document called index
, this is how you could call that function from the window scope.
HYPE.documents.index.functions().myFunction( HYPE.documents.index, null, null );
We should at least apply the hypeDocument
(API) as first parameter but could omit the element
and event
. Although that depends on the functionality that function is supposed to perform.
Each function has a fixed function signature consisting of the following parameters hypeDocument
, element
and event
. The parameters element
and event
are context dependent, meaning the content changes according to the location the function was trigger from.
The content of hypeDocument
is always the current Hype Document API.
The content of element
is context depended and contains …
- … the Hype Scene element if triggered on the Document Panel or as a Timeline Action
- … the Hype Symbol element if triggered on the Symbol Panel
- … the element the action targeted, if triggered on the Action Panel
Contains in many cases context relevant information but at least always a name
containing the Hype Event the Hype Function was called in.
- Read more about hypeDocument and how to fetch it.
- Use the helper function getHypeDocument to fetch hypeDocument from within a Hype rectangle or on events declared as an HTML attribute.
- Choose another topic from the sidebar
- Visit the topic index
- Return to the welcome page
- Learn about contributing
- Consider making an one-time donation
- Visit the landing page for this project
- Accessibility in Hype
- Quick iterations as the secret to progress
- Using querySelector
- Test an elements class name using classList and contains
- Including external files and Hype Extensions
- Fetching hypeDocument from within a rectangle
- Extend the functionality of Hype using Export Scripts
- Using external editors
- Embedding Hype documents into third-party services
- Accessing external APIs from Hype Previews
- Manually include resources in document head
- Manipulating scene height
- Extension template