(recalculate: boolean = false)
| 12 | // and then verify that the subsequent "scroll" event matches the negative offset. |
| 13 | // If it does not match, then we can assume a non-standard RTL scroll implementation. |
| 14 | export function getRTLOffsetType(recalculate: boolean = false): RTLOffsetType { |
| 15 | if (cachedRTLResult === null || recalculate) { |
| 16 | const outerDiv = document.createElement("div"); |
| 17 | const outerStyle = outerDiv.style; |
| 18 | outerStyle.width = "50px"; |
| 19 | outerStyle.height = "50px"; |
| 20 | outerStyle.overflow = "scroll"; |
| 21 | outerStyle.direction = "rtl"; |
| 22 | |
| 23 | const innerDiv = document.createElement("div"); |
| 24 | const innerStyle = innerDiv.style; |
| 25 | innerStyle.width = "100px"; |
| 26 | innerStyle.height = "100px"; |
| 27 | |
| 28 | outerDiv.appendChild(innerDiv); |
| 29 | |
| 30 | document.body.appendChild(outerDiv); |
| 31 | |
| 32 | if (outerDiv.scrollLeft > 0) { |
| 33 | cachedRTLResult = "positive-descending"; |
| 34 | } else { |
| 35 | outerDiv.scrollLeft = 1; |
| 36 | if (outerDiv.scrollLeft === 0) { |
| 37 | cachedRTLResult = "negative"; |
| 38 | } else { |
| 39 | cachedRTLResult = "positive-ascending"; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | document.body.removeChild(outerDiv); |
| 44 | |
| 45 | return cachedRTLResult; |
| 46 | } |
| 47 | |
| 48 | return cachedRTLResult; |
| 49 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…