You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
11 KiB
1 line
11 KiB
2 years ago
|
!function(l,e){"function"==typeof define&&define.amd?define(["jquery"],e):e(l.jQuery)}(this,function(l){"use strict";var e={data:{index:0,name:"scrollbar"},macosx:/mac/i.test(navigator.platform),mobile:/android|webos|iphone|ipad|ipod|blackberry/i.test(navigator.userAgent),overlay:null,scroll:null,scrolls:[],webkit:/webkit/i.test(navigator.userAgent)&&!/edge\/\d+/i.test(navigator.userAgent)};e.scrolls.add=function(l){this.remove(l).push(l)},e.scrolls.remove=function(e){for(;l.inArray(e,this)>=0;)this.splice(l.inArray(e,this),1);return this};var o={autoScrollSize:!0,autoUpdate:!0,debug:!1,disableBodyScroll:!1,duration:200,ignoreMobile:!1,ignoreOverlay:!1,scrollStep:30,showArrows:!1,stepScrolling:!0,scrollx:null,scrolly:null,onDestroy:null,onInit:null,onScroll:null,onUpdate:null},s=function(s){var r;e.scroll||(e.overlay=!((r=c(!0)).height||r.width),e.scroll=c(),n(),l(window).resize(function(){var l=!1;if(e.scroll&&(e.scroll.height||e.scroll.width)){var o=c();o.height===e.scroll.height&&o.width===e.scroll.width||(e.scroll=o,l=!0)}n(l)})),this.container=s,this.namespace=".scrollbar_"+e.data.index++,this.options=l.extend({},o,window.jQueryScrollbarOptions||{}),this.scrollTo=null,this.scrollx={},this.scrolly={},s.data(e.data.name,this),e.scrolls.add(this)};s.prototype={destroy:function(){if(this.wrapper){this.container.removeData(e.data.name),e.scrolls.remove(this);var o=this.container.scrollLeft(),s=this.container.scrollTop();this.container.insertBefore(this.wrapper).css({height:"",margin:"","max-height":""}).removeClass("scroll-content scroll-scrollx_visible scroll-scrolly_visible").off(this.namespace).scrollLeft(o).scrollTop(s),this.scrollx.scroll.removeClass("scroll-scrollx_visible").find("div").andSelf().off(this.namespace),this.scrolly.scroll.removeClass("scroll-scrolly_visible").find("div").andSelf().off(this.namespace),this.wrapper.remove(),l(document).add("body").off(this.namespace),l.isFunction(this.options.onDestroy)&&this.options.onDestroy.apply(this,[this.container])}},init:function(o){var s=this,r=this.container,t=this.containerWrapper||r,i=this.namespace,n=l.extend(this.options,o||{}),c={x:this.scrollx,y:this.scrolly},d=this.wrapper,h={scrollLeft:r.scrollLeft(),scrollTop:r.scrollTop()};if(e.mobile&&n.ignoreMobile||e.overlay&&n.ignoreOverlay||e.macosx&&!e.webkit)return!1;if(d)t.css({height:"auto","margin-bottom":-1*e.scroll.height+"px","margin-right":-1*e.scroll.width+"px","max-height":""});else{if(this.wrapper=d=l("<div>").addClass("scroll-wrapper").addClass(r.attr("class")).css("position","absolute"==r.css("position")?"absolute":"relative").insertBefore(r).append(r),r.is("textarea")&&(this.containerWrapper=t=l("<div>").insertBefore(r).append(r),d.addClass("scroll-textarea")),t.addClass("scroll-content").css({height:"auto","margin-bottom":-1*e.scroll.height+"px","margin-right":-1*e.scroll.width+"px","max-height":""}),r.on("scroll"+i,function(e){l.isFunction(n.onScroll)&&n.onScroll.call(s,{maxScroll:c.y.maxScrollOffset,scroll:r.scrollTop(),size:c.y.size,visible:c.y.visible},{maxScroll:c.x.maxScrollOffset,scroll:r.scrollLeft(),size:c.x.size,visible:c.x.visible}),c.x.isVisible&&c.x.scroll.bar.css("left",r.scrollLeft()*c.x.kx+"px"),c.y.isVisible&&c.y.scroll.bar.css("top",r.scrollTop()*c.y.kx+"px")}),d.on("scroll"+i,function(){d.scrollTop(0).scrollLeft(0)}),n.disableBodyScroll){var p=function(l){a(l)?c.y.isVisible&&c.y.mousewheel(l):c.x.isVisible&&c.x.mousewheel(l)};d.on("MozMousePixelScroll"+i,p),d.on("mousewheel"+i,p),e.mobile&&d.on("touchstart"+i,function(e){var o=e.originalEvent.touches&&e.originalEvent.touches[0]||e,s=o.pageX,t=o.pageY,n=r.scrollLeft(),c=r.scrollTop();l(document).on("touchmove"+i,function(l){var e=l.originalEvent.targetTouches&&l.originalEvent.targetTouches[0]||l;r.scrollLeft(n+s-e.pageX),r.scrollTop(c+t-e.pageY),l.preventDefault()}),l(document).on("touchend"+i,function(){l(document).off(i)})})}l.isFunction(n.onInit)&&n.onInit.apply(this,[r])}l.each(c,function(e,o){var t=null,d=1,h="x"===e?"scrollLeft":"scrollTop",p=n.scrollStep,u=function(){var l=r[h]();r[h](l+p),1==d&&l+p>=f&&(l=r[h]()),-1==d&
|