Last active
February 17, 2018 13:58
-
-
Save Takazudo/f695187a88e31b5c3165 to your computer and use it in GitHub Desktop.
position fixed detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a little modified version of | |
// position: fixed support detection from jQuery mobile. | |
// | |
// This script also defines Android2.x as out of support. | |
// | |
// https://github.com/jquery/jquery-mobile/blob/master/js/support.js | |
// http://demos.jquerymobile.com/1.4.4/toolbar-fixed/ | |
// http://jimbergman.net/webkit-version-in-android-version/ | |
Modernizr.addTest('positionfixed', function() { | |
var w = window, | |
ua = navigator.userAgent, | |
platform = navigator.platform, | |
// Rendering engine is Webkit, and capture major version | |
wkmatch = ua.match( /AppleWebKit\/([0-9]+)/ ), | |
wkversion = !!wkmatch && wkmatch[ 1 ], | |
ffmatch = ua.match( /Fennec\/([0-9]+)/ ), | |
ffversion = !!ffmatch && ffmatch[ 1 ], | |
operammobilematch = ua.match( /Opera Mobi\/([0-9]+)/ ), | |
omversion = !!operammobilematch && operammobilematch[ 1 ]; | |
if ( | |
// iOS 4.3 and older : Platform is iPhone/Pad/Touch and Webkit version is less than 534 (ios5) | |
( ( platform.indexOf( "iPhone" ) > -1 || platform.indexOf( "iPad" ) > -1 || platform.indexOf( "iPod" ) > -1 ) && wkversion && wkversion < 534 ) || | |
// Opera Mini | |
( w.operamini && ({}).toString.call( w.operamini ) === "[object OperaMini]" ) || | |
( operammobilematch && omversion < 7458 ) || | |
//Android lt 3: Platform is Android and Webkit version is less than 534 (Android 3.2.1) | |
( ua.indexOf( "Android" ) > -1 && wkversion && wkversion < 534 ) || | |
// Firefox Mobile before 6.0 - | |
( ffversion && ffversion < 6 ) || | |
// WebOS less than 3 | |
( "palmGetResource" in window && wkversion && wkversion < 534 ) || | |
// MeeGo | |
( ua.indexOf( "MeeGo" ) > -1 && ua.indexOf( "NokiaBrowser/8.5.0" ) > -1 ) ) { | |
return false; | |
} | |
return true; | |
}); | |
console.log(Modernizr.positionfixed); // true or false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment