aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartek Szopka <bartek.szopka+github@gmail.com>2012-03-06 21:43:38 +0100
committerBartek Szopka <bartek.szopka+github@gmail.com>2012-03-06 21:43:38 +0100
commit456817d3b59a9e800bcad292a5d74c2dc4d2f502 (patch)
tree2f34155d5b6f653cbc20261c378b9838260e0b1e
parent45fcf19c4d2c8096fbafe71de67e2c5279d4d70d (diff)
downloadimpress.js-456817d3b59a9e800bcad292a5d74c2dc4d2f502.tar.gz
scaling elements to make them fit the screen (by @fmate14)
-rw-r--r--js/impress.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/js/impress.js b/js/impress.js
index 7395cd9..f82dad1 100644
--- a/js/impress.js
+++ b/js/impress.js
@@ -141,6 +141,19 @@
document.head.appendChild(meta);
}
+ // configuration object
+ // probably will get extended (and configurable) later
+ var config = {
+ width: 1024,
+ height: 768
+ }
+
+ // computing scale of the window
+ var hScale = window.innerHeight / config.height;
+ var wScale = window.innerWidth / config.width;
+ var windowScale = hScale > wScale ? wScale : hScale;
+
+
var canvas = document.createElement("div");
canvas.className = "canvas";
@@ -285,8 +298,8 @@
css(root, {
// to keep the perspective look similar for different scales
// we need to 'scale' the perspective, too
- perspective: step.scale * 1000 + "px",
- transform: scale(target.scale),
+ perspective: step.scale * (1/windowScale) * 1000 + "px",
+ transform: scale(target.scale * windowScale),
transitionDuration: duration,
transitionDelay: (zoomin ? "500ms" : "0ms")
});