Hello Everybody,
given some back and forth on a good way to extend Hype and allow modularity we (@MarkHunte, @MaxZieb) are starting this little project as a board thread. One could move things to GitHub or so but that adds another layer of abstraction and this thread is about inclusion. Anyways one will have to see if this thread picks up any traction anyways.
Purpose of the Project
A modular way to extend Hype with functions that follow some simple rules.
Rules of participation
-
Try to keep an extension agnostic to the location of the call, structure or layout of the document (if a function targets certain elements they should be parameters). If that isn't possible consider not posting your solution as a extension and rather keep it as a project specific solution on an another thread. Your welcome to discuss it in this thread.
-
Should a extension depend on another extension require it with a written statement in the function description as
@require nameOfExtension
so the whole set of functions in this thread can be picked like a cherry tree to ones project needs (copy&paste). -
An extension should be documented using
@param, @return, @require
helping people to understand what a function does. Please have a look at http://usejsdoc.org/ if you need more tags (like@example
etc.) -
Should you find a error try maintaining your extension in your original post on this thread to avoid multiple reposts. If someone finds a bug please try contacting the author with a private message before posting to this thread.
-
Post your extentsion to this thread once you have suggested and discussed them in the Extension category. Please try to follow the post format used by the other functions in this thread and link back to this index.
Preparing your project for extensions
Method: Bestcase
Copy & paste this to your Document-Tab → Head HTML (see Tumult Hype Documentation) and make sure to place the extensions in the extendHype function (location indicated with an comment):
<script>
function extendHype(hypeDocument, element, event) {
/* add the extentions here */
return true;
}
if("HYPE_eventListeners" in window === false) {
window.HYPE_eventListeners = Array();
}
window.HYPE_eventListeners.push({"type":"HypeDocumentLoad", "callback":extendHype});
</script>
Extension_Method_1.hypetemplate.zip (8,6 KB)
Method: Quick and dirty
Just drop the extensions from this thread into a Hype Function and load the function on the first scene load (scene-tab) from within Hype. No need for any of the above script code (bestcase). This method has some downsides but for single use, cases with no access to the HTML (in production) and quick prototyping it should work fine.
Extension_Method_2.hypetemplate.zip (8,9 KB)
Usage of extension
Once you prepared your document just copy and paste any extensions from this thread into the wrapper or your scene load function to make them work in your project. Also make sure to check if your extension requires another extension found in the statement @require nameOfExtension
and also copy&paste that one to your project.
EXTENSION INDEX
hypeDocument.continueTimelineNamedFromTo
This Extension allows you to play a Timeline from a given time, To a given time on a named timeline
The timeline will start from the From time and stop at the To time.
hypeDocument.sceneInfo
Returns the Scene information: scene element ,current scene number, current scene name and total scene count (Object)
### hypeDocument.currentSceneElement
Returns the current scene element (HTMLDivElement).
hypeDocument.getSceneElementByName
Returns a scene element by name (HTMLDivElement).
hypeDocument.currentSceneIndex
Returns the current scene index (Number).
hypeDocument.getSymbolInstance
Returns the current symbol instance (symbolInstance)
hypeDocument.setElementProperties
Sets multiple properties at once (with the optional possibility to animate them)
hypeDocument.setInnerHtmlByClass
Sets all the all elements of a given class to the content one provides.
hypeDocument.goToTimeIndexInTimelineNamed
Jump to timeIndex as seen in the Hype frontend.
includes: hypeDocument.timeIndexToSeconds
hypeDocument.getCurrentSceneHeight
Gets the current scene height (CSS)
hypeDocument.setCurrentSceneHeight
Sets the current scene height (CSS)
hypeDocument.cloneElement
This Extension allows you to clone elements and append them to the scene or within a Group.
hypeDocument.startCustomBehaviourTicker
Hype Pro Extension: Starts a ticker based on a time interval that broadcasts a custom behaviour.
hypeDocument.stopCustomBehaviourTicker
Hype Pro Extension: Stops an active ticker broadcasting a custom behaviour.
hypeDocument.stopAllCustomBehaviourTicker
Hype Pro Extension: Stops all active ticker broadcasting custom behaviour.
hypeDocument.loadSound
Load soundfiles from the library and plays them back.
hypeDocument.stopAllSounds
Stops all playing soundfiles that have been loaded with hypeDocument.loadSound
hypeDocument.unloadAllSoundsByName
resets all (loadSound) audio elements with a given name and removes them from the DOM
hypeDocument.unloadSound
resets (loadSound) audio element by reference and removes it from the DOM
hypeDocument.getPrivateContainer
This function creates a kind of "shadow DOM" (HTMLDivElement)
hypeDocument.TypeTextExtension
This Extension Allows you to have text Typed out