-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make legend toggle work in IE11 #2741
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,38 @@ export var isWithinBox = function(point, box, sensitivity = 0) { | |
return xStart < point[0] && point[0] < xEnd && yEnd < point[1] && point[1] < yStart; | ||
}; | ||
|
||
/** | ||
* Returns Internet Explorer version number (or false if no Internet Explorer used). | ||
*/ | ||
export var getIEVersion = function() { | ||
// https://stackoverflow.com/questions/19999388/check-if-user-is-using-ie | ||
const agent = window.navigator.userAgent; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about taking
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, let's do this. I'm going to modify getIEVersion() to take an optional parameter so usage is kept simple and it can be tested as well. |
||
|
||
let pos = agent.indexOf('MSIE '); // up to IE10 | ||
if (pos > 0) { | ||
return parseInt(agent.substring(pos + 5, agent.indexOf('.', pos)), 10); | ||
} | ||
|
||
pos = agent.indexOf('Trident/'); // IE11 | ||
if (pos > 0) { | ||
pos = agent.indexOf('rv:'); | ||
return parseInt(agent.substring(pos + 3, agent.indexOf('.', pos)), 10); | ||
} | ||
|
||
return false; | ||
}; | ||
|
||
/** | ||
* Returns whether the used browser is Internet Explorer. | ||
* | ||
* @param {Number} version Optional parameter to specify IE version | ||
*/ | ||
export var isIE = function(version) { | ||
const ver = getIEVersion(); | ||
|
||
if (typeof version === 'undefined') { | ||
return !!ver; | ||
} | ||
|
||
return version === ver; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!