1 |
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define(["vue"],e):(t=t||self).vuescroll=e(t.Vue)}(this,function(t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(t,e,o){return e&&i(t.prototype,e),o&&i(t,o),t};function i(t,e){for(var o=0;o<e.length;o++){var i=e[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function b(t,e,o){return e in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}var d=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var o=arguments[e];for(var i in o)Object.prototype.hasOwnProperty.call(o,i)&&(t[i]=o[i])}return t},p=function(t){if(Array.isArray(t)){for(var e=0,o=Array(t.length);e<t.length;e++)o[e]=t[e];return o}return Array.from(t)};function s(){if(l())return!1;var t=navigator.userAgent.toLowerCase();return-1!==t.indexOf("msie")||-1!==t.indexOf("trident")||-1!==t.indexOf(" edge/")}var a=function(){return!l()&&!!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)},l=function(){return t.prototype.$isServer},m=(o(r,[{key:"getEventObject",value:function(t){return this.touchObject?this.isTouch?t.touches:[t]:null}},{key:"getTouchObject",value:function(){if(l())return null;this.isTouch=!1;var t=navigator.userAgent,e=navigator.platform,o={};switch(o.touch=!!("ontouchstart"in window&&!window.opera||"msmaxtouchpoints"in window.navigator||"maxtouchpoints"in window.navigator||0<navigator.maxTouchPoints||0<navigator.msMaxTouchPoints),o.nonDeskTouch=o.touch&&!/win32/i.test(e)||o.touch&&/win32/i.test(e)&&/mobile/i.test(t),o.eventType="onmousedown"in window&&!o.nonDeskTouch?"mouse":"ontouchstart"in window?"touch":"msmaxtouchpoints"in window.navigator||0<navigator.msMaxTouchPoints?"mstouchpoints":"maxtouchpoints"in window.navigator||0<navigator.maxTouchPoints?"touchpoints":"mouse",o.eventType){case"mouse":o.touchstart="mousedown",o.touchend="mouseup",o.touchmove="mousemove",o.touchenter="mouseenter",o.touchmove="mousemove",o.touchleave="mouseleave";break;case"touch":o.touchstart="touchstart",o.touchend="touchend",o.touchmove="touchmove",o.touchcancel="touchcancel",o.touchenter="touchstart",o.touchmove="touchmove",o.touchleave="touchend",this.isTouch=!0;break;case"mstouchpoints":o.touchstart="MSPointerDown",o.touchend="MSPointerUp",o.touchmove="MSPointerMove",o.touchcancel="MSPointerCancel",o.touchenter="MSPointerDown",o.touchmove="MSPointerMove",o.touchleave="MSPointerUp";break;case"touchpoints":o.touchstart="pointerdown",o.touchend="pointerup",o.touchmove="pointermove",o.touchcancel="pointercancel",o.touchenter="pointerdown",o.touchmove="pointermove",o.touchleave="pointerup"}return this.touchObject=o}}]),r);function r(){e(this,r)}var c=(o(u,[{key:"getRatio",value:function(){var t=0,e=window.screen,o=navigator.userAgent.toLowerCase();return void 0!==window.devicePixelRatio?t=window.devicePixelRatio:~o.indexOf("msie")?e.deviceXDPI&&e.logicalXDPI&&(t=e.deviceXDPI/e.logicalXDPI):void 0!==window.outerWidth&&void 0!==window.innerWidth&&(t=window.outerWidth/window.innerWidth),t=t&&Math.round(100*t)}},{key:"getRatioBetweenPreAndCurrent",value:function(){return this.originPixelRatio/this.lastPixelRatio}}]),u);function u(){var t=this;e(this,u),this.originPixelRatio=this.getRatio(),this.lastPixelRatio=this.originPixelRatio,window.addEventListener("resize",function(){t.lastPixelRatio=t.getRatio()})}function h(t,o,e){if(e&&x(o))return t;if(E(t))o=[],t.forEach(function(t,e){o[e]=h(t,o[e])});else if(t){if(!z(t))return t;for(var i in o={},t)o[i]="object"===n(t[i])?h(t[i],o[i]):t[i]}return o}function v(t,o,i,r){if(r&&x(o))return t;if(o=o||{},E(t))!E(o)&&i&&(o=[]),E(o)&&t.forEach(function(t,e){o[e]=v(t,o[e],i,r)});else if(t)if(z(t))for(var e in t)"object"===n(t[e])?x(o[e])?o[e]=h(t[e],o[e],r):v(t[e],o[e],i,r):(x(o[e])||i)&&(o[e]=t[e]);else i&&(o=t);return o}var f=void 0,g=void 0;function y(t,e,o,i,r){var n=3<arguments.length&&void 0!==i&&i;"on"==(4<arguments.length&&void 0!==r?r:"on")?t.addEventListener(e,o,n):t.removeEventListener(e,o,n)}function w(t){console.warn("[vuescroll] "+t)}function S(t,e){var o=!1;if(!t||!e)return o;for(;t.parentNode!==e&&9!==t.parentNode.nodeType&&!t.parentNode._isVuescroll;)t=t.parentNode;return t.parentNode==e&&(o=!0),o}function B(t,e){if(l())return!1;var o,i,r,n="-"+(o=window,r=document.documentElement.style,o.opera&&"[object Opera]"===Object.prototype.toString.call(opera)?i="presto":"MozAppearance"in r?i="gecko":"WebkitAppearance"in r?i="webkit":"string"==typeof navigator.cpuClass&&(i="trident"),{trident:"ms",gecko:"moz",webkit:"webkit",presto:"O"}[i])+"-"+e,s=document.createElement("div");return s.style[t]=n,s.style[t]==n&&n}function P(t,e,o,i,r){var n=1<arguments.length&&void 0!==e?e:[],s=2<arguments.length&&void 0!==o?o:[],a=3<arguments.length&&void 0!==i?i:{},l=r;if(n&&1<n.length)return l?[].concat(p(s),p(n)):[].concat(p(n),p(s));var c=function(t){if(!t||1<t.length)return{};var e=!!(t=t[0]?t[0]:t).componentOptions,o=void 0,i=void 0;i=e?(o=t.componentOptions.children||[],t.componentOptions.tag):(o=t.children||[],t.tag);return{isComponent:e,ch:o,tag:i}}(n=n[0]),u=c.ch,h=c.tag;return c.isComponent&&(n.data=v({attrs:n.componentOptions.propsData},n.data,!1,!0)),u=l?[].concat(p(s),p(u)):[].concat(p(u),p(s)),delete n.data.slot,t(h,v(a,n.data,!1,!0),u)}function O(t){var e=t.$parent;return!e._isVuescrollRoot&&e&&(e=e.$parent),e}var E=function(t){return Array.isArray(t)},z=function(t){return"[object Object]"==Object.prototype.toString.call(t)},x=function(t){return void 0===t};function C(t,e){var o=void 0;return o=(o=/(-?\d+(?:\.\d+?)?)%$/.exec(t))?e*(o=o[1]-0)/100:t-0}function k(){!function(t,e){if(!l()&&!document.getElementById(t)){var o=document.head||doc.getElementsByTagName("head")[0],i=document.createElement("style");i.id=t,i.type="text/css",i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e)),o.appendChild(i)}}("vuescroll-hide-ios-bar",".__hidebar::-webkit-scrollbar {\n width: 0;\n height: 0;\n }")}var R={mounted:function(){T[this._uid]=this},beforeDestroy:function(){delete T[this._uid]},methods:{scrollTo:function(t,e,o){var i=t.x,r=t.y;!0!==e&&void 0!==e||(e=this.mergedOptions.scrollPanel.speed),this.internalScrollTo(i,r,e,o)},scrollBy:function(t,e,o){var i=t.dx,r=void 0===i?0:i,n=t.dy,s=void 0===n?0:n,a=this.getPosition(),l=a.scrollLeft,c=void 0===l?0:l,u=a.scrollTop,h=void 0===u?0:u;r&&(c+=C(r,this.scrollPanelElm.scrollWidth-this.$el.clientWidth)),s&&(h+=C(s,this.scrollPanelElm.scrollHeight-this.$el.clientHeight)),this.internalScrollTo(c,h,e,o)},scrollIntoView:function(t,e){var o=!(1<arguments.length&&void 0!==e)||e,i=this.$el;if("string"==typeof t&&(t=i.querySelector(t)),S(t,i)){var r=this.$el.getBoundingClientRect(),n=r.left,s=r.top,a=t.getBoundingClientRect(),l=n-a.left,c=s-a.top;this.scrollBy({dx:-l,dy:-c},o)}else w("The element or selector you passed is not the element of Vuescroll, please pass the element that is in Vuescroll to scrollIntoView API. ")},refresh:function(){this.refreshInternalStatus(),this.$nextTick(this.refreshInternalStatus)}}},T={};var D={vuescroll:{sizeStrategy:"percent",detectResize:!0,locking:!0},scrollPanel:{initialScrollY:!1,initialScrollX:!1,scrollingX:!0,scrollingY:!0,speed:300,easing:void 0,verticalNativeBarPos:"right",maxHeight:void 0,maxWidth:void 0},rail:{background:"#01a99a",opacity:0,border:"none",size:"6px",specifyBorderRadius:!1,gutterOfEnds:null,gutterOfSide:"2px",keepShow:!1},bar:{showDelay:500,specifyBorderRadius:!1,onlyShowBarOnScroll:!0,keepShow:!1,background:"rgb(3, 185, 118)",opacity:1,size:"6px",minSize:0,disable:!1},scrollButton:{enable:!1,background:"rgb(3, 185, 118)",opacity:1,step:180,mousedownStep:30}};var H=null,$=["mergedOptions.vuescroll.pullRefresh.tips","mergedOptions.vuescroll.pushLoad.tips","mergedOptions.vuescroll.scroller.disable","mergedOptions.rail","mergedOptions.bar"],M={vertical:{size:"height",opsSize:"width",posName:"top",opposName:"bottom",sidePosName:"right",page:"pageY",scroll:"scrollTop",scrollSize:"scrollHeight",offset:"offsetHeight",client:"clientY",axis:"Y",scrollButton:{start:"top",end:"bottom"}},horizontal:{size:"width",opsSize:"height",posName:"left",opposName:"right",sidePosName:"bottom",page:"pageX",scroll:"scrollLeft",scrollSize:"scrollWidth",offset:"offsetWidth",client:"clientX",axis:"X",scrollButton:{start:"left",end:"right"}}};function A(t){var o=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame,e=!!o;if(o&&!/requestAnimationFrame\(\)\s*\{\s*\[native code\]\s*\}/i.test(o.toString())&&(e=!1),e)return function(t,e){o(t,e)};var i={},r=1,n=null,s=+new Date;return function(t){var e=r++;return i[e]=t,null===n&&(n=setInterval(function(){var t=+new Date,e=i;for(var o in i={},e)e.hasOwnProperty(o)&&(e[o](t),s=t);2500<t-s&&(clearInterval(n),n=null)},1e3/60)),e}}var N={},I=/rgb\(/,L=/rgb\((.*)\)/;function V(t,e){var o=t+"&"+e;if(N[o])return N[o];var i=document.createElement("div");i.style.background=t,document.body.appendChild(i);var r=window.getComputedStyle(i).backgroundColor;return document.body.removeChild(i),I.test(r)?N[o]="rgba("+L.exec(r)[1]+", "+e+")":t}var X={name:"bar",props:{ops:Object,state:Object,hideBar:Boolean,otherBarHide:Boolean,type:String},computed:{bar:function(){return M[this.type]},barSize:function(){return Math.max(this.state.size,this.ops.bar.minSize)},barRatio:function(){return(1-this.barSize)/(1-this.state.size)}},render:function(t){var e,o,i,r=this,n=V(r.ops.rail.background,r.ops.rail.opacity);this.touchManager||(this.touchManager=new m);var s,a=r.ops.rail.size,l=r.otherBarHide?0:a,c=r.touchManager.getTouchObject(),u={class:"__rail-is-"+r.type,style:(e={position:"absolute","z-index":"1",borderRadius:r.ops.rail.specifyBorderRadius||a,background:n,border:r.ops.rail.border},b(e,r.bar.opsSize,a),b(e,r.bar.posName,r.ops.rail.gutterOfEnds||0),b(e,r.bar.opposName,r.ops.rail.gutterOfEnds||l),b(e,r.bar.sidePosName,r.ops.rail.gutterOfSide),e)};c&&(u.on=(b(s={},c.touchenter,function(){r.setRailHover()}),b(s,c.touchleave,function(){r.setRailLeave()}),s));var h=r.ops.scrollButton.enable?a:0,d={class:"__bar-wrap-is-"+r.type,style:(o={position:"absolute",borderRadius:r.ops.rail.specifyBorderRadius||a},b(o,r.bar.posName,h),b(o,r.bar.opposName,h),o),on:{}},p=r.state.posValue*r.state.size*r.barRatio/r.barSize,v=r.state.opacity;O(this).setClassHook("vertical"==this.type?"vBarVisible":"hBarVisible",!!v);var f={style:(b(i={cursor:"pointer",position:"absolute",margin:"auto",transition:"opacity 0.5s","user-select":"none","border-radius":"inherit"},r.bar.size,100*r.barSize+"%"),b(i,"background",r.ops.bar.background),b(i,r.bar.opsSize,r.ops.bar.size),b(i,"opacity",v),b(i,"transform","translate"+M[r.type].axis+"("+p+"%)"),i),class:"__bar-is-"+r.type,ref:"thumb",on:{}};"vertical"==r.type?(d.style.width="100%",f.style.left=0,f.style.right=0):(d.style.height="100%",f.style.top=0,f.style.bottom=0);var g=this.touchManager.getTouchObject();return f.on[g.touchstart]=this.createBarEvent(),d.on[g.touchstart]=this.createTrackEvent(),t("div",u,[this.createScrollbarButton(t,"start"),this.hideBar?null:t("div",d,[t("div",f)]),this.createScrollbarButton(t,"end")])},data:function(){return{isBarDragging:!1}},methods:{setRailHover:function(){var t=O(this),e=t.vuescroll.state;e.isRailHover||(e.isRailHover=!0,t.showBar())},setRailLeave:function(){var t=O(this);t.vuescroll.state.isRailHover=!1,t.hideBar()},setBarDrag:function(t){this.$emit("setBarDrag",this.isBarDragging=t),O(this).setClassHook("vertical"==this.type?"vBarDragging":"hBarDragging",!!t)},createBarEvent:function(){var n=this,s=O(n),o=n.touchManager.getTouchObject();function i(t){if(n.axisStartPos){var e=n.touchManager.getEventObject(t);if(e){e=e[0];var o=n.$refs.thumb.parentNode,i=e[n.bar.client]-o.getBoundingClientRect()[n.bar.posName],r=((i/=n.barRatio)-n.axisStartPos)/o[n.bar.offset];s.scrollTo(b({},n.bar.axis.toLowerCase(),s.scrollPanelElm[n.bar.scrollSize]*r),!1)}}}function r(){n.setBarDrag(!1),s.hideBar(),document.onselectstart=null,n.axisStartPos=0,y(document,o.touchmove,i,!1,"off"),y(document,o.touchend,r,!1,"off")}return function(t){var e=n.touchManager.getEventObject(t);e&&(t.stopImmediatePropagation(),t.preventDefault(),e=e[0],document.onselectstart=function(){return!1},n.axisStartPos=e[n.bar.client]-n.$refs.thumb.getBoundingClientRect()[n.bar.posName],n.setBarDrag(!0),y(document,o.touchmove,i),y(document,o.touchend,r))}},createTrackEvent:function(){var u=this;return function(t){var e=O(u),o=u.bar,i=o.client,r=o.offset,n=o.posName,s=o.axis,a=u.$refs.thumb;if(t.preventDefault(),t.stopImmediatePropagation(),a){var l=a[r],c=(u.touchManager.getEventObject(t)[0][i]-t.currentTarget.getBoundingClientRect()[n]-l/2)/(t.currentTarget[r]-l);e.scrollTo(b({},s.toLowerCase(),100*c+"%"))}}},createScrollbarButton:function(t,e){var o,i=this;if(!i.ops.scrollButton.enable)return null;var r=i.ops.rail.size,n=i.ops.scrollButton,s=n.opacity,a=V(n.background,s),l={class:["__bar-button","__bar-button-is-"+i.type+"-"+e],style:(b(o={},i.bar.scrollButton[e],0),b(o,"width",r),b(o,"height",r),b(o,"position","absolute"),b(o,"cursor","pointer"),b(o,"display","table"),o),ref:e},c={class:"__bar-button-inner",style:{border:"calc("+r+" / 2.5) solid transparent",width:"0",height:"0",margin:"auto",position:"absolute",top:"0",bottom:"0",right:"0",left:"0"},on:{}};"vertical"==i.type?"start"==e?(c.style["border-bottom-color"]=a,c.style.transform="translateY(-25%)"):(c.style["border-top-color"]=a,c.style.transform="translateY(25%)"):"start"==e?(c.style["border-right-color"]=a,c.style.transform="translateX(-25%)"):(c.style["border-left-color"]=a,c.style.transform="translateX(25%)");var u=this.touchManager.getTouchObject();return c.on[u.touchstart]=this.createScrollButtonEvent(e,u),t("div",l,[t("div",c)])},createScrollButtonEvent:function(o,i){var r=this,n=O(r),t=r.ops.scrollButton,e=t.step,s=t.mousedownStep,a="start"==o?-e:e,l="start"==o?-s:s,c=A(window),u=r.type,h=!1,d=!0,p=void 0;function v(){h&&!d&&(n.scrollBy(b({},"d"+r.bar.axis.toLowerCase(),l),!1),c(v,window))}function f(){if(clearTimeout(p),h=!1,y(document,i.touchend,f,!1,"off"),"mousedown"==i.touchstart){var t=r.$refs[o];y(t,"mouseenter",g,!1,"off"),y(t,"mouseleave",m,!1,"off")}n.setClassHook("cliking"+u+o+"Button",!1)}function g(){d=!1,v()}function m(){d=!0}return function(t){if(3!=t.which){if(n.setClassHook("cliking"+u+o+"Button",!0),t.stopImmediatePropagation(),t.preventDefault(),d=!1,n.scrollBy(b({},"d"+r.bar.axis.toLowerCase(),a)),y(document,i.touchend,f,!1),"mousedown"==i.touchstart){var e=r.$refs[o];y(e,"mouseenter",g,!1),y(e,"mouseleave",m,!1)}clearTimeout(p),p=setTimeout(function(){h=!0,c(v,window)},500)}}}}};function j(t,e){var o=M[e].axis,i=e.charAt(0)+"Bar",r=!t.bar[i].state.size||!t.mergedOptions.scrollPanel["scrolling"+o]||t.refreshLoad&&"vertical"!==e||t.mergedOptions.bar.disable,n=t.mergedOptions.rail.keepShow;return r&&!n?null:{hideBar:r,props:{type:e,ops:{bar:t.mergedOptions.bar,rail:t.mergedOptions.rail,scrollButton:t.mergedOptions.scrollButton},state:t.bar[i].state,hideBar:r},on:{setBarDrag:t.setBarDrag},ref:e+"Bar",key:e}}function _(t){var h=t.render,e=t.components,o=t.mixins;return{name:"vueScroll",props:{ops:{type:Object}},components:e,mixins:[R].concat(p([].concat(o))),created:function(){var e,o,t,i,r,n,s,a,l,c,u,h=this,d=v(this.$vuescrollConfig||{},{}),p=v(D,d);this.$options.propsData.ops=this.$options.propsData.ops||{},Object.keys(this.$options.propsData.ops).forEach(function(t){var e,o,i,r;e=h.mergedOptions,o=t,!(i=h.$options.propsData.ops)[o]&&"function"!=typeof i||(r=r||o,Object.defineProperty(e,o,{get:function(){return i[r]},configurable:!0}))}),v(p,this.mergedOptions),this._isVuescrollRoot=!0,this.renderError=(e=this.mergedOptions,o=!1,t=e.scrollPanel,i=e.bar,r=i.vBar,n=i.hBar,s=e.rail,a=s.vRail,l=s.hRail,c=t.initialScrollY,u=t.initialScrollX,c&&!String(c).match(/^\d+(\.\d+)?(%)?$/)&&w("The prop `initialScrollY` or `initialScrollX` should be a percent number like `10%` or an exact number that greater than or equal to 0 like `100`."),u&&!String(u).match(/^\d+(\.\d+)?(%)?$/)&&w("The prop `initialScrollY` or `initialScrollX` should be a percent number like `10%` or an exact number that greater than or equal to 0 like `100`."),(r||n||a||l)&&w("The options: vRail, hRail, vBar, hBar have been deprecated since v4.7.0,please use corresponing rail/bar instead!"),H&&(H=[].concat(H)).forEach(function(t){t(e)&&(o=!0)}),o)},render:function(t){var e=this;if(e.renderError)return t("div",[[e.$slots.default]]);e.touchManager||(e.touchManager=new m);var o,i={style:{height:e.vuescroll.state.height,width:e.vuescroll.state.width,padding:0,position:"relative",overflow:"hidden"},class:d({__vuescroll:!0},e.classHooks)},r=e.touchManager.getTouchObject();r&&(i.on=(b(o={},r.touchenter,function(){e.vuescroll.state.pointerLeave=!1,e.updateBarStateAndEmitEvent(),e.setClassHook("mouseEnter",!0)}),b(o,r.touchleave,function(){e.vuescroll.state.pointerLeave=!0,e.hideBar(),e.setClassHook("mouseEnter",!1)}),b(o,r.touchmove,function(){e.vuescroll.state.pointerLeave=!1,e.updateBarStateAndEmitEvent()}),o));var n,s,a,l,c=[h(t,e)].concat(p((n=t,a=j(s=e,"vertical"),l=j(s,"horizontal"),s.setClassHook("hasVBar",!(!a||a.hideBar)),s.setClassHook("hasHBar",!(!l||l.hideBar)),[a?n("bar",d({},a,{props:d({otherBarHide:!l},a.props)})):null,l?n("bar",d({},l,{props:d({otherBarHide:!a},l.props)})):null]))),u=this.$slots["scroll-container"];return u?P(t,u,c,i):t("div",i,[c])},mounted:function(){var t=this;this.renderError||(this.initVariables(),this.initWatchOpsChange(),this.refreshInternalStatus(),this.updatedCbs.push(function(){t.scrollToAnchor(),t.updateBarStateAndEmitEvent()}))},updated:function(){var e=this;this.updatedCbs.forEach(function(t){t.call(e)}),this.updatedCbs=[]},beforeDestroy:function(){this.destroy&&this.destroy()},computed:{scrollPanelElm:function(){return this.$refs.scrollPanel._isVue?this.$refs.scrollPanel.$el:this.$refs.scrollPanel}},data:function(){return{vuescroll:{state:{isDragging:!1,pointerLeave:!0,isRailHover:!1,height:"100%",width:"100%",currentSizeStrategy:"percent",currentScrollState:null,currentScrollInfo:null}},bar:{vBar:{state:{posValue:0,size:0,opacity:0}},hBar:{state:{posValue:0,size:0,opacity:0}}},mergedOptions:{vuescroll:{},scrollPanel:{},scrollContent:{},rail:{},bar:{}},updatedCbs:[],renderError:!1,classHooks:{hasVBar:!1,hasHBar:!1,vBarVisible:!1,hBarVisible:!1,vBarDragging:!1,hBarDragging:!1,clikingVerticalStartButton:!1,clikingVerticalEndButton:!1,clikingHorizontalStartButton:!1,clikingHorizontalEndButton:!1,mouseEnter:!1}}},methods:{scrollingComplete:function(){this.updateBarStateAndEmitEvent("handle-scroll-complete")},setBarDrag:function(t){this.vuescroll.state.isDragging=t},setClassHook:function(t,e){this.classHooks[t]=e},showAndDefferedHideBar:function(t){var e=this;this.showBar(),this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=0),this.timeoutId=setTimeout(function(){e.timeoutId=0,e.hideBar(t)},this.mergedOptions.bar.showDelay)},showBar:function(){var t=this.mergedOptions.bar.opacity;this.bar.vBar.state.opacity=t,this.bar.hBar.state.opacity=t},hideBar:function(t){var e=this.vuescroll.state,o=e.isDragging,i=e.isRailHover;o||i||(t&&!this.mergedOptions.bar.keepShow&&(this.bar.hBar.state.opacity=0,this.bar.vBar.state.opacity=0),this.mergedOptions.bar.keepShow||this.vuescroll.state.isDragging||(this.bar.vBar.state.opacity=0,this.bar.hBar.state.opacity=0))},useNumbericSize:function(){this.vuescroll.state.currentSizeStrategy="number";var t=this.mergedOptions.scrollPanel,e=t.maxHeight,o=t.maxWidth,i=this.$el.parentNode,r=i.clientHeight,n=i.clientWidth,s=this.scrollPanelElm,a=s.scrollHeight,l=s.scrollWidth,c=void 0,u=void 0;c=e||o?(u=a<=e?void 0:e,l<=o?void 0:o):(u=r,n),this.vuescroll.state.height=u?u+"px":void 0,this.vuescroll.state.width=c?c+"px":void 0},usePercentSize:function(){this.vuescroll.state.currentSizeStrategy="percent",this.vuescroll.state.height="100%",this.vuescroll.state.width="100%"},setVsSize:function(){var t=this.mergedOptions.vuescroll.sizeStrategy,e=this.mergedOptions.scrollPanel,o=e.maxHeight,i=e.maxWidth,r=this.scrollPanelElm,n=r.clientHeight,s=r.clientWidth;"number"==t||o&&o<n||i&&i<s?this.useNumbericSize():"percent"==t&&n!=o&&s!=i&&this.usePercentSize()},initWatchOpsChange:function(){var e=this,o={deep:!0,sync:!0};this.$watch("mergedOptions",function(){setTimeout(function(){if(e.isSmallChangeThisTick)return e.isSmallChangeThisTick=!1,void e.updateBarStateAndEmitEvent("options-change");e.refreshInternalStatus()},0)},o),$.forEach(function(t){e.$watch(t,function(){e.isSmallChangeThisTick=!0},o)})},scrollToAnchor:function(){var t=window.location.hash;if(t&&(!(t=t.slice(t.lastIndexOf("#")))||/^#[a-zA-Z_]\d*$/.test(t))){var e=document.querySelector(t);!S(e,this.$el)||this.mergedOptions.scrollPanel.initialScrollY||this.mergedOptions.scrollPanel.initialScrollX||this.scrollIntoView(e)}}}}}var W={name:"scrollPanel",props:{ops:{type:Object,required:!0}},methods:{updateInitialScroll:function(){var t=0,e=0,o=O(this);this.ops.initialScrollX&&(t=this.ops.initialScrollX),this.ops.initialScrollY&&(e=this.ops.initialScrollY),(t||e)&&o.scrollTo({x:t,y:e})}},mounted:function(){var t=this;setTimeout(function(){t._isDestroyed||t.updateInitialScroll()},0)},render:function(t){var e={class:["__panel"],style:{position:"relative",boxSizing:"border-box"}},o=O(this).$slots["scroll-panel"];return o?P(t,o,this.$slots.default,e):t("div",e,[[this.$slots.default]])}};function Y(e,o){return function(t){return o(e,t)}}function q(t,e){var o=null;return"easeInQuad"===t&&(o=e*e),"easeOutQuad"===t&&(o=e*(2-e)),"easeInOutQuad"===t&&(o=e<.5?2*e*e:(4-2*e)*e-1),"easeInCubic"===t&&(o=e*e*e),"easeOutCubic"===t&&(o=--e*e*e+1),"easeInOutCubic"===t&&(o=e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1),"easeInQuart"===t&&(o=e*e*e*e),"easeOutQuart"===t&&(o=1- --e*e*e*e),"easeInOutQuart"===t&&(o=e<.5?8*e*e*e*e:1-8*--e*e*e*e),"easeInQuint"===t&&(o=e*e*e*e*e),"easeOutQuint"===t&&(o=1+--e*e*e*e*e),"easeInOutQuint"===t&&(o=e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e),o||e}function Q(){return!0}var F=Date.now||function(){return(new Date).getTime()},U=(o(K,[{key:"pause",value:function(){this.isRunning&&(this.isPaused=!0)}},{key:"stop",value:function(){this.isStopped=!0}},{key:"continue",value:function(){this.isPaused&&(this.isPaused=!1,this.ts=F()-this.percent*this.spd,this.execScroll())}},{key:"startScroll",value:function(t,e,o,i,r,n,s){var a=3<arguments.length&&void 0!==i?i:Q,l=4<arguments.length&&void 0!==r?r:Q,c=5<arguments.length&&void 0!==n?n:Q,u=6<arguments.length&&void 0!==s?s:Q,h=e-t,d=0<h?-1:1,p=F();this.isRunning||this.init(),d!=this.dir||200<p-this.ts?(this.ts=p,this.dir=d,this.st=t,this.ed=e,this.df=h):this.df+=h,this.spd=o,this.completeCb=l,this.vertifyCb=c,this.stepCb=a,this.easingMethod=u,this.isRunning||this.execScroll()}},{key:"execScroll",value:function(){var o=this;if(this.df){var i=this.percent||0;this.percent=0,this.isRunning=!0,this.ref(function t(){if(o.isRunning&&o.vertifyCb(i)&&!o.isStopped){if(i=(F()-o.ts)/o.spd,o.isPaused)return o.percent=i,void(o.isRunning=!1);if(i<1){var e=o.st+o.df*o.easingMethod(i);o.stepCb(e),o.ref(t)}else o.stepCb(o.st+o.df),o.completeCb(),o.isRunning=!1}else o.isRunning=!1})}}},{key:"init",value:function(){this.st=0,this.ed=0,this.df=0,this.spd=0,this.ts=0,this.dir=0,this.ref=A(window),this.isPaused=!1,this.isStopped=!1}}]),K);function K(){e(this,K),this.init(),this.isRunning=!1}function Z(t){var e={ref:"scrollPanel",style:{height:"100%",overflowY:"scroll",overflowX:"scroll"},class:[],nativeOn:{"&scroll":t.handleScroll},props:{ops:t.mergedOptions.scrollPanel}};t.scrollYEnable=!0,t.scrollXEnable=!0,e.nativeOn.DOMMouseScroll=e.nativeOn.mousewheel=t.onMouseWheel;var o=t.mergedOptions.scrollPanel,i=o.scrollingY,r=o.scrollingX;t.bar.hBar.state.size&&r||(t.scrollXEnable=!1,e.style.overflowX="hidden"),t.bar.vBar.state.size&&i||(t.scrollYEnable=!1,e.style.overflowY="hidden");var n=function(){if(l())return 0;if(g=g||new c,void 0!==f)return f*g.getRatioBetweenPreAndCurrent();var t=document.createElement("div");t.style.visibility="hidden",t.style.width="100px",t.style.position="absolute",t.style.top="-9999px",document.body.appendChild(t);var e=t.offsetWidth;t.style.overflow="scroll";var o=document.createElement("div");o.style.width="100%",t.appendChild(o);var i=o.offsetWidth;return t.parentNode.removeChild(t),f=e-i,g=g||new c,f*g.getRatioBetweenPreAndCurrent()}();return n?(t.bar.vBar.state.size&&t.mergedOptions.scrollPanel.scrollingY&&("right"==t.mergedOptions.scrollPanel.verticalNativeBarPos?e.style.marginRight="-"+n+"px":e.style.marginLeft="-"+n+"px"),t.bar.hBar.state.size&&t.mergedOptions.scrollPanel.scrollingX&&(e.style.height="calc(100% + "+n+"px)")):(k(),e.class.push("__hidebar"),a()&&(e.style["-webkit-overflow-scrolling"]="touch")),e.style.transformOrigin="",e.style.transform="",e}function G(t,e){return function(t,e){if(t.hasResized)return;var o="display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; opacity: 0; z-index: -1000; pointer-events: none;",i=document.createElement("div");i.style.cssText=o;var r=document.createElement("object");r.style.cssText=o,r.type="text/html",r.tabIndex=-1,r.onload=function(){y(r.contentDocument.defaultView,"resize",e)},s()||(r.data="about:blank");i.isResizeElm=!0,i.appendChild(r),t.appendChild(i),s()&&(r.data="about:blank");return function(){r.contentDocument&&y(r.contentDocument.defaultView,"resize",e,"off"),t.removeChild(i),t.hasResized=!1}}(t,e)}var J=function(t,e,o,i){var r,n=2<arguments.length&&void 0!==o?o:[],s=3<arguments.length&&void 0!==i?i:[],a=(b(r={},W.name,W),b(r,X.name,X),r),l={};l.components=a,l.render=e,l.mixins=t;var c,u=_(l);return c=s,[].concat(n).forEach(function(t){v(t,D)}),H=c,u}({mixins:[{mounted:function(){this.scrollX=new U,this.scrollY=new U},methods:{nativeStop:function(){this.scrollX.stop(),this.scrollY.stop()},nativePause:function(){this.scrollX.pause(),this.scrollY.pause()},nativeContinue:function(){this.scrollX.continue(),this.scrollY.continue()},nativeScrollTo:function(t,e,o,i){!1===o||void 0===o&&(o=this.mergedOptions.scrollPanel.speed);var r=this.scrollPanelElm,n=r.scrollTop,s=r.scrollLeft,a=r.scrollWidth,l=r.clientWidth,c=r.scrollHeight,u=r.clientHeight;if(t=void 0===t?s:C(t,a-l),e=void 0===e?n:C(e,c-u),o){var h=Y(i=i||this.mergedOptions.scrollPanel.easing,q);t!=s&&this.scrollX.startScroll(s,t,o,function(t){r.scrollLeft=t},this.scrollingComplete.bind(this),void 0,h),e!=n&&this.scrollY.startScroll(n,e,o,function(t){r.scrollTop=t},this.scrollingComplete.bind(this),void 0,h)}else r.scrollTop=e,r.scrollLeft=t},getCurrentviewDomNative:function(){return function(t,e){for(var o,i,r,n,s,a,l,c,u,h,d=t.children,p=[],v=0;v<d.length;v++){var f=d.item(v);void 0,o=f.getBoundingClientRect(),i=o.left,r=o.top,n=o.width,s=o.height,a=e.getBoundingClientRect(),l=a.left,c=a.top,u=a.height,h=a.width,0<i-l+n&&i-l<h&&0<r-c+s&&r-c<u&&!f.isResizeElm&&p.push(f)}return p}(this.scrollContentElm,this.$el)}}},{methods:{updateNativeModeBarState:function(){var t=this.scrollPanelElm,e="percent"==this.vuescroll.state.currentSizeStrategy,o=this.vuescroll.state,i=o.width,r=o.height,n=e||!i?t.clientWidth:i.slice(0,-2),s=e||!r?t.clientHeight:r.slice(0,-2),a=s/t.scrollHeight,l=n/t.scrollWidth;this.bar.vBar.state.posValue=100*t.scrollTop/s,this.bar.hBar.state.posValue=100*t.scrollLeft/n,this.bar.vBar.state.size=a<1?a:0,this.bar.hBar.state.size=l<1?l:0},getNativePosition:function(){return{scrollTop:this.scrollPanelElm.scrollTop,scrollLeft:this.scrollPanelElm.scrollLeft}},css:function(t,e){return window.getComputedStyle(t)[e]},checkScrollable:function(t,e,o){for(var i=!1,r=t.target?t.target:t;r&&1==r.nodeType&&r!==this.scrollPanelElm.parentNode&&!/^BODY|HTML/.test(r.nodeName);){var n=this.css(r,"overflow")||"";if(/scroll|auto/.test(n)){var s=this.getScrollProcess(r),a=s.v,l=s.h,c="hidden"!==this.css(r,"overflowX"),u="hidden"!==this.css(r,"overflowY");if(c&&(e<0&&0<l||0<e&&l<1)||u&&(o<0&&0<a||0<o&&a<1)){i=r==this.scrollPanelElm;break}}r=!!r.parentNode&&r.parentNode}return i},onMouseWheel:function(t){var e=this.mergedOptions.vuescroll,o=e.wheelDirectionReverse,i=e.wheelScrollDuration,r=e.checkShiftKey,n=e.locking,s=e.deltaPercent,a=void 0,l=void 0;t.wheelDelta?t.deltaY||t.deltaX?(a=t.deltaX*s,l=t.deltaY*s,n&&(Math.abs(t.deltaX)>Math.abs(t.deltaY)?l=0:a=0)):(a=0,l=-1*t.wheelDelta/2):t.detail&&(l=a=16*t.detail,1==t.axis?l=0:2==t.axis&&(a=0)),r&&t.shiftKey&&(a^=l,a^=l^=a),o&&(a^=l,a^=l^=a),this.checkScrollable(t,a,l)&&(t.stopPropagation(),t.preventDefault(),this.scrollBy({dx:a,dy:l},i))}},computed:{scrollContentElm:function(){return this.$refs.scrollContent._isVue?this.$refs.scrollContent.$el:this.$refs.scrollContent}}}],methods:{destroy:function(){this.destroyResize&&this.destroyResize()},getCurrentviewDom:function(){return this.getCurrentviewDomNative()},internalScrollTo:function(t,e,o,i){this.nativeScrollTo(t,e,o,i)},internalStop:function(){this.nativeStop()},internalPause:function(){this.nativePause()},internalContinue:function(){this.nativeContinue()},handleScroll:function(t){this.updateBarStateAndEmitEvent("handle-scroll",t)},updateBarStateAndEmitEvent:function(t,e){var o=1<arguments.length&&void 0!==e?e:null;this.updateNativeModeBarState(),t&&this.emitEvent(t,o),this.mergedOptions.bar.onlyShowBarOnScroll?"handle-scroll"!=t&&"handle-resize"!=t&&"refresh-status"!=t&&"window-resize"!=t&&"options-change"!=t||this.showAndDefferedHideBar(!0):this.showAndDefferedHideBar()},getScrollProcess:function(t){var e=t||this.scrollPanelElm,o=e.scrollHeight,i=e.scrollWidth,r=e.clientHeight,n=e.clientWidth,s=e.scrollTop,a=e.scrollLeft;return{v:Math.min(s/(o-r||1),1),h:Math.min(a/(i-n||1),1)}},emitEvent:function(t,e){var o=1<arguments.length&&void 0!==e?e:null,i=this.scrollPanelElm,r=i.scrollTop,n=i.scrollLeft,s={type:"vertical"},a={type:"horizontal"},l=this.getScrollProcess(),c=l.v,u=l.h;s.process=c,a.process=u,s.barSize=this.bar.vBar.state.size,a.barSize=this.bar.hBar.state.size,s.scrollTop=r,a.scrollLeft=n,this.$emit(t,s,a,o)},initVariables:function(){this.$el._isVuescroll=!0},refreshInternalStatus:function(){this.setVsSize(),this.registryResize(),this.updateBarStateAndEmitEvent("refresh-status")},registryResize:function(){var e=this,t=this.mergedOptions.vuescroll.detectResize;if((!this.destroyResize||!t)&&(this.destroyResize&&this.destroyResize(),t)){var o=this.scrollContentElm,i=this,r=function(){i.updateBarStateAndEmitEvent("window-resize")};window.addEventListener("resize",r,!1);var n=G(o,function(){var t={};t.width=e.scrollPanelElm.scrollWidth,t.height=e.scrollPanelElm.scrollHeight,e.updateBarStateAndEmitEvent("handle-resize",t),e.setVsSize()});this.destroyResize=function(){window.removeEventListener("resize",r,!1),n(),e.destroyResize=null}}},getPosition:function(){return this.getNativePosition()}}},function(t,e){return t("scrollPanel",Z(e),[function(t,e){var o={position:"relative","box-sizing":"border-box","min-width":"100%","min-height":"100%"},i={style:o,ref:"scrollContent",class:"__view"},r=e.$slots["scroll-content"];e.mergedOptions.scrollPanel.scrollingX?o.width=B("width","fit-content"):i.style.width="100%";e.mergedOptions.scrollPanel.padding&&(i.style.paddingRight=e.mergedOptions.rail.size);if(r)return P(t,r,e.$slots.default,i);return t("div",i,[e.$slots.default])}(t,e)])},[{vuescroll:{wheelScrollDuration:0,wheelDirectionReverse:!1,checkShiftKey:!0,deltaPercent:1}}]);var tt=d({install:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};t.component(e.name||J.name,J),t.prototype.$vuescrollConfig=e.ops||{}},version:"4.18.1",refreshAll:function(){for(var t in T)T[t].refresh()},scrollTo:function(e,t,o){var i,r,n,s,a,l,c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:300,u=arguments[4],h=arguments[5],d=e.nodeType,p=new U,v=new U;if(d){9==d&&(e=e.scrollingElement);i=e.scrollLeft,r=e.scrollTop,n=e.scrollHeight,s=e.scrollWidth,a=e.clientWidth,l=e.clientHeight,t=void 0===t?i:C(t,s-a),o=void 0===o?r:C(o,n-l);var f=Y(u,q);p.startScroll(i,t,c,function(t){e.scrollLeft=t},h,void 0,f),v.startScroll(r,o,c,function(t){e.scrollTop=t},h,void 0,f)}else w("You must pass a dom for the first param, for window scrolling, you can pass document as the first param.")}},J);return"undefined"!=typeof window&&window.Vue&&window.Vue.use(tt),tt});
|