From 213c8d13541f3ac4c68098a6528d1bdcc716ab32 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sat, 28 Jun 2014 12:58:33 +0200 Subject: [PATCH] fix double-navigation on touch for some android systems --- css/reveal.css | 3 +++ js/reveal.js | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/css/reveal.css b/css/reveal.css index 54106e5f..20d14052 100644 --- a/css/reveal.css +++ b/css/reveal.css @@ -248,6 +248,8 @@ body { z-index: 30; right: 10px; bottom: 10px; + + -webkit-user-select: none; } .reveal .controls div { @@ -258,6 +260,7 @@ body { border: 12px solid transparent; -moz-transform: scale(.9999); + -webkit-tap-highlight-color: rgba( 0, 0, 0, 0 ); -webkit-transition: all 0.2s ease; -moz-transition: all 0.2s ease; diff --git a/js/reveal.js b/js/reveal.js index edf30731..270bf63f 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -291,6 +291,8 @@ features.canvas = !!document.createElement( 'canvas' ).getContext; + features.touch = !!( 'ontouchstart' in window ); + isMobileDevice = navigator.userAgent.match( /(iphone|ipod|ipad|android)/gi ); } @@ -907,14 +909,13 @@ } } - [ 'touchstart', 'click' ].forEach( function( eventName ) { - dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } ); - dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } ); - dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } ); - dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } ); - dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } ); - dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } ); - } ); + var eventName = features.touch ? 'touchstart' : 'click'; + dom.controlsLeft.forEach( function( el ) { el.addEventListener( eventName, onNavigateLeftClicked, false ); } ); + dom.controlsRight.forEach( function( el ) { el.addEventListener( eventName, onNavigateRightClicked, false ); } ); + dom.controlsUp.forEach( function( el ) { el.addEventListener( eventName, onNavigateUpClicked, false ); } ); + dom.controlsDown.forEach( function( el ) { el.addEventListener( eventName, onNavigateDownClicked, false ); } ); + dom.controlsPrev.forEach( function( el ) { el.addEventListener( eventName, onNavigatePrevClicked, false ); } ); + dom.controlsNext.forEach( function( el ) { el.addEventListener( eventName, onNavigateNextClicked, false ); } ); } @@ -2604,7 +2605,6 @@ // Vimeo embeds toArray( slide.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) { if( el.hasAttribute( 'data-autoplay' ) ) { - console.log(11); el.contentWindow.postMessage( '{"method":"play"}', '*' ); } });