Skip to content

Commit

Permalink
Fixes hakimel#1549, now UA match is limiting out MS Edge and Chrome d…
Browse files Browse the repository at this point in the history
…etection is improved. Also improved UserAgent access by storing it in to a local variable, it was accessed so many times in different places.
  • Loading branch information
Markku Roponen committed Apr 8, 2016
1 parent e83e275 commit a63c8ca
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
HORIZONTAL_SLIDES_SELECTOR = '.slides>section',
VERTICAL_SLIDES_SELECTOR = '.slides>section.present>section',
HOME_SLIDE_SELECTOR = '.slides>section:first-of-type',
UA = navigator.userAgent,

// Configuration defaults, can be overridden at initialization time
config = {
Expand Down Expand Up @@ -197,6 +198,9 @@
// Client is a mobile device, see #checkCapabilities()
isMobileDevice,

// Client is a desktop Chrome, see #checkCapabilities()
isChrome,

// Throttles mouse wheel navigation
lastMouseWheelStep = 0,

Expand Down Expand Up @@ -301,7 +305,8 @@
*/
function checkCapabilities() {

isMobileDevice = /(iphone|ipod|ipad|android)/gi.test( navigator.userAgent );
isMobileDevice = /(iphone|ipod|ipad|android)/gi.test( UA );
isChrome = /chrome/i.test( UA ) && !/edge/i.test( UA );

var testElement = document.createElement( 'div' );

Expand All @@ -324,13 +329,13 @@

// Transitions in the overview are disabled in desktop and
// Safari due to lag
features.overviewTransitions = !/Version\/[\d\.]+.*Safari/.test( navigator.userAgent );
features.overviewTransitions = !/Version\/[\d\.]+.*Safari/.test( UA );

// Flags if we should use zoom instead of transform to scale
// up slides. Zoom produces crisper results but has a lot of
// xbrowser quirks so we only use it in whitelsited browsers.
features.zoom = 'zoom' in testElement.style && !isMobileDevice &&
( /chrome/i.test( navigator.userAgent ) || /Version\/[\d\.]+.*Safari/.test( navigator.userAgent ) );
( isChrome || /Version\/[\d\.]+.*Safari/.test( UA ) );

}

Expand Down Expand Up @@ -1048,7 +1053,7 @@

// Only support touch for Android, fixes double navigations in
// stock browser
if( navigator.userAgent.match( /android/gi ) ) {
if( UA.match( /android/gi ) ) {
pointerEvents = [ 'touchstart' ];
}

Expand Down Expand Up @@ -4183,7 +4188,7 @@
}
// There's a bug with swiping on some Android devices unless
// the default action is always prevented
else if( navigator.userAgent.match( /android/gi ) ) {
else if( UA.match( /android/gi ) ) {
event.preventDefault();
}

Expand Down

0 comments on commit a63c8ca

Please sign in to comment.