Skip to content

Commit d572aa6

Browse files
author
Brian Vaughn
committed
Updated RTL related inline comments
1 parent b3fc81c commit d572aa6

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/createGridComponent.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ export default function createGridComponent({
343343
const { scrollLeft, scrollTop, scrollUpdateWasRequested } = this.state;
344344

345345
if (scrollUpdateWasRequested && this._outerRef != null) {
346+
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
347+
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
348+
// So we need to determine which browser behavior we're dealing with, and mimic it.
346349
const outerRef = ((this._outerRef: any): HTMLElement);
347350
if (direction === 'rtl') {
348351
const isNegative = isRTLOffsetNegative();
@@ -728,8 +731,9 @@ export default function createGridComponent({
728731
const isNegative = isRTLOffsetNegative();
729732

730733
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
731-
// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
732-
// See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
734+
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
735+
// It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
736+
// So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
733737
if (isNegative) {
734738
calculatedScrollLeft = -scrollLeft;
735739
} else {

src/createListComponent.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ export default function createListComponent({
238238
// TODO Deprecate direction "horizontal"
239239
if (direction === 'horizontal' || layout === 'horizontal') {
240240
if (direction === 'rtl') {
241+
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
242+
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
243+
// So we need to determine which browser behavior we're dealing with, and mimic it.
241244
const isNegative = isRTLOffsetNegative();
242245
if (isNegative) {
243246
outerRef.scrollLeft = -scrollOffset;
@@ -512,8 +515,9 @@ export default function createListComponent({
512515
const isNegative = isRTLOffsetNegative();
513516

514517
// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
515-
// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
516-
// See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
518+
// This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
519+
// It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
520+
// So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
517521
if (isNegative) {
518522
scrollOffset = -scrollLeft;
519523
} else {

0 commit comments

Comments
 (0)