Skip to content

Commit

Permalink
reverse slider thumb offset if css direction is rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerwyn committed Sep 13, 2024
1 parent 67ef0f8 commit 4abf43e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/universal-remote-card.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "universal-remote-card",
"version": "4.0.4",
"version": "4.0.5",
"description": "Universal Remote Card",
"main": "./dist/universal-remote-card.min.js",
"scripts": {
Expand Down
11 changes: 8 additions & 3 deletions src/classes/remote-slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class RemoteSlider extends BaseRemoteElement {
this.setThumbOffset();
}
});
rtl: boolean = false;

onInput(e: InputEvent) {
const slider = e.currentTarget as HTMLInputElement;
Expand Down Expand Up @@ -250,7 +251,7 @@ export class RemoteSlider extends BaseRemoteElement {
buildBackground() {
const style: StyleInfo = {};
if (this.vertical) {
style['transform'] = 'rotateZ(270deg)';
style['transform'] = `rotateZ(${this.rtl ? '90deg' : '270deg'})`;
style['width'] = `${this.sliderWidth}px`;
style[
'height'
Expand Down Expand Up @@ -320,7 +321,7 @@ export class RemoteSlider extends BaseRemoteElement {
style['pointer-events'] = 'none';
}
if (this.vertical) {
style['transform'] = 'rotateZ(270deg)';
style['transform'] = `rotateZ(${this.rtl ? '90deg' : '270deg'})`;
style['height'] = `${this.sliderHeight}px`;
style['width'] = `${this.sliderWidth}px`;
style['touch-action'] = 'none';
Expand Down Expand Up @@ -411,8 +412,12 @@ export class RemoteSlider extends BaseRemoteElement {
containerStyle['width'] = 'var(--height)';
}
}
this.rtl = getComputedStyle(this).direction == 'rtl';
this.setThumbOffset();
this.style.setProperty('--thumb-offset', `${this.thumbOffset}px`);
this.style.setProperty(
'--thumb-offset',
`${this.rtl ? '-1 * ' : ''}${this.thumbOffset})px`,
);

return html`
<div class="container" style=${styleMap(containerStyle)}>
Expand Down

0 comments on commit 4abf43e

Please sign in to comment.