mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix animated scroll of "smooth scrolled" elements in browsers that support smooth scroll (Chrome/Firefox)
This commit is contained in:
parent
fe87abc5a8
commit
0502e984ad
1 changed files with 22 additions and 10 deletions
|
@ -199,6 +199,26 @@ define(["dom", "browser", "layoutManager"], function (dom, browser, layoutManage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs built-in scroll.
|
||||||
|
*
|
||||||
|
* @param {HTMLElement} xScroller horizontal scroller
|
||||||
|
* @param {number} scrollX horizontal coordinate
|
||||||
|
* @param {HTMLElement} yScroller vertical scroller
|
||||||
|
* @param {number} scrollY vertical coordinate
|
||||||
|
* @param {boolean} smooth smooth scrolling
|
||||||
|
*/
|
||||||
|
function builtinScroll(xScroller, scrollX, yScroller, scrollY, smooth) {
|
||||||
|
var scrollBehavior = smooth ? "smooth" : "instant";
|
||||||
|
|
||||||
|
if (xScroller !== yScroller) {
|
||||||
|
scrollToHelper(xScroller, {left: scrollX, behavior: scrollBehavior});
|
||||||
|
scrollToHelper(yScroller, {top: scrollY, behavior: scrollBehavior});
|
||||||
|
} else {
|
||||||
|
scrollToHelper(xScroller, {left: scrollX, top: scrollY, behavior: scrollBehavior});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var scrollTimer;
|
var scrollTimer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -238,8 +258,7 @@ define(["dom", "browser", "layoutManager"], function (dom, browser, layoutManage
|
||||||
dx = Math.round(dx*k);
|
dx = Math.round(dx*k);
|
||||||
dy = Math.round(dy*k);
|
dy = Math.round(dy*k);
|
||||||
|
|
||||||
xScroller.scrollLeft += dx;
|
builtinScroll(xScroller, xScroller.scrollLeft + dx, yScroller, yScroller.scrollTop + dy, false);
|
||||||
yScroller.scrollTop += dy;
|
|
||||||
|
|
||||||
scrollTimer = requestAnimationFrame(scrollAnim);
|
scrollTimer = requestAnimationFrame(scrollAnim);
|
||||||
};
|
};
|
||||||
|
@ -263,14 +282,7 @@ define(["dom", "browser", "layoutManager"], function (dom, browser, layoutManage
|
||||||
if (smooth && useAnimatedScroll()) {
|
if (smooth && useAnimatedScroll()) {
|
||||||
animateScroll(xScroller, scrollX, yScroller, scrollY);
|
animateScroll(xScroller, scrollX, yScroller, scrollY);
|
||||||
} else {
|
} else {
|
||||||
var scrollBehavior = smooth ? "smooth" : "instant";
|
builtinScroll(xScroller, scrollX, yScroller, scrollY, smooth);
|
||||||
|
|
||||||
if (xScroller !== yScroller) {
|
|
||||||
scrollToHelper(xScroller, {left: scrollX, behavior: scrollBehavior});
|
|
||||||
scrollToHelper(yScroller, {top: scrollY, behavior: scrollBehavior});
|
|
||||||
} else {
|
|
||||||
scrollToHelper(xScroller, {left: scrollX, top: scrollY, behavior: scrollBehavior});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue