grid-layout-plus
Version:
<p align="center"> <a href="https://grid-layout-plus.netlify.app/" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/grid-layout-plus.svg" width="180" style="width: 120px;" /> </a> </p>
27 lines (22 loc) • 588 B
text/typescript
let currentDir: 'ltr' | 'rtl' | 'auto' = 'auto'
function hasDocument() {
return typeof document !== 'undefined'
}
export function getDocumentDir() {
if (!hasDocument()) {
return currentDir
}
const direction =
typeof document.dir !== 'undefined'
? document.dir
: document.getElementsByTagName('html')[0].getAttribute('dir')
return direction
}
export function setDocumentDir(dir: 'ltr' | 'rtl' | 'auto') {
if (!hasDocument()) {
currentDir = dir
return
}
const html = document.getElementsByTagName('html')[0]
html.setAttribute('dir', dir)
}