web-components
web-components copied to clipboard
Remove DirHelper as browser scroll behavior is now consistent
trafficstars
Describe your motivation
The DirHelper has been added in https://github.com/vaadin/vaadin-element-mixin/pull/32 to address browser differences with regards to how scrollLeft is calculated when using dir="rtl". Back then, as of early 2020, the situation was as follows:
- Chrome =
defaultscroll type, - Firefox / Safari =
negativetype, - IE / legacy Edge =
reversetype.
See Chromium issue for more detail. Note, the issue was marked as fixed later in July 2020 and the fix landed in Chrome 85. Regarding behavior of WebKit (Safari) mentioned in the above issue - it was fixed in 2017 to align with Gecko (Firefox).
Based on testing, all the supported browser versions now use negative scroll type, as detected using this code:
<script type="module">
import { DirHelper } from '@vaadin/component-base/src/dir-helper.js'
console.log(DirHelper.detectScrollType());
</script>
Chrome 103

Firefox 101

Safari 15.1

Edge 103

Describe the solution you'd like
- Simplify
DirHelperto removedetectScrollType()method and usenegativemode for two other methods. - Mark
DirHelperas deprecated in JSDoc /.d.tsfile and later remove in the next major release (Vaadin 24).