1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/emby-scroller/emby-scroller.js

1 line
1.8 KiB
JavaScript
Raw Normal View History

2017-03-01 15:29:42 -05:00
define(["scroller","dom","layoutManager","registerElement"],function(scroller,dom,layoutManager){"use strict";function initCenterFocus(elem,scrollerInstance,selector){var classNames=selector.split(",");dom.addEventListener(elem,"focus",function(e){var focused=dom.parentWithClass(e.target,classNames);focused&&scrollerInstance.toCenter(focused)},{capture:!0,passive:!0})}var ScrollerProtoType=Object.create(HTMLDivElement.prototype);ScrollerProtoType.createdCallback=function(){this.classList.add("emby-scroller")},ScrollerProtoType.scrollToBeginning=function(){this.scroller&&this.scroller.slideTo(0,!0)},ScrollerProtoType.scrollToPosition=function(pos,immediate){this.scroller&&this.scroller.slideTo(pos,immediate)},ScrollerProtoType.getScrollPosition=function(){if(this.scroller)return this.scroller.getScrollPosition()},ScrollerProtoType.attachedCallback=function(){var horizontal="false"!==this.getAttribute("data-horizontal"),slider=this.querySelector(".scrollSlider");horizontal&&(slider.style["white-space"]="nowrap");var options={horizontal:horizontal,mouseDragging:1,mouseWheel:"false"!==this.getAttribute("data-mousewheel"),touchDragging:1,slidee:slider,scrollBy:200,speed:300,elasticBounds:1,dragHandle:1,scrollWidth:5e5,autoImmediate:!0,skipSlideToWhenVisible:"true"===this.getAttribute("data-skipfocuswhenvisible"),dispatchScrollEvent:"true"===this.getAttribute("data-scrollevent")},self=this;setTimeout(function(){self.scroller=new scroller(self,options),self.scroller.init();var centerFocus=self.getAttribute("data-centerfocus");centerFocus&&layoutManager.tv&&initCenterFocus(self,self.scroller,centerFocus)},0)},ScrollerProtoType.detachedCallback=function(){var scrollerInstance=this.scroller;scrollerInstance&&(scrollerInstance.destroy(),this.scroller=null)},document.registerElement("emby-scroller",{prototype:ScrollerProtoType,extends:"div"})});