Browse code
added a demo
Ed L authored on 17/01/2012 00:08:12
Showing 5 changed files
Showing 5 changed files
- demo/slideshow
- demo/static/.slideshow.css.swp
- demo/static/bumbrella.png
- demo/static/impress.js
- demo/static/slideshow.css
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,101 @@ |
1 |
+id: index |
|
2 |
+attrs: |
|
3 |
+ x: 0 |
|
4 |
+ y: 0 |
|
5 |
+ z: 250 |
|
6 |
+ rotate-y: 0 |
|
7 |
+ scale: 1 |
|
8 |
+style: |
|
9 |
+ background: "#bdba95" |
|
10 |
+# border: none !important |
|
11 |
+--- |
|
12 |
+# The first slide |
|
13 |
+ |
|
14 |
+- the slides are written in markdown which is easy to write |
|
15 |
+- they use a yaml config for flexibility |
|
16 |
+- it leverages the impress.js library for visual effects on WebGL browsers |
|
17 |
+- it has a reasonable fallback |
|
18 |
+ |
|
19 |
+------ |
|
20 |
+id: "who" |
|
21 |
+attrs: |
|
22 |
+ x: 250 |
|
23 |
+ y: 0 |
|
24 |
+ z: 0 |
|
25 |
+ rotate-y: 90 |
|
26 |
+ #"rotate-z": 36 |
|
27 |
+style: |
|
28 |
+ background: red |
|
29 |
+--- |
|
30 |
+## The second slide |
|
31 |
+ |
|
32 |
+1. Numbered |
|
33 |
+2. Lists |
|
34 |
+3. Work |
|
35 |
+------ |
|
36 |
+id: "what" |
|
37 |
+ |
|
38 |
+attrs: |
|
39 |
+ x: 0 |
|
40 |
+ y: 0 |
|
41 |
+ z: -250 |
|
42 |
+ rotate-y: 180 |
|
43 |
+ #"rotate-z": 108 |
|
44 |
+style: |
|
45 |
+ background: orange |
|
46 |
+--- |
|
47 |
+The text *is easily* **formatted** |
|
48 |
+------ |
|
49 |
+id: "where" |
|
50 |
+ |
|
51 |
+attrs: |
|
52 |
+ x: -250 |
|
53 |
+ y: 0 |
|
54 |
+ z: 0 |
|
55 |
+ #"rotate-z": 180 |
|
56 |
+ rotate-y: 270 |
|
57 |
+style: |
|
58 |
+ background: yellow |
|
59 |
+--- |
|
60 |
+This is some text |
|
61 |
+ |
|
62 |
+ Code blocks |
|
63 |
+ work in some ways |
|
64 |
+Some more text |
|
65 |
+------ |
|
66 |
+id: "when" |
|
67 |
+ |
|
68 |
+attrs: |
|
69 |
+ x: 0 |
|
70 |
+ y: 250 |
|
71 |
+ z: 0 |
|
72 |
+ #"rotate-z": 252 |
|
73 |
+ rotate-x: -90 |
|
74 |
+ rotate-y: 360 |
|
75 |
+style: |
|
76 |
+ background: green |
|
77 |
+--- |
|
78 |
+## Images |
|
79 |
+ |
|
80 |
+![Alt Text](https://www.google.com/logos/2012/martin_luther_king-2012-hp.jpg "an image") |
|
81 |
+ |
|
82 |
+------ |
|
83 |
+id: "save-the-date" |
|
84 |
+attrs: |
|
85 |
+ x: 0 |
|
86 |
+ y: -250 |
|
87 |
+ z: 0 |
|
88 |
+ rotate-x: -270 |
|
89 |
+ rotate-y: 360 |
|
90 |
+style: |
|
91 |
+ background: blue |
|
92 |
+--- |
|
93 |
+<div class='vcenter'> |
|
94 |
+ |
|
95 |
+# Links |
|
96 |
+ |
|
97 |
+- [Amazon Registry](https://www.amazon.com/registry/wedding/1RTS4LWC99RCK) |
|
98 |
+- [Photo Bucket](https://www.amazon.com/registry/wedding/1RTS4LWC99RCK) |
|
99 |
+- [College Website](http://thomasaquinas.edu) |
|
100 |
+ |
|
101 |
+</div> |
4 | 106 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,329 @@ |
1 |
+/** |
|
2 |
+ * impress.js |
|
3 |
+ * |
|
4 |
+ * impress.js is a presentation tool based on the power of CSS3 transforms and transitions |
|
5 |
+ * in modern browsers and inspired by the idea behind prezi.com. |
|
6 |
+ * |
|
7 |
+ * MIT Licensed. |
|
8 |
+ * |
|
9 |
+ * Copyright 2011 Bartek Szopka (@bartaz) |
|
10 |
+ */ |
|
11 |
+ |
|
12 |
+(function ( document, window ) { |
|
13 |
+ |
|
14 |
+ // HELPER FUNCTIONS |
|
15 |
+ |
|
16 |
+ var pfx = (function () { |
|
17 |
+ |
|
18 |
+ var style = document.createElement('dummy').style, |
|
19 |
+ prefixes = 'Webkit Moz O ms Khtml'.split(' '), |
|
20 |
+ memory = {}; |
|
21 |
+ |
|
22 |
+ return function ( prop ) { |
|
23 |
+ if ( typeof memory[ prop ] === "undefined" ) { |
|
24 |
+ |
|
25 |
+ var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1), |
|
26 |
+ props = (prop + ' ' + prefixes.join(ucProp + ' ') + ucProp).split(' '); |
|
27 |
+ |
|
28 |
+ memory[ prop ] = null; |
|
29 |
+ for ( var i in props ) { |
|
30 |
+ if ( style[ props[i] ] !== undefined ) { |
|
31 |
+ memory[ prop ] = props[i]; |
|
32 |
+ break; |
|
33 |
+ } |
|
34 |
+ } |
|
35 |
+ |
|
36 |
+ } |
|
37 |
+ |
|
38 |
+ return memory[ prop ]; |
|
39 |
+ } |
|
40 |
+ |
|
41 |
+ })(); |
|
42 |
+ |
|
43 |
+ var arrayify = function ( a ) { |
|
44 |
+ return [].slice.call( a ); |
|
45 |
+ }; |
|
46 |
+ |
|
47 |
+ var css = function ( el, props ) { |
|
48 |
+ var key, pkey; |
|
49 |
+ for ( key in props ) { |
|
50 |
+ if ( props.hasOwnProperty(key) ) { |
|
51 |
+ pkey = pfx(key); |
|
52 |
+ if ( pkey != null ) { |
|
53 |
+ el.style[pkey] = props[key]; |
|
54 |
+ } |
|
55 |
+ } |
|
56 |
+ } |
|
57 |
+ return el; |
|
58 |
+ } |
|
59 |
+ |
|
60 |
+ var byId = function ( id ) { |
|
61 |
+ return document.getElementById(id); |
|
62 |
+ } |
|
63 |
+ |
|
64 |
+ var $ = function ( selector, context ) { |
|
65 |
+ context = context || document; |
|
66 |
+ return context.querySelector(selector); |
|
67 |
+ }; |
|
68 |
+ |
|
69 |
+ var $$ = function ( selector, context ) { |
|
70 |
+ context = context || document; |
|
71 |
+ return arrayify( context.querySelectorAll(selector) ); |
|
72 |
+ }; |
|
73 |
+ |
|
74 |
+ var translate = function ( t ) { |
|
75 |
+ return " translate3d(" + t.x + "px," + t.y + "px," + t.z + "px) "; |
|
76 |
+ }; |
|
77 |
+ |
|
78 |
+ var rotate = function ( r, revert ) { |
|
79 |
+ var rX = " rotateX(" + r.x + "deg) ", |
|
80 |
+ rY = " rotateY(" + r.y + "deg) ", |
|
81 |
+ rZ = " rotateZ(" + r.z + "deg) "; |
|
82 |
+ |
|
83 |
+ return revert ? rZ+rY+rX : rX+rY+rZ; |
|
84 |
+ }; |
|
85 |
+ |
|
86 |
+ var scale = function ( s ) { |
|
87 |
+ return " scale(" + s + ") "; |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ // CHECK SUPPORT |
|
91 |
+ |
|
92 |
+ var ua = navigator.userAgent.toLowerCase(); |
|
93 |
+ var impressSupported = ( pfx("perspective") != null ) && |
|
94 |
+ ( ua.search(/(iphone)|(ipod)|(ipad)|(android)/) == -1 ); |
|
95 |
+ |
|
96 |
+ // DOM ELEMENTS |
|
97 |
+ |
|
98 |
+ var impress = byId("impress"); |
|
99 |
+ |
|
100 |
+ if (!impressSupported) { |
|
101 |
+ impress.className = "impress-not-supported"; |
|
102 |
+ return; |
|
103 |
+ } else { |
|
104 |
+ impress.className = ""; |
|
105 |
+ } |
|
106 |
+ |
|
107 |
+ var canvas = document.createElement("div"); |
|
108 |
+ canvas.className = "canvas"; |
|
109 |
+ |
|
110 |
+ arrayify( impress.childNodes ).forEach(function ( el ) { |
|
111 |
+ canvas.appendChild( el ); |
|
112 |
+ }); |
|
113 |
+ impress.appendChild(canvas); |
|
114 |
+ |
|
115 |
+ var steps = $$(".step", impress); |
|
116 |
+ |
|
117 |
+ // SETUP |
|
118 |
+ // set initial values and defaults |
|
119 |
+ |
|
120 |
+ document.documentElement.style.height = "100%"; |
|
121 |
+ |
|
122 |
+ css(document.body, { |
|
123 |
+ height: "100%", |
|
124 |
+ overflow: "hidden" |
|
125 |
+ }); |
|
126 |
+ |
|
127 |
+ var props = { |
|
128 |
+ position: "absolute", |
|
129 |
+ transformOrigin: "top left", |
|
130 |
+ transition: "all 1s ease-in-out", |
|
131 |
+ transformStyle: "preserve-3d" |
|
132 |
+ } |
|
133 |
+ |
|
134 |
+ css(impress, props); |
|
135 |
+ css(impress, { |
|
136 |
+ top: "50%", |
|
137 |
+ left: "50%", |
|
138 |
+ perspective: "1000px" |
|
139 |
+ }); |
|
140 |
+ css(canvas, props); |
|
141 |
+ |
|
142 |
+ var current = { |
|
143 |
+ translate: { x: 0, y: 0, z: 0 }, |
|
144 |
+ rotate: { x: 0, y: 0, z: 0 }, |
|
145 |
+ scale: 1 |
|
146 |
+ }; |
|
147 |
+ |
|
148 |
+ steps.forEach(function ( el, idx ) { |
|
149 |
+ var data = el.dataset, |
|
150 |
+ step = { |
|
151 |
+ translate: { |
|
152 |
+ x: data.x || 0, |
|
153 |
+ y: data.y || 0, |
|
154 |
+ z: data.z || 0 |
|
155 |
+ }, |
|
156 |
+ rotate: { |
|
157 |
+ x: data.rotateX || 0, |
|
158 |
+ y: data.rotateY || 0, |
|
159 |
+ z: data.rotateZ || data.rotate || 0 |
|
160 |
+ }, |
|
161 |
+ scale: data.scale || 1 |
|
162 |
+ }; |
|
163 |
+ |
|
164 |
+ el.stepData = step; |
|
165 |
+ |
|
166 |
+ if ( !el.id ) { |
|
167 |
+ el.id = "step-" + (idx + 1); |
|
168 |
+ } |
|
169 |
+ |
|
170 |
+ css(el, { |
|
171 |
+ position: "absolute", |
|
172 |
+ transform: "translate(-50%,-50%)" + |
|
173 |
+ translate(step.translate) + |
|
174 |
+ rotate(step.rotate) + |
|
175 |
+ scale(step.scale), |
|
176 |
+ transformStyle: "preserve-3d" |
|
177 |
+ }); |
|
178 |
+ |
|
179 |
+ }); |
|
180 |
+ |
|
181 |
+ // making given step active |
|
182 |
+ |
|
183 |
+ var active = null; |
|
184 |
+ var hashTimeout = null; |
|
185 |
+ |
|
186 |
+ var select = function ( el ) { |
|
187 |
+ if ( !el || !el.stepData || el == active) { |
|
188 |
+ // selected element is not defined as step or is already active |
|
189 |
+ return false; |
|
190 |
+ } |
|
191 |
+ |
|
192 |
+ // Sometimes it's possible to trigger focus on first link with some keyboard action. |
|
193 |
+ // Browser in such a case tries to scroll the page to make this element visible |
|
194 |
+ // (even that body overflow is set to hidden) and it breaks our careful positioning. |
|
195 |
+ // |
|
196 |
+ // So, as a lousy (and lazy) workaround we will make the page scroll back to the top |
|
197 |
+ // whenever slide is selected |
|
198 |
+ // |
|
199 |
+ // If you are reading this and know any better way to handle it, I'll be glad to hear about it! |
|
200 |
+ window.scrollTo(0, 0); |
|
201 |
+ |
|
202 |
+ var step = el.stepData; |
|
203 |
+ |
|
204 |
+ if ( active ) { |
|
205 |
+ active.classList.remove("active"); |
|
206 |
+ } |
|
207 |
+ el.classList.add("active"); |
|
208 |
+ |
|
209 |
+ impress.className = "step-" + el.id; |
|
210 |
+ |
|
211 |
+ // `#/step-id` is used instead of `#step-id` to prevent default browser |
|
212 |
+ // scrolling to element in hash |
|
213 |
+ // |
|
214 |
+ // and it has to be set after animation finishes, because in chrome it |
|
215 |
+ // causes transtion being laggy |
|
216 |
+ window.clearTimeout( hashTimeout ); |
|
217 |
+ hashTimeout = window.setTimeout(function () { |
|
218 |
+ window.location.hash = "#/" + el.id; |
|
219 |
+ }, 1000); |
|
220 |
+ |
|
221 |
+ var target = { |
|
222 |
+ rotate: { |
|
223 |
+ x: -parseInt(step.rotate.x, 10), |
|
224 |
+ y: -parseInt(step.rotate.y, 10), |
|
225 |
+ z: -parseInt(step.rotate.z, 10) |
|
226 |
+ }, |
|
227 |
+ translate: { |
|
228 |
+ x: -step.translate.x, |
|
229 |
+ y: -step.translate.y, |
|
230 |
+ z: -step.translate.z |
|
231 |
+ }, |
|
232 |
+ scale: 1 / parseFloat(step.scale) |
|
233 |
+ }; |
|
234 |
+ |
|
235 |
+ var zoomin = target.scale >= current.scale; |
|
236 |
+ |
|
237 |
+ css(impress, { |
|
238 |
+ // to keep the perspective look similar for different scales |
|
239 |
+ // we need to 'scale' the perspective, too |
|
240 |
+ perspective: step.scale * 1000 + "px", |
|
241 |
+ transform: scale(target.scale), |
|
242 |
+ transitionDelay: (zoomin ? "500ms" : "0ms") |
|
243 |
+ }); |
|
244 |
+ |
|
245 |
+ css(canvas, { |
|
246 |
+ transform: rotate(target.rotate, true) + translate(target.translate), |
|
247 |
+ transitionDelay: (zoomin ? "0ms" : "500ms") |
|
248 |
+ }); |
|
249 |
+ |
|
250 |
+ current = target; |
|
251 |
+ active = el; |
|
252 |
+ |
|
253 |
+ return el; |
|
254 |
+ } |
|
255 |
+ |
|
256 |
+ // EVENTS |
|
257 |
+ |
|
258 |
+ document.addEventListener("keydown", function ( event ) { |
|
259 |
+ if ( event.keyCode == 9 || ( event.keyCode >= 32 && event.keyCode <= 34 ) || (event.keyCode >= 37 && event.keyCode <= 40) ) { |
|
260 |
+ var next = active; |
|
261 |
+ switch( event.keyCode ) { |
|
262 |
+ case 33: ; // pg up |
|
263 |
+ case 37: ; // left |
|
264 |
+ case 38: // up |
|
265 |
+ next = steps.indexOf( active ) - 1; |
|
266 |
+ next = next >= 0 ? steps[ next ] : steps[ steps.length-1 ]; |
|
267 |
+ break; |
|
268 |
+ case 9: ; // tab |
|
269 |
+ case 32: ; // space |
|
270 |
+ case 34: ; // pg down |
|
271 |
+ case 39: ; // right |
|
272 |
+ case 40: // down |
|
273 |
+ next = steps.indexOf( active ) + 1; |
|
274 |
+ next = next < steps.length ? steps[ next ] : steps[ 0 ]; |
|
275 |
+ break; |
|
276 |
+ } |
|
277 |
+ |
|
278 |
+ select(next); |
|
279 |
+ |
|
280 |
+ event.preventDefault(); |
|
281 |
+ } |
|
282 |
+ }, false); |
|
283 |
+ |
|
284 |
+ document.addEventListener("click", function ( event ) { |
|
285 |
+ // event delegation with "bubbling" |
|
286 |
+ // check if event target (or any of its parents is a link or a step) |
|
287 |
+ var target = event.target; |
|
288 |
+ while ( (target.tagName != "A") && |
|
289 |
+ (!target.stepData) && |
|
290 |
+ (target != document.body) ) { |
|
291 |
+ target = target.parentNode; |
|
292 |
+ } |
|
293 |
+ |
|
294 |
+ if ( target.tagName == "A" ) { |
|
295 |
+ var href = target.getAttribute("href"); |
|
296 |
+ |
|
297 |
+ // if it's a link to presentation step, target this step |
|
298 |
+ if ( href && href[0] == '#' ) { |
|
299 |
+ target = byId( href.slice(1) ); |
|
300 |
+ } |
|
301 |
+ } |
|
302 |
+ |
|
303 |
+ if ( select(target) ) { |
|
304 |
+ event.preventDefault(); |
|
305 |
+ } |
|
306 |
+ }, false); |
|
307 |
+ |
|
308 |
+ document.addEventListener("mousewheel", function ( event ) { |
|
309 |
+ next = steps.indexOf( active ) - event.wheelDelta / Math.abs(event.wheelDelta); |
|
310 |
+ next = next >= 0 ? steps[ next ] : steps[ steps.length-1 ]; |
|
311 |
+ select(next); |
|
312 |
+ }, false); |
|
313 |
+ |
|
314 |
+ var getElementFromUrl = function () { |
|
315 |
+ // get id from url # by removing `#` or `#/` from the beginning, |
|
316 |
+ // so both "fallback" `#slide-id` and "enhanced" `#/slide-id` will work |
|
317 |
+ return byId( window.location.hash.replace(/^#\/?/,"") ); |
|
318 |
+ } |
|
319 |
+ |
|
320 |
+ window.addEventListener("hashchange", function () { |
|
321 |
+ select( getElementFromUrl() ); |
|
322 |
+ }, false); |
|
323 |
+ |
|
324 |
+ // START |
|
325 |
+ // by selecting step defined in url or first step of the presentation |
|
326 |
+ select(getElementFromUrl() || steps[0]); |
|
327 |
+ |
|
328 |
+})(document, window); |
|
329 |
+ |
0 | 330 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,27 @@ |
1 |
+body { |
|
2 |
+ background: #888 |
|
3 |
+} |
|
4 |
+ |
|
5 |
+a:visited, a { |
|
6 |
+ color: inherit |
|
7 |
+} |
|
8 |
+ |
|
9 |
+#impress div.step { |
|
10 |
+ border: thick #777 outset; |
|
11 |
+ text-align: center; |
|
12 |
+ font-size: x-large; |
|
13 |
+ width: 15em; |
|
14 |
+ height: 15em; |
|
15 |
+ width: 490px; |
|
16 |
+ height: 490px; |
|
17 |
+ position: relative; |
|
18 |
+} |
|
19 |
+ |
|
20 |
+.vcenter { |
|
21 |
+ position: absolute; |
|
22 |
+ top: 50%; |
|
23 |
+ width: 100%; |
|
24 |
+ margin-top: -5em; |
|
25 |
+} |
|
26 |
+ |
|
27 |
+ |