Last active
August 26, 2020 21:13
-
-
Save Ryshackleton/066a49e07eced8c33579d69a0f5647c7 to your computer and use it in GitHub Desktop.
An example of event handling in a scrolling data story
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define a function to handle each step's events | |
const activateFunctions = []; | |
activateFunctions[1] = showFillerTitle; | |
activateFunctions[2] = showGrid; | |
activateFunctions[3] = highlightGrid; | |
// a plot module (the data visualization) | |
function myPlot(functionArray) { | |
function activate(index) { | |
functionArray[index](); | |
} | |
return { activate }; | |
} | |
const plot = myPlot(activateFunctions); | |
// react to events by index | |
scroll.on('active', function(index){ | |
plot.activate(index); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment