Last active
August 29, 2015 14:20
-
-
Save anasnakawa/93a3b826c94475a3710e to your computer and use it in GitHub Desktop.
detect html document if it has right-to-left layout, even if direction is provided using css and not as an attribute.
This file contains hidden or 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
/** | |
* polyfill `getComputedStyle` in IE | |
*/ | |
window.getComputedStyle = window.getComputedStyle || function( element ) { | |
return element.currentStyle; | |
} | |
/** | |
* detect RTL layout | |
*/ | |
function isRtl() { | |
var html = document.documentElement; | |
var style = getComputedStyle( html ); | |
return style.direction === 'rtl'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment