mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fixed scrollButtons
This commit is contained in:
parent
a27ababb3e
commit
0f8c87108b
2 changed files with 25 additions and 7 deletions
|
@ -140,6 +140,13 @@ const EmbyScrollButtonsPrototype = Object.create(HTMLDivElement.prototype);
|
||||||
newPos = scrollPos + scrollSize;
|
newPos = scrollPos + scrollSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (globalize.getIsRTL() && direction === 'left') {
|
||||||
|
newPos = scrollPos + scrollSize;
|
||||||
|
} else if (globalize.getIsRTL()) {
|
||||||
|
newPos = Math.min(0, scrollPos - scrollSize);
|
||||||
|
}
|
||||||
|
console.log(newPos);
|
||||||
|
|
||||||
scroller.scrollToPosition(newPos, false);
|
scroller.scrollToPosition(newPos, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,9 @@ function disableOneEvent(event) {
|
||||||
*
|
*
|
||||||
* @return {Number}
|
* @return {Number}
|
||||||
*/
|
*/
|
||||||
function within(number, min, max) {
|
function within(number, num1, num2) {
|
||||||
|
const min = Math.min(num1, num2);
|
||||||
|
const max = Math.max(num1, num2);
|
||||||
if (number < min) {
|
if (number < min) {
|
||||||
return min;
|
return min;
|
||||||
} else if (number > max) {
|
} else if (number > max) {
|
||||||
|
@ -174,6 +176,8 @@ const scrollerFactory = function (frame, options) {
|
||||||
|
|
||||||
// Set position limits & relativess
|
// Set position limits & relativess
|
||||||
self._pos.end = Math.max(slideeSize - frameSize, 0);
|
self._pos.end = Math.max(slideeSize - frameSize, 0);
|
||||||
|
if (globalize.getIsRTL())
|
||||||
|
self._pos.end *= -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,9 +273,6 @@ const scrollerFactory = function (frame, options) {
|
||||||
newPos = within(newPos, pos.start, pos.end);
|
newPos = within(newPos, pos.start, pos.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalize.getIsRTL())
|
|
||||||
newPos *= -1;
|
|
||||||
|
|
||||||
if (!transform) {
|
if (!transform) {
|
||||||
nativeScrollTo(nativeScrollElement, newPos, immediate);
|
nativeScrollTo(nativeScrollElement, newPos, immediate);
|
||||||
return;
|
return;
|
||||||
|
@ -360,7 +361,12 @@ const scrollerFactory = function (frame, options) {
|
||||||
const slideeOffset = getBoundingClientRect(scrollElement);
|
const slideeOffset = getBoundingClientRect(scrollElement);
|
||||||
const itemOffset = getBoundingClientRect(item);
|
const itemOffset = getBoundingClientRect(item);
|
||||||
|
|
||||||
let offset = o.horizontal ? itemOffset.left - slideeOffset.left : itemOffset.top - slideeOffset.top;
|
let horizontalOffset = itemOffset.left - slideeOffset.left;
|
||||||
|
if (globalize.getIsRTL()) {
|
||||||
|
horizontalOffset = itemOffset.right - slideeOffset.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
let offset = o.horizontal ? horizontalOffset : itemOffset.top - slideeOffset.top;
|
||||||
|
|
||||||
let size = o.horizontal ? itemOffset.width : itemOffset.height;
|
let size = o.horizontal ? itemOffset.width : itemOffset.height;
|
||||||
if (!size && size !== 0) {
|
if (!size && size !== 0) {
|
||||||
|
@ -384,12 +390,17 @@ const scrollerFactory = function (frame, options) {
|
||||||
const currentEnd = currentStart + frameSize;
|
const currentEnd = currentStart + frameSize;
|
||||||
|
|
||||||
console.debug('offset:' + offset + ' currentStart:' + currentStart + ' currentEnd:' + currentEnd);
|
console.debug('offset:' + offset + ' currentStart:' + currentStart + ' currentEnd:' + currentEnd);
|
||||||
const isVisible = offset >= currentStart && (offset + size) <= currentEnd;
|
const isVisible = offset >= Math.min(currentStart, currentEnd)
|
||||||
|
&& (offset + size) <= Math.max(currentStart, currentEnd);
|
||||||
|
|
||||||
|
let end = offset - frameSize + size;
|
||||||
|
if (globalize.getIsRTL())
|
||||||
|
end *= -1;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: offset,
|
start: offset,
|
||||||
center: offset + centerOffset - (frameSize / 2) + (size / 2),
|
center: offset + centerOffset - (frameSize / 2) + (size / 2),
|
||||||
end: offset - frameSize + size,
|
end,
|
||||||
size: size,
|
size: size,
|
||||||
isVisible: isVisible
|
isVisible: isVisible
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue