mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Check an overflow value and stop on fixed parent
This commit is contained in:
parent
2fe6a63542
commit
65373c8ae5
1 changed files with 28 additions and 13 deletions
|
@ -201,6 +201,19 @@ import layoutManager from './layoutManager';
|
||||||
*/
|
*/
|
||||||
const documentScroller = new DocumentScroller();
|
const documentScroller = new DocumentScroller();
|
||||||
|
|
||||||
|
const scrollerHints = {
|
||||||
|
x: {
|
||||||
|
nameScroll: 'scrollWidth',
|
||||||
|
nameClient: 'clientWidth',
|
||||||
|
nameStyle: 'overflowX'
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
nameScroll: 'scrollHeight',
|
||||||
|
nameClient: 'clientHeight',
|
||||||
|
nameStyle: 'overflowY'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns parent element that can be scrolled. If no such, returns document scroller.
|
* Returns parent element that can be scrolled. If no such, returns document scroller.
|
||||||
*
|
*
|
||||||
|
@ -210,24 +223,26 @@ import layoutManager from './layoutManager';
|
||||||
*/
|
*/
|
||||||
function getScrollableParent(element, vertical) {
|
function getScrollableParent(element, vertical) {
|
||||||
if (element) {
|
if (element) {
|
||||||
let nameScroll = 'scrollWidth';
|
const scrollerHint = vertical ? scrollerHints.y : scrollerHints.x;
|
||||||
let nameClient = 'clientWidth';
|
|
||||||
let nameClass = 'scrollX';
|
|
||||||
|
|
||||||
if (vertical) {
|
|
||||||
nameScroll = 'scrollHeight';
|
|
||||||
nameClient = 'clientHeight';
|
|
||||||
nameClass = 'scrollY';
|
|
||||||
}
|
|
||||||
|
|
||||||
let parent = element.parentElement;
|
let parent = element.parentElement;
|
||||||
|
|
||||||
while (parent) {
|
while (parent && parent !== document.body) {
|
||||||
// Skip 'emby-scroller' and 'emby-tabs' because they scroll by themselves
|
// Skip 'emby-scroller' and 'emby-tabs' because they scroll by themselves
|
||||||
if (!parent.classList.contains('emby-scroller') &&
|
if (!parent.classList.contains('emby-scroller') &&
|
||||||
!parent.classList.contains('emby-tabs') &&
|
!parent.classList.contains('emby-tabs')) {
|
||||||
parent[nameScroll] > parent[nameClient] && parent.classList.contains(nameClass)) {
|
const styles = window.getComputedStyle(parent);
|
||||||
return parent;
|
|
||||||
|
// Stop on fixed parent
|
||||||
|
if (styles.position === 'fixed') {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
const overflow = styles[scrollerHint.nameStyle];
|
||||||
|
|
||||||
|
if (overflow === 'scroll' || overflow === 'auto' && parent[scrollerHint.nameScroll] > parent[scrollerHint.nameClient]) {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parent = parent.parentElement;
|
parent = parent.parentElement;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue