-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathreveal-to-d3.js
59 lines (46 loc) · 1.42 KB
/
reveal-to-d3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* global Reveal */
var pt = pt || {};
pt.handleEvent = function(isSlideEvent) {
'use strict';
var currentSlideId = Reveal.getCurrentSlide().id;
var currentFragment = Reveal.getIndices().f;
// Don't go any further if the slide has no ID (i.e. the string is empty).
if (!currentSlideId) {
return;
}
//First remove any SVGs still present when changing a slide
if (isSlideEvent) {
removeSVGs();
}
// If there is no entry corresponding to the current slide in the map, don't go further.
var functions = pt.slideIdToFunctions[currentSlideId];
if (functions == null) {
return;
}
// Call the init function when arriving on a slide for the first time.
if (isSlideEvent) {
var initFunction = functions.init;
if (initFunction != null) {
initFunction();
// Make sure we don't call the init function again.
//functions.init = null;
}//if
}//if
var fragmentFunction = functions[currentFragment];
if (fragmentFunction != null) {
fragmentFunction();
}
};
pt.handleSlideEvent = function() {
'use strict';
//Remove all the svg's drawn
//pt.selectAll("svg").remove();
pt.handleEvent(true);
};
pt.handleFragmentEvent = function() {
'use strict';
pt.handleEvent(false);
};
Reveal.addEventListener('slidechanged', pt.handleSlideEvent);
Reveal.addEventListener('fragmentshown', pt.handleFragmentEvent);
Reveal.addEventListener('fragmenthidden', pt.handleFragmentEvent);