material-web
material-web copied to clipboard
fix(tabs): Adjusting logic for how a tab's `offsetLeft` value is handled.
fix(tabs): Adjusting logic for how a tab's offsetLeft
value is handled.
Firefox and Chrome return different values for offsetLeft
of a particular tab. This is because the two browsers calculate the offsetParent
element of the tab differently -- Firefox, in order to not "leak" a node inside the shadow tree, traverses up parent elements until it finds one not conatined in the shadow DOM. Chrome, simply returns the parent element (regardless of it it's in the shadow DOM or not).
In the Firefox scenario, the tab.offsetLeft
value is no longer a measurement of tab's alignment in relation to the tab scroller's content element (and so the scroller calculations are off). To adjust for this, we can use the tab scroller's offsetLeft
value to calculate the tab's alignment in relation to the scroller (though we only want to do this in scenarios when the tab's offsetParent
is not the tab scroller).
Also since the Tab#computeDimensions
was being updated, I moved it out of the foundation (and also remove the adapter methods it called, since those methods weren't being used elsewhere). Tab will eventually need to be refactored away from the adapter/foundation pattern, so took the opportunity to reduce the amount of code inside the foundation/adapter.