aboutsummaryrefslogtreecommitdiffhomepage
path: root/js/reveal.js
diff options
context:
space:
mode:
authorHakim El Hattab2013-08-10 13:10:48 -0400
committerHakim El Hattab2013-08-10 13:10:48 -0400
commit8ad81aa1a5fc99f6f70d30e1a7396492e4ff3335 (patch)
tree1acabba7bd65d932a59b1b7760d8eaa4c9548901 /js/reveal.js
parent7b5e5371576c8c57196828745e4d28adceb8417e (diff)
delay client capability test until initialization phase
Diffstat (limited to 'js/reveal.js')
-rw-r--r--js/reveal.js47
1 files changed, 32 insertions, 15 deletions
diff --git a/js/reveal.js b/js/reveal.js
index d86c22c..1503c06 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -14,8 +14,6 @@ var Reveal = (function(){
VERTICAL_SLIDES_SELECTOR = '.reveal .slides>section.present>section',
HOME_SLIDE_SELECTOR = '.reveal .slides>section:first-child',
- IS_MOBILE = navigator.userAgent.match( /(iphone|ipod|android)/gi ),
-
// Configurations defaults, can be overridden at initialization time
config = {
@@ -113,19 +111,14 @@ var Reveal = (function(){
// Cached references to DOM elements
dom = {},
- // Detect support for CSS 3D transforms
- supports3DTransforms = 'WebkitPerspective' in document.body.style ||
- 'MozPerspective' in document.body.style ||
- 'msPerspective' in document.body.style ||
- 'OPerspective' in document.body.style ||
- 'perspective' in document.body.style,
+ // Client support for CSS 3D transforms, see #checkCapabilities()
+ supports3DTransforms,
- // Detect support for CSS 2D transforms
- supports2DTransforms = 'WebkitTransform' in document.body.style ||
- 'MozTransform' in document.body.style ||
- 'msTransform' in document.body.style ||
- 'OTransform' in document.body.style ||
- 'transform' in document.body.style,
+ // Client support for CSS 2D transforms, see #checkCapabilities()
+ supports2DTransforms,
+
+ // Client is a mobile device, see #checkCapabilities()
+ isMobileDevice,
// Throttles mouse wheel navigation
lastMouseWheelStep = 0,
@@ -160,6 +153,8 @@ var Reveal = (function(){
*/
function initialize( options ) {
+ checkCapabilities();
+
if( !supports2DTransforms && !supports3DTransforms ) {
document.body.setAttribute( 'class', 'no-transforms' );
@@ -183,6 +178,28 @@ var Reveal = (function(){
}
/**
+ * Inspect the client to see what it's capable of, this
+ * should only happens once per runtime.
+ */
+ function checkCapabilities() {
+
+ supports3DTransforms = 'WebkitPerspective' in document.body.style ||
+ 'MozPerspective' in document.body.style ||
+ 'msPerspective' in document.body.style ||
+ 'OPerspective' in document.body.style ||
+ 'perspective' in document.body.style;
+
+ supports2DTransforms = 'WebkitTransform' in document.body.style ||
+ 'MozTransform' in document.body.style ||
+ 'msTransform' in document.body.style ||
+ 'OTransform' in document.body.style ||
+ 'transform' in document.body.style;
+
+ isMobileDevice = navigator.userAgent.match( /(iphone|ipod|android)/gi );
+
+ }
+
+ /**
* Finds and stores references to DOM elements which are
* required by the presentation. If a required element is
* not found, it is created.
@@ -1569,7 +1586,7 @@ var Reveal = (function(){
var threshold = 3;
// Heavily limited on weaker devices
- if( IS_MOBILE ) {
+ if( isMobileDevice ) {
threshold = 1;
}