Initial support for RTL layouts
This commit is contained in:
parent
941fe35103
commit
0f994ccb5b
19 changed files with 212 additions and 25 deletions
|
@ -5,6 +5,7 @@ import keyboardnavigation from '../../scripts/keyboardNavigation';
|
|||
import './emby-slider.scss';
|
||||
import 'webcomponents.js/webcomponents-lite';
|
||||
import '../emby-input/emby-input';
|
||||
import { getIsRTL } from '../../scripts/globalize';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
|
@ -32,6 +33,10 @@ import '../emby-input/emby-input';
|
|||
|
||||
let fraction = (clientX - rect.left) / rect.width;
|
||||
|
||||
if (getIsRTL()) {
|
||||
fraction = (rect.width - (clientX - rect.left)) / rect.width;
|
||||
}
|
||||
|
||||
// Snap to step
|
||||
const valueRange = range.max - range.min;
|
||||
if (range.step !== 'any' && valueRange !== 0) {
|
||||
|
@ -111,6 +116,9 @@ import '../emby-input/emby-input';
|
|||
const bubbleRect = bubble.getBoundingClientRect();
|
||||
|
||||
let bubblePos = bubbleTrackRect.width * value / 100;
|
||||
if (getIsRTL()) {
|
||||
bubblePos = bubbleTrackRect.width - bubblePos;
|
||||
}
|
||||
bubblePos = Math.min(Math.max(bubblePos, bubbleRect.width / 2), bubbleTrackRect.width - bubbleRect.width / 2);
|
||||
|
||||
bubble.style.left = bubblePos + 'px';
|
||||
|
@ -411,7 +419,11 @@ import '../emby-input/emby-input';
|
|||
|
||||
function setRange(elem, startPercent, endPercent) {
|
||||
const style = elem.style;
|
||||
style.left = Math.max(startPercent, 0) + '%';
|
||||
if (getIsRTL()) {
|
||||
style.right = Math.max(startPercent, 0) + '%';
|
||||
} else {
|
||||
style.left = Math.max(startPercent, 0) + '%';
|
||||
}
|
||||
|
||||
const widthPercent = endPercent - startPercent;
|
||||
style.width = Math.max(Math.min(widthPercent, 100), 0) + '%';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue