Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Last active August 29, 2015 14:20
Show Gist options
  • Save anasnakawa/93a3b826c94475a3710e to your computer and use it in GitHub Desktop.
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.
/**
* 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