Scrollytelling
Installing
For now, you can clone this repo and npm link
the module but there will be an npm module in the future.
Usage
This module can be used as a simple image switching scrollytelling experience or extended based on your needs.
Simple
For a simple image scrollytelling experience that displays fixed images behind text as the user scrolls, all you need is the following.
Javascript
In your js file, import the scrollytelling module and call it; this will handle the functionality as long as the right data attributes are attached to your html.
; const scrolly = ;
HTML
In your html, you will need the following:
- an element with a
data-scrollytelling-content
attribute attached that wraps all your content. - elements with
data-trigger
attributes attached that will trigger a change in image. - on your triggers, include another data attribute
data-media
with thesrc
of the image you would like to display when that element comes into view. - (optional): on your trigger(s), include a data attribute
data-media-class
if you would like to include a class attribute on your image in order to style it yourself.
Here is an example
<!-- Your text content here --> <!-- Your text content here --> <!-- Your text content here -->
Advanced
The scrollytelling module allows you to use your own selectors for triggers. You can also attach your own event listeners.
Javascript
; const first = ;const other = const special = ;const last = ; first; last
HTML
<!-- Your text content here --> <!-- Your text content here --> <!-- Your text content here --> <!-- Your text content here --> <!-- Your text content here -->