diff --git a/js/impress.js b/js/impress.js
index dce97a2..637da41 100644
--- a/js/impress.js
+++ b/js/impress.js
@@ -179,6 +179,9 @@
transitionDuration: 1000
};
+ // Configuration options
+ var config = null;
+
// It's just an empty function ... and a useless comment.
var empty = function() { return false; };
@@ -230,9 +233,6 @@
// Array of step elements
var steps = null;
- // Configuration options
- var config = null;
-
// Scale factor of the browser window
var windowScale = null;
@@ -323,9 +323,28 @@
steps.forEach( initStep );
};
+ // Build configuration from root and defaults
+ var buildConfig = function() {
+ var rootData = root.dataset;
+ return {
+ width: lib.util.toNumber( rootData.width, defaults.width ),
+ height: lib.util.toNumber( rootData.height, defaults.height ),
+ maxScale: lib.util.toNumber( rootData.maxScale, defaults.maxScale ),
+ minScale: lib.util.toNumber( rootData.minScale, defaults.minScale ),
+ perspective: lib.util.toNumber( rootData.perspective, defaults.perspective ),
+ transitionDuration: lib.util.toNumber(
+ rootData.transitionDuration, defaults.transitionDuration
+ )
+ };
+ };
+
// `init` API function that initializes (and runs) the presentation.
var init = function() {
if ( initialized ) { return; }
+
+ // Initialize configuration object to be used by pre-init plugins.
+ // Some config may be changed by pre-init plugins.
+ config = buildConfig();
execPreInitPlugins( root );
// First we set up the viewport for mobile devices.
@@ -337,18 +356,9 @@
document.head.appendChild( meta );
}
- // Initialize configuration object
- var rootData = root.dataset;
- config = {
- width: lib.util.toNumber( rootData.width, defaults.width ),
- height: lib.util.toNumber( rootData.height, defaults.height ),
- maxScale: lib.util.toNumber( rootData.maxScale, defaults.maxScale ),
- minScale: lib.util.toNumber( rootData.minScale, defaults.minScale ),
- perspective: lib.util.toNumber( rootData.perspective, defaults.perspective ),
- transitionDuration: lib.util.toNumber(
- rootData.transitionDuration, defaults.transitionDuration
- )
- };
+ // Initialize configuration object.
+ // Pre-init plugins may make some change, so we calculate it again.
+ config = buildConfig();
windowScale = computeWindowScale( config );
@@ -890,6 +900,10 @@
preStepLeavePlugins[ weight ].push( plugin );
};
+ impress.getConfig = function() {
+ return config;
+ };
+
// Called at beginning of goto(), to execute all preStepLeave plugins.
var execPreStepLeavePlugins = function( event ) { //jshint ignore:line
for ( var i = 0; i < preStepLeavePlugins.length; i++ ) {
@@ -3663,7 +3677,8 @@
return toNumber( numeric, fallback );
} else {
var value = parseFloat( ratio[ 1 ] );
- var multiplier = ratio[ 2 ] === "w" ? window.innerWidth : window.innerHeight;
+ var config = window.impress.getConfig();
+ var multiplier = ratio[ 2 ] === "w" ? config.width : config.height;
return value * multiplier;
}
};
diff --git a/karma.conf.js b/karma.conf.js
index 0848e3c..3f1f4e4 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -22,6 +22,7 @@ module.exports = function(config) {
"test/core_tests.js",
"test/non_default.js",
"src/plugins/navigation/navigation_tests.js",
+ "test/plugins/rel/relative_to_screen_size_tests.js",
// Presentation files, for the iframe
{pattern: "test/*.html", watched: true, served: true, included: false},
{pattern: "test/plugins/*/*.html", watched: true, served: true, included: false},
diff --git a/qunit_test_runner.html b/qunit_test_runner.html
index 749f7ef..358c271 100644
--- a/qunit_test_runner.html
+++ b/qunit_test_runner.html
@@ -20,5 +20,6 @@
+