summaryrefslogtreecommitdiffhomepage
path: root/js/reveal.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/reveal.js')
-rw-r--r--js/reveal.js90
1 files changed, 82 insertions, 8 deletions
diff --git a/js/reveal.js b/js/reveal.js
index fd8a9f0..ccb009f 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -3,7 +3,7 @@
* http://lab.hakim.se/reveal-js
* MIT licensed
*
- * Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se
+ * Copyright (C) 2011-2013 Hakim El Hattab, http://hakim.se
*/
var Reveal = (function(){
@@ -16,6 +16,19 @@ var Reveal = (function(){
// Configurations defaults, can be overridden at initialization time
config = {
+
+ // The "normal" size of the presentation, aspect ratio will be preserved
+ // when the presentation is scaled to fit different resolutions
+ width: 960,
+ height: 700,
+
+ // Factor of the display size that should remain empty around the content
+ margin: 0.1,
+
+ // Bounds for smallest/largest possible scale to apply to content
+ minScale: 0.2,
+ maxScale: 1.0,
+
// Display controls in the bottom right corner
controls: true,
@@ -81,6 +94,9 @@ var Reveal = (function(){
// all current slides.
state = [],
+ // The current scale of the presentation (see width/height config)
+ scale = 1,
+
// Cached references to DOM elements
dom = {},
@@ -128,7 +144,7 @@ var Reveal = (function(){
*/
function initialize( options ) {
- if( ( !supports2DTransforms && !supports3DTransforms ) ) {
+ if( !supports2DTransforms && !supports3DTransforms ) {
document.body.setAttribute( 'class', 'no-transforms' );
// If the browser doesn't support core features we won't be
@@ -219,10 +235,6 @@ var Reveal = (function(){
function hideAddressBar() {
if( navigator.userAgent.match( /(iphone|ipod)/i ) ) {
- // Give the page some scrollable overflow
- document.documentElement.style.overflow = 'scroll';
- document.body.style.height = '120%';
-
// Events that should trigger the address bar to hide
window.addEventListener( 'load', removeAddressBar, false );
window.addEventListener( 'orientationchange', removeAddressBar, false );
@@ -497,9 +509,18 @@ var Reveal = (function(){
*/
function removeAddressBar() {
+ if( window.orientation === 0 ) {
+ document.documentElement.style.overflow = 'scroll';
+ document.body.style.height = '120%';
+ }
+ else {
+ document.documentElement.style.overflow = '';
+ document.body.style.height = '100%';
+ }
+
setTimeout( function() {
window.scrollTo( 0, 1 );
- }, 0 );
+ }, 10 );
}
@@ -547,13 +568,61 @@ var Reveal = (function(){
*/
function layout() {
+ // Available space to scale within
+ var availableWidth = dom.wrapper.offsetWidth,
+ availableHeight = dom.wrapper.offsetHeight;
+
+ // Reduce availabe space by margin
+ availableWidth -= ( availableHeight * config.margin );
+ availableHeight -= ( availableHeight * config.margin );
+
+ // Dimensions of the content
+ var slideWidth = config.width,
+ slideHeight = config.height;
+
+ // Slide width may be a percentage of available width
+ if( typeof slideWidth === 'string' && /%$/.test( slideWidth ) ) {
+ slideWidth = parseInt( slideWidth, 10 ) / 100 * availableWidth;
+ }
+
+ // Slide height may be a percentage of available height
+ if( typeof slideHeight === 'string' && /%$/.test( slideHeight ) ) {
+ slideHeight = parseInt( slideHeight, 10 ) / 100 * availableHeight;
+ }
+
+ dom.slides.style.width = slideWidth + 'px';
+ dom.slides.style.height = slideHeight + 'px';
+
+ // Determine scale of content to fit within available space
+ scale = Math.min( availableWidth / slideWidth, availableHeight / slideHeight );
+
+ // Respect max/min scale settings
+ scale = Math.max( scale, config.minScale );
+ scale = Math.min( scale, config.maxScale );
+
+ // Prefer applying scale via zoom since Chrome blurs scaled content
+ // with nested transforms
+ if( typeof dom.slides.style.zoom !== 'undefined' && !navigator.userAgent.match( /(iphone|ipod|android)/gi ) ) {
+ dom.slides.style.zoom = scale;
+ }
+ // Apply scale transform as a fallback
+ else {
+ var transform = 'translate(-50%, -50%) scale('+ scale +') translate(50%, 50%)';
+
+ dom.slides.style.WebkitTransform = transform;
+ dom.slides.style.MozTransform = transform;
+ dom.slides.style.msTransform = transform;
+ dom.slides.style.OTransform = transform;
+ dom.slides.style.transform = transform;
+ }
+
if( config.center ) {
// Select all slides, vertical and horizontal
var slides = toArray( document.querySelectorAll( SLIDES_SELECTOR ) );
// Determine the minimum top offset for slides
- var minTop = -dom.wrapper.offsetHeight / 2;
+ var minTop = -slideHeight / 2;
for( var i = 0, len = slides.length; i < len; i++ ) {
var slide = slides[ i ];
@@ -1774,6 +1843,11 @@ var Reveal = (function(){
return currentSlide;
},
+ // Returns the current scale of the presentation content
+ getScale: function() {
+ return scale;
+ },
+
// Helper method, retrieves query string as a key/value hash
getQueryHash: function() {
var query = {};