forked from willemmulder/Presenteer.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
presenteer.html
210 lines (195 loc) · 10.4 KB
/
presenteer.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<html>
<head>
<title>Presenteer.js</title>
<style>
body { font: 14px arial, verdana; margin: 0px; padding: 0px; color: #222233; }
.inline { display: inline; margin: 0px; }
.container { width: 800px; margin: 20px auto; }
.presentationcontainer { overflow: hidden; background: #ddddff; cursor: pointer; }
.presentation > div { float: left; clear: both; padding: 20px; }
#presentationcontainer1 { height: 100px; }
#presentationcontainer2 { height: 100px; width: 80%; float: left; }
#presentationcontainer2_counter { height: 100px; width: 20%; float: right; background: #bbbbdd; }
.clearfix { visibility: hidden; font-size: 1px; clear:both; }
.syntaxhighlighter.js { overflow-y: hidden !important; }
/* specify smooth animations between states */
.presentation {
-moz-transition: all 0.5s ease;
-webkit-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
}
</style>
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/sylvester/sylvester.js"></script>
<script src="js/sylvester/matrix.js"></script>
<script src="js/sylvester/vector.js"></script>
<script src="js/presenteer-1.0.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.js"></script>
<link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.css"/>
<script type="text/javascript">
SyntaxHighlighter.defaults.toolbar = false;
SyntaxHighlighter.all();
</script>
</head>
<body>
<div class="container">
<h1>Presenteer.js</h1>
<p>
Source code at <a href="https://github.com/willemmulder/Presenteer.js">https://github.com/willemmulder/Presenteer.js</a>
</p>
<script>
$(window).load(function() {
var presentation1 = new Presenteer("#presentation1", $("#presentation1 > div"), { centerHorizontally : false, centerVertically: true, followElementTransforms: true });
$("#presentationcontainer1").on("click", function() { presentation1.next(); });
presentation1.start();
});
</script>
<div class="presentationcontainer" id="presentationcontainer1">
<div class="presentation" id="presentation1">
<div>Welcome to <code class="inline">Presenteer.js</code>. Click in this box to continue.</div>
<div>Presenteer.js a flexible HTML5 presentation tool. <br />Yet, it needs very little configuration</div>
<div>In fact, it can be used with one simple line of code</div>
<div>For example the code for this slideshow is <br /><pre class="brush: js;">var presentation = new Presenteer("#presentation1", $("#presentation1 > div"));</pre></div>
<div>We can navigate by calling <code class="inline">presentation.next();</code> or <code class="inline">presentation.prev();</code></div>
<div style="-webkit-transform: rotate(8deg); -moz-transform: rotate(8deg); -o-transform: rotate(8deg); -ms-transform: rotate(8deg); transform: rotate(8deg);">The nice thing is that Presenteer follows element-transforms like on this element!</div>
<div>There's also several constructor-options and custom callback functions.<br />Read on for more!</div>
</div>
</div>
<div>
<h2>Introduction</h2>
<p>Presenteer.js a very flexible HTML5 presentation tool that works in one line of code, but is configurable with constructor options and many callbacks.</p>
<p>
In its simplest form, it works like <pre class="brush:js">var presentation = new Presenteer("#presentation", $("#presentation > div"));</pre>
</p>
<p>
And then navigate through the presentation with <code class="inline">presentation.start();</code>, <code class="inline">presentation.next();</code>, <code class="inline">presentation.prev();</code> and <code class="inline">presentation.show(0-based-index);</code>
</p>
<h2>Constructor options</h2>
<p><pre class="brush: js;">var presentation = new Presenteer(canvas, elements, options);</pre></p>
<p>Where <code class="inline">elements</code> is a list of objects that are any of the following</p>
<ol>
<li>CSS selector, like "#elm"</li>
<li>jQuery element, like $("#elm")</li>
<li>A Presenteer Object, that looks like
<pre class="brush: js;">{
element : e, // CSS selector or jQuery object,
// Direction-independent callbacks
onBeforeEnter : function(), // Callback right before e is shown
onAfterEnter : function(), // Callback right after e is shown
onAfterLeave : function(), // Callback right before presentation moves from e to another element
onBeforeLeave : function(), // Callback right after presentation moves from e to another element
// Forward-navigating callbacks
onBeforeLeaveToNext : function(), // Callback right before presentation moves from e to the next element
onAfterLeaveToNext : function(), // Callback right after presentation moves from e to the next element
onBeforeEnterFromPrev : function(), // Callback right before presentation moves from the previous element to e
onAfterEnterFromPrev : function(), // Callback right after presentation moves from the previous element to e
// Backward-navigating callbacks
onBeforeLeaveToPrev : function(), // Callback right before presentation moves from e to the previous element
onAfterLeaveToPrev : function(), // Callback right after presentation moves from e to the previous element
onBeforeEnterFromNext : function(), // Callback right before presentation moves from the next element to e
onAfterEnterFromNext : function(), // Callback right after presentation moves from the next element to e
}</pre>
</li>
</ol>
<p>And <code class="inline">options</code> is an object with the following defaults</p>
<pre class="brush: js;">{
showOriginalMargins : false, // When showing an element, also show its margins
centerHorizontally : true, // When showing an element, center it horizontally
centerVertically : true, // When showing an element, center it vertically
followElementTransforms: true // Follow element transforms like rotation. If true, requires the Sylvester matrix libraries.
}</pre>
<h2>Navigation</h2>
<p>Once we have created a presentation with <pre class="brush: js;">var presentation = new Presenteer("#presentation", $("#presentation > div"));</pre> we can call the following commands to navigate through the presentation</p>
<p>
Go to the first element by doing <code class="inline">presentation.start();</code>
</p>
<p>
To go forward, call <code class="inline">presentation.next();</code>. If the end of the presentation is reached, the first element will be shown again.
</p>
<p>
To go back, call <code class="inline">presentation.prev();</code> or <code class="inline">presentation.previous();</code>. If the start of the presentation is reached, the last element will be shown again.
</p>
<p>
To go to an arbitrary element, call <code class="inline">presentation.show(index);</code> where index is 0-based.
</p>
<p>
<h2>Installation</h2>
<p>Include jQuery, Presenteer.js and Sylvester in your page.</p>
<pre class="brush: js;">
<script src="js/jquery-1.7.1.min.js"></script>
<script src="js/presenteer-1.0.min.js"></script>
</pre>
<p>Then, on page load, create Presenteer instances for all the presentations you want to show on the page : </p>
<pre class="brush: js;">var presentation = new Presenteer(
"#presentation",
$("#presentation > div"),
{ followElementTransforms: false }
);</pre>
<p>I set followElementTransforms to false to not follow element transforms. Consequently, we don't need the Sylvester matrix libraries. If you want Presenteer.js to follow element transforms (e.g. element rotations), also add the Sylvester libraries to your page</p>
<pre class="brush:js">
<script src="js/sylvester/sylvester.js"></script>
<script src="js/sylvester/matrix.js"></script>
<script src="js/sylvester/vector.js"></script>
</pre>
<p>And set <code>followElementTransforms: true</code>. This is also the default</p>
<pre class="brush: js;">var presentation = new Presenteer(
"#presentation",
$("#presentation > div"),
{ followElementTransforms: true }
);</pre>
<h2>Examples</h2>
<script>
$(window).load(function() {
var presentation2_counter = new Presenteer(
"#presentation2_counter",
$("#presentation2_counter > div")
);
var presentation2 = new Presenteer(
"#presentation2",
$("#presentation2 > div"),
{ onAfterEnter : function(elm) { setTimeout(function(){presentation2_counter.prev()},1); } }
);
$("#presentationcontainer2_counter").on("click", function() { presentation2.next(); });
$("#presentationcontainer2").on("click", function() { presentation2.next(); });
presentation2_counter.start();
presentation2.start();
});
</script>
<div class="presentationcontainer" id="presentationcontainer2">
<div class="presentation" id="presentation2">
<div>Woo, that's a nice slide-counter at the right side! Click!</div>
<div id="r" style="-webkit-transform: translate(0px, 50px) rotate(90.01deg); -moz-transform: translate(0px, 50px) rotate(90.01deg); -o-transform: translate(0px, 50px) rotate(90.01deg); -ms-transform: translate(0px, 50px) rotate(90.01deg); transform: translate(0px, 50px) rotate(90.01deg);">90 degree ROTATION</div>
<div style="-webkit-transform: translate(0,100px); -moz-transform: translate(0,100px); -o-transform: translate(0,100px); -ms-transform: translate(0,100px); transform: translate(0,100px);">And back! That's it for this demo. Click to restart.</div>
</div>
</div>
<div class="presentationcontainer" id="presentationcontainer2_counter">
<div class="presentation" id="presentation2_counter">
<div>3</div>
<div>2</div>
<div>1</div>
</div>
</div>
<div class="clearfix">.</div>
<p>Code is as simple as</p>
<pre class="brush: js;">
var presentation2_counter = new Presenteer(
"#presentation2_counter",
$("#presentation2_counter > div")
);
var presentation2 = new Presenteer(
"#presentation2",
$("#presentation2 > div"),
{ onAfterEnter : function(elm) { setTimeout(function(){presentation2_counter.prev()},1); } }
);
$("#presentationcontainer2_counter").on("click", function() { presentation2.next(); });
$("#presentationcontainer2").on("click", function() { presentation2.next(); });
presentation2_counter.start();
presentation2.start();
</pre>
</div>
</div>
</body>
</html>