1 line
7.5 KiB
JavaScript
1 line
7.5 KiB
JavaScript
|
|
import layoutManager from"./../../layoutmanager.js";import scroller from"./../../scroller/smoothscroller.js";import Headroom from"./../../headroom/headroom.js";import"./../../customelementupgrade.js";import"./../emby-scrollbuttons/emby-scrollbuttons.js";import skinViewManager from"./../../skinviewmanager.js";function onInit(){this.classList.add("emby-scroller")}let headerElement=document.querySelector(".skinHeader"),DefaultFocusScroll="adaptive";function initHeadroom(elem){var headroom;skinViewManager.getSkinOptions().disableHeadRoom||((headroom=new Headroom({scroller:elem,element:headerElement,enableScrollingStatus:!0})).init(),elem.headroom=headroom)}let embyScrollButtonsLoaded;function loadEmbyScrollButtons(){return embyScrollButtonsLoaded?Promise.resolve():(embyScrollButtonsLoaded=!0,Emby.importModule("./modules/emby-elements/emby-scrollbuttons/emby-scrollbuttons.js"))}function loadScrollButtons(scroller){layoutManager.tv||embyScrollButtonsLoaded||loadEmbyScrollButtons();let parent=scroller;(parent="self"!==scroller.getAttribute("data-scrollbuttonparent")?parent.parentNode:parent).insertAdjacentHTML("afterbegin",'<div is="emby-scrollbuttons" class="emby-scrollbuttons"></div>')}layoutManager.tv||loadEmbyScrollButtons();class EmbyScroller extends HTMLDivElement{constructor(){var self=super();return onInit.call(self),self}connectedCallback(){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.tv&&"tv"===bindHeaderValue,enableScrollButtons=!layoutManager.tv&&(horizontal||"x"===this.getAttribute("data-scrollbuttonstype"))&&"false"!==this.getAttribute("data-scrollbuttons");let focusScroll=this.getAttribute("data-focusscroll");focusScroll="true"===focusScroll?DefaultFocusScroll:"false"===focusScroll?null:focusScroll||("false"!==this.getAttribute("data-centerfocus")?DefaultFocusScroll:null),this.isPrimaryScroller=bindHeaderValue||"true"===this.getAttribute("data-primaryscroller");var forceScrollbar="true"===this.getAttribute("data-forcescrollbar"),slider={horizontal:horizontal,mouseWheel:"false"!==this.getAttribute("data-mousewheel"),touchDragging:1,slidee:slider,dragHandle:1,hideScrollbar:enableScrollButtons&&horizontal||!forceScrollbar&&null,forceScrollbar:enableScrollButtons&&horizontal||forceScrollbar,allowNativeSmoothScroll:"true"===this.getAttribute("data-allownativesmoothscroll"),focusScroll:focusScroll,focusScrollOffsetLeft:this.getAttribute("data-focusscrolloffsetleft")||this.getAttribute("data-focusscrolloffset")||null,focusScrollOffsetTop:this.getAttribute("data-focusscrolloffsettop")||this.getAttribute("data-focusscrolloffset")||null,forceNativeScroll:"true"===this.getAttribute("data-forcenativescroll"),forceSmoothScroll:"true"===this.getAttribute("data-forcesmoothscroll"),dualScroll:"true"===this.getAttribute("data-dualscroll"),miniScrollbar:"true"===this.getAttribute("data-miniscrollbar"),autoStartEdge:horizontal||this.isPrimaryScroller},forceScrollbar=(slider.dualScroll&&(slider.autoStartEdge=!1),horizontal||this.isPrimaryScroller||(slider.adaptiveBorderYStart=0),this.getAttribute("data-adaptiveborder")),horizontal=(forceScrollbar&&(slider.adaptiveBorderXStart=slider.adaptiveBorderXEnd=slider.adaptiveBorderYStart=slider.adaptiveBorderYEnd=parseInt(forceScrollbar)),this.getAttribute("data-adaptiveborderxstart")),forceScrollbar=(horizontal&&(slider.adaptiveBorderXStart=parseInt(horizontal)),this.getAttribute("data-adaptiveborderystart")),horizontal=(forceScrollbar&&(slider.adaptiveBorderYStart=parseInt(forceScrollbar)),this.getAttribute("data-adaptiveborderxend")),forceScrollbar=(horizontal&&(slider.adaptiveBorderXEnd=parseInt(horizontal)),this.getAttribute("data-adaptiveborderyend"));forceScrollbar&&(slider.adaptiveBorderYEnd=parseInt(forceScrollbar)),this.scroller=new scroller(this,slider),this.scroller.init(),bindHeaderValue&&initHeadroom(this),enableScrollButtons&&loadScrollButt
|