A modern scroll-based animation library that integrates GSAP ScrollTrigger with Tumult Hype for high-performance scroll interactions and timeline control.
Designed specifically for Tumult Hype users! This plugin works with Hype's visual Inspector interface - no hand-coding HTML required.
HypeScrollTrigger is a JavaScript extension designed for integration with Tumult Hype, enabling developers and designers to create interactive, scroll-based animations and interactions within their Hype projects. Leveraging the power of GSAP ScrollTrigger, this extension makes it easy to trigger animations as users scroll through a webpage, enhancing the storytelling and user engagement of Hype animations.
Incorporating HypeScrollTrigger into your Tumult Hype projects unlocks a new realm of interactive storytelling and user engagement through scroll-driven animations. By utilizing this powerful extension, you can create immersive web experiences that captivate your audience.
- Modern Performance: Built on GSAP ScrollTrigger for superior performance compared to ScrollMagic
- Smooth Timeline Animation: Built-in smooth interpolation for silky timeline transitions (enabled by default)
- Tumult Hype Integration: Seamless integration with Hype documents and timelines
- Element Pinning: Pin elements during scroll with automatic wrapper creation
- CSS Custom Properties: Automatic CSS variable updates for scroll progress
- Data Attribute Configuration: Easy setup using HTML data attributes via Hype's Identity Inspector
- Event System: Comprehensive enter/leave/progress event handling
- Debug Tools: Built-in debugging utilities for development
- Horizontal Scrolling: Support for horizontal scroll animations
- Scene Management: Automatic cleanup and refresh handling
- Symbol Support: Works with both Hype main timelines and symbol timelines
- Integration with Hype Action Events: When using
HypeActionEvents, you can easily call functions by using data action attributes to bind scroll progress or events to actions
- GSAP (3.0+)
- GSAP ScrollTrigger
- Tumult Hype (4.0+)
For a quick start, incorporate GSAP ScrollTrigger and HypeScrollTrigger directly into your project by adding the following scripts to the Head section of your Hype document:
CDN Version
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/worldoptimizer/HypeScrollTrigger/HypeScrollTrigger.min.js"></script>Download all dependencies and Hype Scroll Trigger, then combine them into a single script file. Include this file in your resources and link to head HTML.
HypeScrollTrigger is designed to work seamlessly with Tumult Hype's visual interface. Instead of editing raw HTML, you configure scroll animations using Hype's Identity Inspector.
- Select any element in your Hype scene (rectangle, group, symbol, etc.)
- Open Identity Inspector:
- Menu:
View→Inspectors→Identity - Or use the Inspector panel if already visible
- Menu:
- Locate "Additional HTML Attributes" section (below Class Name field)
- Click the
+button to add new attribute pairs - Enter Key and Value:
- Key:
data-scroll-timeline - Value:
Main Timeline
- Key:
- Repeat for additional attributes like
data-scroll-duration, etc.
- Always start with
data-prefix - Use kebab-case:
data-scroll-timeline(notdataScrollTimeline) - Leave values empty for some boolean attributes like
data-scroll-pinas the attribute itself is the switch
HypeScrollTrigger enhances Hype documents by allowing scroll position to control timeline animations. After including the script, scroll animations can be configured programmatically or through data attributes.
The extension looks for elements with the data-scroll-timeline attribute within each scene to automatically create scroll-driven animations. No manual initialization is needed for basic usage.
HypeScrollTrigger utilizes data-attributes in HTML elements to define and control scroll-driven animations. These attributes allow for a declarative approach to configuring animations, making it easy to integrate and manage animations directly through Hype's Identity Inspector.
data-scroll-timeline: Links an HTML element to a specific Hype timeline or timelines. Specify one or multiple timeline names separated by commas to trigger upon scrolling. Whiledata-scroll-offsetanddata-scroll-durationare essential attributes for defining the start point and length of the scroll animation respectively, if they are not explicitly declared,HypeScrollTriggerwill assume these values based on the element's bounding box dimensions.
| Attribute | Type | Example Value | Description |
|---|---|---|---|
data-scroll-timeline |
string | Main Timeline |
Timeline name(s) to control (comma-separated for multiple) |
data-scroll-pin |
boolean | (leave empty) | Pins the element in place for the duration of the scroll animation |
data-scroll-offset |
number/string | 100 or 50% |
Start point of scroll animation in pixels or percentage of element dimension |
data-scroll-duration |
number/string | 200 or 100vh or 50% |
Duration over which scroll animation runs |
data-scroll-trigger |
number | 0.5 |
Viewport position to start animation (0=top, 0.5=center, 1=bottom) |
data-scroll-reset |
boolean | false |
If set to false, prevents timeline from resetting when scrolled back |
data-scroll-horizontal |
boolean | (leave empty) | Changes scroll direction from vertical to horizontal |
data-scroll-name |
string | MyScrollArea |
Custom name for behavior events and debugging |
| Attribute Usage | Example Value | Description |
|---|---|---|
| Percentage of element | 50% |
Adds half of the element's height to the start point |
| Absolute pixels | 100 |
Starts the animation 100 pixels down from the top |
| Attribute Usage | Example Value | Description |
|---|---|---|
| Viewport height | 100vh |
Duration equals the full height of the viewport |
| Percentage of element | 50% |
Animation lasts for half of the element's dimension |
| Absolute pixels | 500 |
Specifies the animation duration as 500 pixels |
| Attribute | Type | Default | Example Value | Description |
|---|---|---|---|---|
data-scroll-smooth |
boolean | true |
false |
Enables/disables smooth timeline interpolation |
data-scroll-smooth-factor |
number | 0.15 |
0.1 |
Smooth animation factor (0-1, lower = smoother) |
data-scroll-properties: This attribute dynamically links CSS variables to scroll activity, enabling styled effects based on scroll position. It specifies the names of the CSS variables that should be updated within the scope of the Hype document according to scroll progress, duration, and offset.
| Property Value | CSS Variables Created | Description |
|---|---|---|
test |
--test-progress, --test-duration, --test-offset, --test-trigger-hook |
Custom named variables |
| (empty) | --scroll-progress, --scroll-duration, --scroll-offset, --scroll-trigger-hook |
Default variable names |
Setup in Hype Inspector:
Key: data-scroll-properties
Value: letterbox
CSS Usage:
.dynamic-letter-spacing {
letter-spacing: calc(var(--letterbox-progress) * 5px) !important;
}| Attribute | Example Value | Description |
|---|---|---|
data-scroll-element-class |
active-element |
CSS class applied to element when entering scroll timeline |
data-scroll-scene-class |
active-scene |
CSS class applied to entire Hype scene when visible in scroll timeline |
| Attribute | Example Value | Description |
|---|---|---|
data-indicator-color |
red |
Customizes color of scroll animation indicators |
data-indicator-force |
(leave empty) | Forces display of scroll animation indicators |
| Attribute | Description |
|---|---|
data-scroll-offset-action |
Custom logic to dynamically calculate initial offset |
data-scroll-duration-action |
Custom script to calculate scroll effect duration |
data-scroll-trigger-action |
Script to dynamically determine triggerHook value |
| Attribute | Description |
|---|---|
data-scroll-progress-action |
Action triggered as scroll animation progresses |
data-scroll-enter-action |
Script executed when scroll enters trigger area |
data-scroll-leave-action |
Script executed when scroll leaves trigger area |
data-scroll-action |
Catch-all action for all events (differentiate by event.type) |
- Select your element in the Hype scene
- Open Identity Inspector:
View→Inspectors→Identity - Add data attributes in the "Additional HTML Attributes" section:
| Key | Value |
|---|---|
data-scroll-timeline |
Main Timeline |
data-scroll-duration |
200 |
data-scroll-trigger |
0.5 |
- Select your element to pin during scroll
- Identity Inspector → Additional HTML Attributes:
| Key | Value |
|---|---|
data-scroll-pin |
(leave empty) |
data-scroll-timeline |
Main Timeline |
- Select your element
- Identity Inspector → Additional HTML Attributes:
| Key | Value |
|---|---|
data-scroll-timeline |
Main Timeline |
data-scroll-smooth |
false |
- Select your element
- Identity Inspector → Additional HTML Attributes:
| Key | Value |
|---|---|
data-scroll-properties |
scroll |
data-scroll-duration |
100vh |
In HypeScrollTrigger, "Enter" and "Leave" events are designed to trigger specific behaviors when scrolling through particular regions on a webpage. The behavior naming convention is based on the timeline name or the scroll name if provided. Triggering is dependent on a name being present in either the timeline or the manually set scroll name.
Behavior Mechanisms:
- Enter: Activated as the scroll enters a defined region, which can trigger linked animations or actions.
- Leave: Triggered when the scroll exits the region, typically used to conclude or reverse animations.
Examples:
-
General Behavior with Timeline Name (e.g., "Main Timeline"):
Main Timeline EnterMain Timeline Leave
-
Specific Behavior with Scroll Name (e.g., "MyScrollArea"):
MyScrollArea Enter ForwardMyScrollArea Enter ReverseMyScrollArea Leave ForwardMyScrollArea Leave Reverse
The specific naming convention includes the direction of the scroll (Forward or Reverse) to further refine the behavior based on the scroll movement.
Custom behaviors are at the heart of HypeScrollTrigger, offering a way to extend the interactivity of your Hype projects beyond predefined animations. When a scroll timeline reaches certain milestones, such as the start or end of an animation, HypeScrollTrigger can automatically trigger custom behaviors named following a specific convention.
For example, if you have a timeline named "exampleTimeline", the extension can generate custom behaviors like exampleTimeline Enter Forward when the scroll enters the timeline boundary moving downwards, or exampleTimeline Leave Reverse when scrolling out of the timeline boundary upwards.
When actions are triggered using Hype Action Events, specific scroll-related properties such as offset, duration, and triggerHook are exposed within the scope of the action. This allows for direct manipulation and calculation within the action scripts. For instance, expressions like offset + duration / 2 can be used directly in data-scroll-offset-action or data-scroll-duration-action to compute values dynamically.
In cases where a Hype function is invoked, such as myOffset(), Hype automatically populates the function's signature with hypeDocument, element, and event. The scope values (e.g., duration, offset) are also added to the event object, accessible as event.duration, event.offset, etc.
// Set default options
HypeScrollTrigger.setDefault({
options: {
triggerHook: 0.5,
smooth: true,
smoothFactor: 0.15
},
behavior: {
enter: true,
leave: true
},
logBehavior: false,
addIndicators: false
});
// Get current defaults
const defaults = HypeScrollTrigger.getDefault();- Add a Scroll Timeline:
hypeDocument.addScrollTimeline(element, timelineName, options)- Programmatically adds a scroll timeline to the specified element with custom options.
// Add a scroll timeline to an element with custom options
const myElement = hypeDocument.getElementById('myElement');
const trigger = hypeDocument.addScrollTimeline(myElement, 'exampleTimeline', {
duration: '50%',
pin: true,
smooth: false,
smoothFactor: 0.1
});// Refresh all ScrollTriggers
HypeScrollTrigger.refresh();
// Get triggers for a specific scene
const triggers = HypeScrollTrigger.getTriggersForScene('sceneId');
// Debug information
const debugInfo = HypeScrollTrigger.debug();
console.log('GSAP Version:', debugInfo.gsapVersion);
console.log('ScrollTrigger Version:', debugInfo.scrollTriggerVersion);
console.log('Active Triggers:', debugInfo.scrollTriggers);Scroll triggers work inside Symbols:
- Enter the Symbol (double-click)
- Select elements within the symbol
- Set data attributes on symbol children via Identity Inspector
- Timelines reference the symbol's internal timelines
For responsive designs:
- Use viewport units:
100vh,50vwfordata-scroll-duration - Use percentage values:
50%,200%for relative sizing - ScrollTrigger automatically recalculates on window resize
- Use
HypeScrollTrigger.refresh()after layout changes
Groups can be scroll triggers:
- Select the entire group
- Add scroll attributes to the group element
- All children animate together
- Useful for complex multi-element animations
Globally enable indicators:
// In Head HTML or JavaScript function
HypeScrollTrigger.setDefault('addIndicators', true);Per element in Hype Inspector:
- Select your element
- Identity Inspector → Additional HTML Attributes:
| Key | Value |
|---|---|
data-indicator-force |
(empty) |
data-indicator-color |
red |
const debug = HypeScrollTrigger.debug();
console.log('GSAP Version:', debug.gsapVersion);
console.log('ScrollTrigger Version:', debug.scrollTriggerVersion);
console.log('Active Triggers:', debug.scrollTriggers);HypeScrollTrigger is designed as a drop-in replacement for HypeScrollMagic:
| ScrollMagic | HypeScrollTrigger |
|---|---|
data-scroll-magic |
data-scroll-timeline |
| Scene controller | Automatic management |
| Manual refresh | Auto-refresh on scene changes |
| Basic interpolation | Smooth timeline option (default enabled) |
HypeScrollTrigger is designed to integrate seamlessly with Tumult Hype and is compatible with most modern web browsers, ensuring a wide audience can experience the scroll-based animations. While future updates may introduce new interfaces or affect backward compatibility, version 1.0.0 should be a straightforward implementation.
MIT License - see LICENSE file for details.
- Hype ActionEvents - Enhanced event system for Hype
- GSAP ScrollTrigger - The underlying animation engine
- HypeScrollMagic - Previous ScrollMagic-based version
