Skip to content

Instantly share code, notes, and snippets.

@navidkashani
Last active May 9, 2018 16:02
Show Gist options
  • Save navidkashani/eb17979eed8159bd7e5f to your computer and use it in GitHub Desktop.
Save navidkashani/eb17979eed8159bd7e5f to your computer and use it in GitHub Desktop.
Check Page Direction and Return Object() for some related data
// Get Value(Sample) : dirCheck().start => 'left'
function dirCheck(dir) {
dir = dir || document.getElementsByTagName("HTML")[0].getAttribute("dir");
if (dir === 'rtl') {
return {
dir : 'rtl',
rtl : true,
ltr : false,
start : 'right',
end : 'left'
};
} else {
return {
dir : 'ltr',
rtl : false,
ltr : true,
start : 'left',
end : 'right'
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment