aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-17 13:13:20 +0200
committerPacien TRAN-GIRARD2014-05-17 13:13:20 +0200
commit879e4d6b8348d28ddaf2dee66f3658e6db7dac48 (patch)
tree165ac445a777dbf1485e0e7ef887226d1d7c5357 /js
parent633f35ac82a18ca9ec26125b6bd2a6b0beb698e4 (diff)
downloadio-slides-remote-879e4d6b8348d28ddaf2dee66f3658e6db7dac48.tar.gz
Scale down slides instead of cropping
Diffstat (limited to 'js')
-rw-r--r--js/slide-elastic.js30
-rw-r--r--js/slides.js6
2 files changed, 35 insertions, 1 deletions
diff --git a/js/slide-elastic.js b/js/slide-elastic.js
new file mode 100644
index 0000000..3ac491f
--- /dev/null
+++ b/js/slide-elastic.js
@@ -0,0 +1,30 @@
1/*
2 * Inspired by https://github.com/francescolaffi/elastic-google-io-slides/blob/master/js/slide-elastic.js
3 */
4(function() {
5
6 var container = document.getElementsByTagName('slides')[0];
7 var slide = document.getElementsByTagName('slide')[0];
8
9 var resize = function() {
10 var transform;
11 if (window.innerWidth < slide.offsetWidth
12 || window.innerHeight < slide.offsetHeight) {
13 var sx = window.innerWidth / slide.offsetWidth;
14 var sy = window.innerHeight / slide.offsetHeight;
15 transform = 'scale(' + Math.min(sx, sy) + ')';
16 } else {
17 transform = 'none';
18 }
19
20 container.style.MozTransform = transform;
21 container.style.WebkitTransform = transform;
22 container.style.OTransform = transform;
23 container.style.msTransform = transform;
24 container.style.transform = transform;
25 };
26
27 window.addEventListener('resize', resize);
28 resize();
29
30})();
diff --git a/js/slides.js b/js/slides.js
index 3482287..e57faa2 100644
--- a/js/slides.js
+++ b/js/slides.js
@@ -3,6 +3,7 @@ require.config({
3 'slide_config' : '../slide_config', 3 'slide_config' : '../slide_config',
4 'slide-controller' : 'slide-controller', 4 'slide-controller' : 'slide-controller',
5 'slide-deck' : 'slide-deck', 5 'slide-deck' : 'slide-deck',
6 'slide-elastic' : 'slide-elastic',
6 7
7 'modernizr' : 'modernizr.custom.56571', 8 'modernizr' : 'modernizr.custom.56571',
8 'prettify' : 'prettify/prettify', 9 'prettify' : 'prettify/prettify',
@@ -18,7 +19,10 @@ require.config({
18 'slide-deck' : { 19 'slide-deck' : {
19 deps : ['slide_config', 'slide-controller', 'modernizr'], 20 deps : ['slide_config', 'slide-controller', 'modernizr'],
20 }, 21 },
22 'slide-elastic' : {
23 deps : ['slide-deck'],
24 },
21 }, 25 },
22}); 26});
23 27
24require(['slide-deck']); 28require(['slide-elastic']);