Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Scrollama

373 sites Security covered Drupal 10–11
View on drupal.org

This module integrates the scrollama.js library, allowing you to trigger CSS class changes on HTML elements as they scroll into view. It provides a data-attribute-based API for easily adding classes on entry and exit, streamlining the creation of scroll-based animations and scrollytelling experiences.

Loads scrollama.js library and provides a simple data-attributes-based API for triggering changes on scroll (animations, etc) via css classes.

Scrollama is normally used for Scrollytelling and animation triggering, but it is no limited to this. It makes use of the IntersectionObserver API in order to avoid scrolljaking and performance issues.

Installation

  • Install and enable the module.
  • Activate the module by one of these two ways:
    1. Go to the module configuration page and enable it globally. This will load scrollama on all pages, so it could come with a performance penalty if the library is not in use across your site. It is useful for testing, but for production we recommend switching to the second option.
    2. Attach the `"scrollama/scrollama"` library on your code when needed, using one of the many ways available in Drupal

Please note that, for performance reasons, scrollama is disabled by default. It's up to you to choose one of the previous two ways of activation.

How to use

On its core, Scrollama is a library that will only set a scroll point on the viewport and react whenever a given HTML element enters and exits this point. See a working example.

This means is up to you to decide what to do. Scrollama won't animate, enable, disable, reposition or change your HTML. You will.

This module adds a simple data-attributes-based API as a helper to improve and fasten development.

- Add data-scroll-init="my-class" to any HTML element to add .my-class when entering the screen. You can add multiple classes by separating them by at least a space, e.g. data-scroll-init="my-class another-class".
- Optionally, add data-scroll-exit="my-exit-class" to trigger a class on exit and data-scroll-delay="1" to add a delay (expressed in seconds).

Example:

<div data-scroll-init="fade-in" data-scroll-exit="fade-out" data-scroll-delay="2">
  My code...
</div>

This element will fade in when entering scroll point, fade out when exiting and the animation will have a delay of 2 seconds.

CSS animations:

This module ships with a very simple CSS implementation of several common animations. You can use the CSS as it is or as a reference for your implementation.

- `.fade-in` will fade the element from opacity 0 to 1.
- `.fade-out` will do the opposite
- `.slide-in` will move the element on the Y-axis from -200px to 0.
- `.slide-out` will move the element on the Y-axis from 200px to 0.

To enable it, use the module settings or attach manually the library "scrollama/scrollama-css" on your code.

TODOs and upcoming features

  • Better library loading, not only CDN
  • Extended animation library
  • Basic integration with blocks, paragraphs and layouts
  • Load scrollama from libraries and allow to choose library/CDN
  • (long term) allow the user to define several scroll points via a plugin-like system

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jan 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core Release date
2.0.0 Stable 10–11 Jan 24, 2025
2.x-dev Dev 10–11 Jan 24, 2025