348 lines
12 KiB
JavaScript
348 lines
12 KiB
JavaScript
define([
|
|
"exports",
|
|
"./../../layoutmanager.js",
|
|
"./../../scroller/smoothscroller.js",
|
|
"./../../headroom/headroom.js",
|
|
"./../emby-scrollbuttons/emby-scrollbuttons.js",
|
|
], function (
|
|
_exports,
|
|
_layoutmanager,
|
|
_smoothscroller,
|
|
_headroom,
|
|
_embyScrollbuttons,
|
|
) {
|
|
function onInit() {
|
|
this.classList.add("emby-scroller");
|
|
}
|
|
Object.defineProperty(_exports, "__esModule", { value: !0 }),
|
|
(_exports.default = void 0);
|
|
var headerElement = document.querySelector(".skinHeader");
|
|
var EmbyScroller = (function (_HTMLDivElement) {
|
|
babelHelpers.inherits(EmbyScroller, _HTMLDivElement);
|
|
var _super = _createSuper(EmbyScroller);
|
|
function EmbyScroller() {
|
|
babelHelpers.classCallCheck(this, EmbyScroller);
|
|
var _this,
|
|
self = (_this = _super.call(this));
|
|
return (
|
|
onInit.call(self), babelHelpers.possibleConstructorReturn(_this, self)
|
|
);
|
|
}
|
|
return (
|
|
babelHelpers.createClass(EmbyScroller, [
|
|
{
|
|
key: "connectedCallback",
|
|
value: function () {
|
|
onInit.call(this);
|
|
var horizontal = "false" !== this.getAttribute("data-horizontal"),
|
|
slider = this.querySelector(".scrollSlider"),
|
|
bindHeaderValue =
|
|
(horizontal && (slider.style["white-space"] = "nowrap"),
|
|
this.getAttribute("data-bindheader")),
|
|
bindHeaderValue =
|
|
"true" === bindHeaderValue ||
|
|
(_layoutmanager.default.tv && "tv" === bindHeaderValue),
|
|
enableScrollButtons =
|
|
!_layoutmanager.default.tv &&
|
|
(horizontal ||
|
|
"x" === this.getAttribute("data-scrollbuttonstype")) &&
|
|
"false" !== this.getAttribute("data-scrollbuttons"),
|
|
focusScroll = this.getAttribute("data-focusscroll"),
|
|
slider =
|
|
((focusScroll =
|
|
(focusScroll =
|
|
"true" === focusScroll ? "adaptive" : focusScroll) ||
|
|
("false" !== this.getAttribute("data-centerfocus")
|
|
? "adaptive"
|
|
: null)),
|
|
(this.isPrimaryScroller =
|
|
bindHeaderValue ||
|
|
"true" === this.getAttribute("data-primaryscroller")),
|
|
{
|
|
horizontal: horizontal,
|
|
mouseWheel: "false" !== this.getAttribute("data-mousewheel"),
|
|
touchDragging: 1,
|
|
slidee: slider,
|
|
dragHandle: 1,
|
|
hideScrollbar: (enableScrollButtons && horizontal) || null,
|
|
forceScrollbar:
|
|
(enableScrollButtons && horizontal) ||
|
|
"true" === this.getAttribute("data-forcescrollbar"),
|
|
allowNativeSmoothScroll:
|
|
"true" ===
|
|
this.getAttribute("data-allownativesmoothscroll"),
|
|
focusScroll: focusScroll,
|
|
focusScrollOffset:
|
|
this.getAttribute("data-focusscrolloffset") || null,
|
|
forceNativeScroll:
|
|
"true" === this.getAttribute("data-forcenativescroll"),
|
|
forceSmoothScroll:
|
|
"true" === this.getAttribute("data-forcesmoothscroll"),
|
|
dynamicFrameSizing:
|
|
"true" === this.getAttribute("data-dynamicframesizing"),
|
|
dualScroll: "true" === this.getAttribute("data-dualscroll"),
|
|
}),
|
|
horizontal = this.getAttribute("data-adaptiveborder");
|
|
horizontal && (slider.adaptiveBorder = parseInt(horizontal)),
|
|
(this.scroller = new _smoothscroller.default(this, slider)),
|
|
this.scroller.init(),
|
|
bindHeaderValue &&
|
|
((focusScroll = this),
|
|
(horizontal = new _headroom.default({
|
|
scroller: focusScroll,
|
|
element: headerElement,
|
|
enableScrollingStatus: !0,
|
|
})).init(),
|
|
(focusScroll.headroom = horizontal)),
|
|
enableScrollButtons &&
|
|
(slider =
|
|
"self" !==
|
|
(slider = this).getAttribute("data-scrollbuttonparent")
|
|
? slider.parentNode
|
|
: slider).insertAdjacentHTML(
|
|
"afterbegin",
|
|
'<div is="emby-scrollbuttons" class="emby-scrollbuttons"></div>',
|
|
),
|
|
this.dispatchEvent(
|
|
new CustomEvent("upgraded", { cancelable: !1 }),
|
|
);
|
|
},
|
|
},
|
|
{
|
|
key: "disconnectedCallback",
|
|
value: function () {
|
|
var headroom = this.headroom,
|
|
headroom =
|
|
(headroom && (headroom.destroy(), (this.headroom = null)),
|
|
this.scroller);
|
|
headroom && (headroom.destroy(), (this.scroller = null));
|
|
},
|
|
},
|
|
{
|
|
key: "pause",
|
|
value: function () {
|
|
this.paused = !0;
|
|
var headroom = this.headroom;
|
|
headroom && headroom.pause();
|
|
},
|
|
},
|
|
{
|
|
key: "beginResume",
|
|
value: function () {
|
|
this.paused = !1;
|
|
var headroom = this.headroom;
|
|
headroom && headroom.beginResume();
|
|
},
|
|
},
|
|
{
|
|
key: "resume",
|
|
value: function () {
|
|
this.paused = !1;
|
|
var headroom = this.headroom;
|
|
headroom
|
|
? headroom.resume()
|
|
: this.isPrimaryScroller &&
|
|
(headerElement.classList.add("headroom-scrolling"),
|
|
headerElement.classList.remove("headroom-hidden"));
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollSize",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollSize();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollWidth",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollWidth();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollHeight",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollHeight();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollPosition",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollPosition();
|
|
},
|
|
},
|
|
{
|
|
key: "getLastScrollPosition",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getLastScrollPosition();
|
|
},
|
|
},
|
|
{
|
|
key: "isNativeScroll",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.isNativeScroll();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollLeft",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollLeft();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollTop",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollTop();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollContainerBoundingClientRect",
|
|
value: function () {
|
|
if (this.scroller)
|
|
return this.scroller.getScrollContainerBoundingClientRect();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollSlider",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollSlider();
|
|
},
|
|
},
|
|
{
|
|
key: "scrollToBeginning",
|
|
value: function (scrollOptions) {
|
|
if (this.scroller)
|
|
return (
|
|
((scrollOptions = scrollOptions || {}).position = 0),
|
|
this.scroller.scrollToPosition(scrollOptions)
|
|
);
|
|
},
|
|
},
|
|
{
|
|
key: "toStart",
|
|
value: function (elem, scrollOptions) {
|
|
this.scroller && this.scroller.toStart(elem, scrollOptions);
|
|
},
|
|
},
|
|
{
|
|
key: "toCenter",
|
|
value: function (elem, scrollOptions) {
|
|
this.scroller && this.scroller.toCenter(elem, scrollOptions);
|
|
},
|
|
},
|
|
{
|
|
key: "scrollToElement",
|
|
value: function (elem, scrollOptions) {
|
|
this.scroller && this.scroller.scrollToElement(elem, scrollOptions);
|
|
},
|
|
},
|
|
{
|
|
key: "scrollToPosition",
|
|
value: function (pos) {
|
|
if (this.scroller) return this.scroller.scrollToPosition(pos);
|
|
},
|
|
},
|
|
{
|
|
key: "addScrollEventListener",
|
|
value: function (fn, options) {
|
|
this.scroller && this.scroller.addScrollEventListener(fn, options);
|
|
},
|
|
},
|
|
{
|
|
key: "removeScrollEventListener",
|
|
value: function (fn, options) {
|
|
this.scroller &&
|
|
this.scroller.removeScrollEventListener(fn, options);
|
|
},
|
|
},
|
|
{
|
|
key: "scrollBackwards",
|
|
value: function () {
|
|
this.scroller && this.scroller.scrollBackwards();
|
|
},
|
|
},
|
|
{
|
|
key: "scrollForwards",
|
|
value: function () {
|
|
this.scroller && this.scroller.scrollForwards();
|
|
},
|
|
},
|
|
{
|
|
key: "addResizeObserver",
|
|
value: function (fn) {
|
|
this.scroller && this.scroller.addResizeObserver(fn);
|
|
},
|
|
},
|
|
{
|
|
key: "removeResizeObserver",
|
|
value: function (fn) {
|
|
this.scroller && this.scroller.removeResizeObserver(fn);
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollMultiplier",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollMultiplier();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollLeftMultiplier",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollLeftMultiplier();
|
|
},
|
|
},
|
|
{
|
|
key: "getScrollTopMultiplier",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getScrollTopMultiplier();
|
|
},
|
|
},
|
|
{
|
|
key: "getPadding",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.getPadding();
|
|
},
|
|
},
|
|
{
|
|
key: "getElementPosition",
|
|
value: function (element, horizontal, scrollOptions) {
|
|
if (this.scroller)
|
|
return this.scroller.getElementPosition(
|
|
element,
|
|
horizontal,
|
|
scrollOptions,
|
|
);
|
|
},
|
|
},
|
|
{
|
|
key: "notifyResized",
|
|
value: function () {
|
|
if (this.scroller) return this.scroller.notifyResized();
|
|
},
|
|
},
|
|
{
|
|
key: "setHeaderBindingEnabled",
|
|
value: function (enabled) {
|
|
this.headroom &&
|
|
!this.paused &&
|
|
(enabled
|
|
? (this.headroom.beginResume({}), this.headroom.resume({}))
|
|
: this.headroom.pause());
|
|
},
|
|
},
|
|
{
|
|
key: "setFocusScroll",
|
|
value: function (focusScroll) {
|
|
this.scroller &&
|
|
(null == focusScroll && (focusScroll = "adaptive"),
|
|
this.scroller.options) &&
|
|
(this.scroller.options.focusScroll = focusScroll);
|
|
},
|
|
},
|
|
]),
|
|
EmbyScroller
|
|
);
|
|
})(babelHelpers.wrapNativeSuper(HTMLDivElement));
|
|
customElements.define("emby-scroller", EmbyScroller, { extends: "div" }),
|
|
(_exports.default = EmbyScroller);
|
|
});
|