Skip to content

Commit

Permalink
Apply RTL logic for resizing (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Jan 23, 2020
1 parent 090f5cb commit b6ae782
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/vaadin-split-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,11 @@
}

var distance = this.orientation === 'vertical' ? event.detail.dy : event.detail.dx;
this._setFlexBasis(this._primaryChild, this._startSize.primary + distance, this._startSize.container);
this._setFlexBasis(this._secondaryChild, this._startSize.secondary - distance, this._startSize.container);
const isRtl = this.orientation !== 'vertical' && this.getAttribute('dir') === 'rtl';
const dirDistance = isRtl ? -distance : distance;

this._setFlexBasis(this._primaryChild, this._startSize.primary + dirDistance, this._startSize.container);
this._setFlexBasis(this._secondaryChild, this._startSize.secondary - dirDistance, this._startSize.container);

this.notifyResize();

Expand Down
21 changes: 21 additions & 0 deletions test/vaadin-split-layout_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,27 @@

expect(spy.called).to.be.true;
});

describe('RTL mode', () => {

beforeEach(() => splitLayout.setAttribute('dir', 'rtl'));

it('resizes forwards', () => {
dragHandle(distance);

expect(Math.abs((isVertical ? first : second).getBoundingClientRect()[size] - (initialSize + distance))).to.be.at.most(1);
expect(Math.abs((isVertical ? second : first).getBoundingClientRect()[size] - (initialSize - distance))).to.be.at.most(1);
});

it('resizes backwards', () => {
dragHandle(distance);
dragHandle(-distance);

expect(Math.abs((isVertical ? first : second).getBoundingClientRect()[size] - initialSize)).to.be.at.most(1);
expect(Math.abs((isVertical ? second : first).getBoundingClientRect()[size] - initialSize)).to.be.at.most(1);
});

});
});

}
Expand Down
7 changes: 7 additions & 0 deletions theme/lumo/vaadin-split-layout-styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
:host([theme~="minimal"]) > [part="splitter"]:active > [part="handle"]::after {
opacity: 1;
}

/* RTL specific styles */

:host([theme~="small"][dir="rtl"]) > [part="splitter"] {
border-left: auto;
border-right: 1px solid var(--lumo-contrast-10pct);
}
</style>
</template>
</dom-module>

0 comments on commit b6ae782

Please sign in to comment.