Skip to content

Instantly share code, notes, and snippets.

@Ryshackleton
Last active August 26, 2020 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryshackleton/066a49e07eced8c33579d69a0f5647c7 to your computer and use it in GitHub Desktop.
Save Ryshackleton/066a49e07eced8c33579d69a0f5647c7 to your computer and use it in GitHub Desktop.
An example of event handling in a scrolling data story
// 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