aboutsummaryrefslogtreecommitdiff
path: root/js/slide-elastic.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/slide-elastic.js')
-rw-r--r--js/slide-elastic.js30
1 files changed, 30 insertions, 0 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})();