@better-scroll/scroll-bar
Advanced tools
Comparing version 2.0.0-alpha.15 to 2.0.0-alpha.16
@@ -272,7 +272,7 @@ /*! | ||
ret = fn.apply(context, args); | ||
if (ret === true) | ||
break; | ||
if (ret === true) { | ||
return ret; | ||
} | ||
} | ||
} | ||
return ret; | ||
}; | ||
@@ -633,7 +633,7 @@ EventEmitter.prototype.registerType = function (names) { | ||
'box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px;'; | ||
indicatorEl.className = 'this.bscroll-indicator'; | ||
indicatorEl.className = 'bscroll-indicator'; | ||
if (direction === 'horizontal') { | ||
scrollbarEl.style.cssText += ';height:7px;left:2px;right:2px;bottom:0'; | ||
indicatorEl.style.height = '100%'; | ||
scrollbarEl.className = 'this.bscroll-horizontal-scrollbar'; | ||
scrollbarEl.className = 'bscroll-horizontal-scrollbar'; | ||
} | ||
@@ -643,3 +643,3 @@ else { | ||
indicatorEl.style.width = '100%'; | ||
scrollbarEl.className = 'this.bscroll-vertical-scrollbar'; | ||
scrollbarEl.className = 'bscroll-vertical-scrollbar'; | ||
} | ||
@@ -646,0 +646,0 @@ scrollbarEl.style.cssText += ';overflow:hidden'; |
@@ -278,7 +278,7 @@ /*! | ||
ret = fn.apply(context, args); | ||
if (ret === true) | ||
break; | ||
if (ret === true) { | ||
return ret; | ||
} | ||
} | ||
} | ||
return ret; | ||
}; | ||
@@ -639,7 +639,7 @@ EventEmitter.prototype.registerType = function (names) { | ||
'box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px;'; | ||
indicatorEl.className = 'this.bscroll-indicator'; | ||
indicatorEl.className = 'bscroll-indicator'; | ||
if (direction === 'horizontal') { | ||
scrollbarEl.style.cssText += ';height:7px;left:2px;right:2px;bottom:0'; | ||
indicatorEl.style.height = '100%'; | ||
scrollbarEl.className = 'this.bscroll-horizontal-scrollbar'; | ||
scrollbarEl.className = 'bscroll-horizontal-scrollbar'; | ||
} | ||
@@ -649,3 +649,3 @@ else { | ||
indicatorEl.style.width = '100%'; | ||
scrollbarEl.className = 'this.bscroll-vertical-scrollbar'; | ||
scrollbarEl.className = 'bscroll-vertical-scrollbar'; | ||
} | ||
@@ -652,0 +652,0 @@ scrollbarEl.style.cssText += ';overflow:hidden'; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).ScrollBar=e()}(this,function(){"use strict";var f,t;(t=f||(f={})).Horizontal="horizontal",t.Vertical="vertical";var i="undefined"!=typeof window,e=i&&navigator.userAgent.toLowerCase(),s=(e&&/wechatdevtools/.test(e),e&&e.indexOf("android"),i&&document.createElement("div").style),o=function(){if(!i)return!1;var t={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(var e in t)if(void 0!==s[t[e]])return e;return!1}();function r(t){return!1===o?t:"standard"===o?"transitionEnd"===t?"transitionend":t:o+t.charAt(0).toUpperCase()+t.substr(1)}o&&"standard"!==o&&o.toLowerCase();var n=r("transform"),a=(r("transition"),i&&r("perspective"),n),h=r("transitionTimingFunction"),l=r("transitionDuration");r("transitionDelay"),r("transformOrigin"),r("transitionEnd");var c="undefined"!=typeof window,p=c&&navigator.userAgent.toLowerCase(),d=(p&&/wechatdevtools/.test(p),p&&p.indexOf("android"),c&&document.createElement("div").style),u=function(){if(!c)return!1;var t={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(var e in t)if(void 0!==d[t[e]])return e;return!1}();function v(t){return!1===u?t:"standard"===u?"transitionEnd"===t?"transitionend":t:u+t.charAt(0).toUpperCase()+t.substr(1)}function y(t,e,i,s){t.addEventListener(e,i,{passive:!1,capture:!!s})}function m(t,e,i,s){t.removeEventListener(e,i,{capture:!!s})}u&&"standard"!==u&&u.toLowerCase();var b=v("transform"),g=v("transition"),w=(c&&v("perspective"),v("transitionTimingFunction"),v("transitionDuration"),v("transitionDelay"),v("transformOrigin"),v("transitionEnd"),c&&window);function S(){}c&&(w.requestAnimationFrame||w.webkitRequestAnimationFrame||w.mozRequestAnimationFrame||w.oRequestAnimationFrame),c&&(w.cancelAnimationFrame||w.webkitCancelAnimationFrame||w.mozCancelAnimationFrame||w.oCancelAnimationFrame);var x=(_.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},_.prototype.addDOMEvents=function(){this.handleDOMEvents(y)},_.prototype.removeDOMEvents=function(){this.handleDOMEvents(m)},_.prototype.handleDOMEvents=function(e){var i=this,s=this.wrapper;this.events.forEach(function(t){e(s,t.name,i,!!t.capture)})},_.prototype.handleEvent=function(e){var i=e.type;this.events.some(function(t){return t.name===i&&(t.handler(e),!0)})},_);function _(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}var E=(T.prototype.on=function(t,e,i){return void 0===i&&(i=this),this._checkInTypes(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,i]),this},T.prototype.once=function(i,s,o){var r=this;void 0===o&&(o=this),this._checkInTypes(i);var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.off(i,n),s.apply(o,t)};return n.fn=s,this.on(i,n),this},T.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this._checkInTypes(t),!e)return this.events[t]=[],this;var i=this.events[t];if(!i)return this;for(var s=i.length;s--;)(i[s][0]===e||i[s][0]&&i[s][0].fn===e)&&i.splice(s,1);return this}},T.prototype.trigger=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];this._checkInTypes(t);var s=this.events[t];if(s){for(var o,r=s.length,n=s.slice(),a=0;a<r;a++){var h=n[a],l=h[0],c=h[1];if(l&&!0===(o=l.apply(c,e)))break}return o}},T.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},T.prototype.destroy=function(){this.events={},this.eventTypes={}},T.prototype._checkInTypes=function(t){var e=this.eventTypes;e[t]===t||function(t){console.error("[BScroll warn]: "+t)}('EventEmitter has used unknown event type: "'+t+'", should be oneof ['+Object.keys(e)+"]")},T);function T(t){this.events={},this.eventTypes={},this.registerType(t)}var k=(z.prototype._start=function(t){var e=t.touches?t.touches[0]:t;t.preventDefault(),t.stopPropagation(),this.initiated=!0,this.moved=!1,this.lastPoint=e[this.indicator.keysMap.pointPos];var i=this.bscroll.options.disableMouse;this.moveEventRegister=new x(window,[{name:i?"touchmove":"mousemove",handler:this._move.bind(this)}]),this.hooks.trigger("touchStart")},z.prototype._move=function(t){var e=(t.touches?t.touches[0]:t)[this.indicator.keysMap.pointPos];t.preventDefault(),t.stopPropagation();var i=e-this.lastPoint;if(this.lastPoint=e,!this.moved)return this.hooks.trigger("touchMove",this.moved,i),void(this.moved=!0);this.hooks.trigger("touchMove",this.moved,i)},z.prototype._end=function(t){this.initiated&&(this.initiated=!1,t.preventDefault(),t.stopPropagation(),this.moveEventRegister.destroy(),this.hooks.trigger("touchEnd",this.moved))},z.prototype.destroy=function(){this.startEventRegister.destroy(),this.moveEventRegister&&this.moveEventRegister.destroy(),this.endEventRegister.destroy()},z);function z(t,e){this.indicator=t,this.options=e,this.bscroll=t.bscroll,this.startEventRegister=new x(this.indicator.el,[{name:e.disableMouse?"touchstart":"mousedown",handler:this._start.bind(this)}]),this.endEventRegister=new x(window,[{name:e.disableMouse?"touchend":"mouseup",handler:this._end.bind(this)}]),this.hooks=new E(["touchStart","touchMove","touchEnd"])}var M=(P.prototype._listenHooks=function(t,e){var i=this,s=this.bscroll,o=s,r=s.scroller.translater.hooks,n=s.scroller.animater.hooks;if(this._listen(o,"refresh",this.refresh),this._listen(r,"translate",this.updatePosAndSize),this._listen(n,"time",function(t){i.setTransitionTime(t)}),this._listen(n,"timeFunction",function(t){i.setTransitionTimingFunction(t)}),t&&(this._listen(o,"scrollEnd",function(){i.fade()}),this._listen(o,"scrollStart",function(){i.fade(!0)}),s.eventTypes.mousewheelStart&&s.eventTypes.mousewheelEnd&&(this._listen(o,"mousewheelStart",function(){i.fade(!0)}),this._listen(o,"mousewheelEnd",function(){i.fade()}))),e){var a=this.bscroll.options.disableMouse;this.eventHandler=new k(this,{disableMouse:a});var h=this.eventHandler.hooks;this._listen(h,"touchStart",this.startHandler),this._listen(h,"touchMove",this.moveHandler),this._listen(h,"touchEnd",this.endHandler)}},P.prototype._getKeysMap=function(){return this.direction===f.Vertical?{hasScroll:"hasVerticalScroll",size:"height",wrapperSize:"clientHeight",scrollerSize:"scrollerHeight",maxScroll:"maxScrollY",pos:"y",pointPos:"pageY",translate:"translateY"}:{hasScroll:"hasHorizontalScroll",size:"width",wrapperSize:"clientWidth",scrollerSize:"scrollerWidth",maxScroll:"maxScrollX",pos:"x",pointPos:"pageX",translate:"translateX"}},P.prototype.fade=function(t){var e=t?250:500;this.wrapperStyle[l]=e+"ms",this.wrapperStyle.opacity=t?"1":"0",this.visible=t?1:0},P.prototype.refresh=function(){var t=this.keysMap.hasScroll;if(this._setShowBy(this.bscroll[t])){var e=this.keysMap,i=e.wrapperSize,s=e.scrollerSize,o=e.maxScroll;this.keyVals=this._refreshKeyValues(this.wrapper[i],this.bscroll[s],this.bscroll[o]),this.updatePosAndSize({x:this.bscroll.x,y:this.bscroll.y})}},P.prototype._setShowBy=function(t){return t?!(this.wrapper.style.display=""):!(this.wrapper.style.display="none")},P.prototype._refreshKeyValues=function(t,e,i){var s=Math.max(Math.round(t*t/(e||t||1)),8),o=t-s;return{initialSize:s,maxPos:o,sizeRatio:o/i}},P.prototype.updatePosAndSize=function(t){var e=this._refreshPosAndSizeValue(t,this.keyVals),i=e.pos,s=e.size;this.curPos=i,this._refreshPosAndSizeStyle(s,i)},P.prototype._refreshPosAndSizeValue=function(t,e){var i,s=this.keysMap.pos,o=e.sizeRatio,r=e.initialSize,n=e.maxPos,a=Math.round(o*t[s]);return a<0?(i=Math.max(r+3*a,8),a=0):n<a?a=n+r-(i=Math.max(r-3*(a-n),8)):i=r,{pos:a,size:i}},P.prototype._refreshPosAndSizeStyle=function(t,e){var i=this.keysMap,s=i.translate,o=i.size;this.elStyle[o]=t+"px",this.elStyle[a]=s+"("+e+"px)"+this.bscroll.options.translateZ},P.prototype.setTransitionTime=function(t){void 0===t&&(t=0),this.elStyle[l]=t+"ms"},P.prototype.setTransitionTimingFunction=function(t){this.elStyle[h]=t},P.prototype.startHandler=function(){this.setTransitionTime(),this.bscroll.trigger("beforeScrollStart")},P.prototype.moveHandler=function(t,e){t||this.bscroll.trigger("scrollStart");var i=this._calScrollDesPos(this.curPos,e,this.keyVals);this.direction===f.Vertical?this.bscroll.scrollTo(this.bscroll.x,i):this.bscroll.scrollTo(i,this.bscroll.y),this.bscroll.trigger("scroll",{x:this.bscroll.x,y:this.bscroll.y})},P.prototype._calScrollDesPos=function(t,e,i){var s=i.maxPos,o=i.sizeRatio,r=t+e;return r<0?r=0:s<r&&(r=s),Math.round(r/o)},P.prototype.endHandler=function(t){t&&this.bscroll.trigger("scrollEnd",{x:this.bscroll.x,y:this.bscroll.y})},P.prototype.destroy=function(){this.options.interactive&&this.eventHandler.destroy(),this.wrapper.parentNode.removeChild(this.wrapper),this.hooksHandlers.forEach(function(t){var e=t[0],i=t[1],s=t[2];e.off(i,s)}),this.hooksHandlers.length=0},P.prototype._listen=function(t,e,i){t.on(e,i,this),this.hooksHandlers.push([t,e,i])},P);function P(t,e){this.bscroll=t,this.options=e,this.keyVals={sizeRatio:1,maxPos:0,initialSize:0},this.curPos=0,this.hooksHandlers=[],this.wrapper=e.wrapper,this.wrapperStyle=this.wrapper.style,this.el=this.wrapper.children[0],this.elStyle=this.el.style,this.bscroll=t,this.direction=e.direction,this.keysMap=this._getKeysMap(),e.fade?(this.visible=0,this.wrapperStyle.opacity="0"):this.visible=1,this._listenHooks(e.fade,e.interactive),this.refresh()}function H(t){this.indicators=[],t.options.scrollbar&&(this.indicators=this._initIndicators(t),t.on("destroy",this.destroy,this))}return H.prototype._initIndicators=function(t){for(var e,i=t.options.scrollbar,s=i.fade,o=void 0===s||s,r=i.interactive,n=void 0!==r&&r,a={scrollX:f.Horizontal,scrollY:f.Vertical},h=[],l=0,c=Object.entries(a);l<c.length;l++){var p=c[l],d=p[0],u=p[1];t.options[d]&&(e={wrapper:this._createIndicatorElement(u),direction:u,fade:o,interactive:n},t.wrapper.appendChild(e.wrapper),h.push(new M(t,e)))}return h},H.prototype._createIndicatorElement=function(t){var e=document.createElement("div"),i=document.createElement("div");return e.style.cssText="position:absolute;z-index:9999;pointerEvents:none",i.style.cssText="box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px;",i.className="this.bscroll-indicator","horizontal"===t?(e.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",i.style.height="100%",e.className="this.bscroll-horizontal-scrollbar"):(e.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",i.style.width="100%",e.className="this.bscroll-vertical-scrollbar"),e.style.cssText+=";overflow:hidden",e.appendChild(i),e},H.prototype._insertIndicatorsTo=function(t){for(var e=0,i=this.indicators;e<i.length;e++){var s=i[e];t.wrapper.appendChild(s.wrapper)}},H.prototype.destroy=function(){for(var t=0,e=this.indicators;t<e.length;t++)e[t].destroy()},H.pluginName="scrollbar",H}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).ScrollBar=e()}(this,function(){"use strict";var f,t;(t=f||(f={})).Horizontal="horizontal",t.Vertical="vertical";var i="undefined"!=typeof window,e=i&&navigator.userAgent.toLowerCase(),s=(e&&/wechatdevtools/.test(e),e&&e.indexOf("android"),i&&document.createElement("div").style),o=function(){if(!i)return!1;var t={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(var e in t)if(void 0!==s[t[e]])return e;return!1}();function r(t){return!1===o?t:"standard"===o?"transitionEnd"===t?"transitionend":t:o+t.charAt(0).toUpperCase()+t.substr(1)}o&&"standard"!==o&&o.toLowerCase();var n=r("transform"),a=(r("transition"),i&&r("perspective"),n),h=r("transitionTimingFunction"),l=r("transitionDuration");r("transitionDelay"),r("transformOrigin"),r("transitionEnd");var c="undefined"!=typeof window,p=c&&navigator.userAgent.toLowerCase(),d=(p&&/wechatdevtools/.test(p),p&&p.indexOf("android"),c&&document.createElement("div").style),u=function(){if(!c)return!1;var t={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(var e in t)if(void 0!==d[t[e]])return e;return!1}();function v(t){return!1===u?t:"standard"===u?"transitionEnd"===t?"transitionend":t:u+t.charAt(0).toUpperCase()+t.substr(1)}function y(t,e,i,s){t.addEventListener(e,i,{passive:!1,capture:!!s})}function m(t,e,i,s){t.removeEventListener(e,i,{capture:!!s})}u&&"standard"!==u&&u.toLowerCase();var b=v("transform"),g=v("transition"),w=(c&&v("perspective"),v("transitionTimingFunction"),v("transitionDuration"),v("transitionDelay"),v("transformOrigin"),v("transitionEnd"),c&&window);function S(){}c&&(w.requestAnimationFrame||w.webkitRequestAnimationFrame||w.mozRequestAnimationFrame||w.oRequestAnimationFrame),c&&(w.cancelAnimationFrame||w.webkitCancelAnimationFrame||w.mozCancelAnimationFrame||w.oCancelAnimationFrame);var x=(_.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},_.prototype.addDOMEvents=function(){this.handleDOMEvents(y)},_.prototype.removeDOMEvents=function(){this.handleDOMEvents(m)},_.prototype.handleDOMEvents=function(e){var i=this,s=this.wrapper;this.events.forEach(function(t){e(s,t.name,i,!!t.capture)})},_.prototype.handleEvent=function(e){var i=e.type;this.events.some(function(t){return t.name===i&&(t.handler(e),!0)})},_);function _(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}var E=(T.prototype.on=function(t,e,i){return void 0===i&&(i=this),this._checkInTypes(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,i]),this},T.prototype.once=function(i,s,o){var r=this;void 0===o&&(o=this),this._checkInTypes(i);var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.off(i,n),s.apply(o,t)};return n.fn=s,this.on(i,n),this},T.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this._checkInTypes(t),!e)return this.events[t]=[],this;var i=this.events[t];if(!i)return this;for(var s=i.length;s--;)(i[s][0]===e||i[s][0]&&i[s][0].fn===e)&&i.splice(s,1);return this}},T.prototype.trigger=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];this._checkInTypes(t);var s=this.events[t];if(s)for(var o,r=s.length,n=s.slice(),a=0;a<r;a++){var h=n[a],l=h[0],c=h[1];if(l&&!0===(o=l.apply(c,e)))return o}},T.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},T.prototype.destroy=function(){this.events={},this.eventTypes={}},T.prototype._checkInTypes=function(t){var e=this.eventTypes;e[t]===t||function(t){console.error("[BScroll warn]: "+t)}('EventEmitter has used unknown event type: "'+t+'", should be oneof ['+Object.keys(e)+"]")},T);function T(t){this.events={},this.eventTypes={},this.registerType(t)}var k=(z.prototype._start=function(t){var e=t.touches?t.touches[0]:t;t.preventDefault(),t.stopPropagation(),this.initiated=!0,this.moved=!1,this.lastPoint=e[this.indicator.keysMap.pointPos];var i=this.bscroll.options.disableMouse;this.moveEventRegister=new x(window,[{name:i?"touchmove":"mousemove",handler:this._move.bind(this)}]),this.hooks.trigger("touchStart")},z.prototype._move=function(t){var e=(t.touches?t.touches[0]:t)[this.indicator.keysMap.pointPos];t.preventDefault(),t.stopPropagation();var i=e-this.lastPoint;if(this.lastPoint=e,!this.moved)return this.hooks.trigger("touchMove",this.moved,i),void(this.moved=!0);this.hooks.trigger("touchMove",this.moved,i)},z.prototype._end=function(t){this.initiated&&(this.initiated=!1,t.preventDefault(),t.stopPropagation(),this.moveEventRegister.destroy(),this.hooks.trigger("touchEnd",this.moved))},z.prototype.destroy=function(){this.startEventRegister.destroy(),this.moveEventRegister&&this.moveEventRegister.destroy(),this.endEventRegister.destroy()},z);function z(t,e){this.indicator=t,this.options=e,this.bscroll=t.bscroll,this.startEventRegister=new x(this.indicator.el,[{name:e.disableMouse?"touchstart":"mousedown",handler:this._start.bind(this)}]),this.endEventRegister=new x(window,[{name:e.disableMouse?"touchend":"mouseup",handler:this._end.bind(this)}]),this.hooks=new E(["touchStart","touchMove","touchEnd"])}var M=(P.prototype._listenHooks=function(t,e){var i=this,s=this.bscroll,o=s,r=s.scroller.translater.hooks,n=s.scroller.animater.hooks;if(this._listen(o,"refresh",this.refresh),this._listen(r,"translate",this.updatePosAndSize),this._listen(n,"time",function(t){i.setTransitionTime(t)}),this._listen(n,"timeFunction",function(t){i.setTransitionTimingFunction(t)}),t&&(this._listen(o,"scrollEnd",function(){i.fade()}),this._listen(o,"scrollStart",function(){i.fade(!0)}),s.eventTypes.mousewheelStart&&s.eventTypes.mousewheelEnd&&(this._listen(o,"mousewheelStart",function(){i.fade(!0)}),this._listen(o,"mousewheelEnd",function(){i.fade()}))),e){var a=this.bscroll.options.disableMouse;this.eventHandler=new k(this,{disableMouse:a});var h=this.eventHandler.hooks;this._listen(h,"touchStart",this.startHandler),this._listen(h,"touchMove",this.moveHandler),this._listen(h,"touchEnd",this.endHandler)}},P.prototype._getKeysMap=function(){return this.direction===f.Vertical?{hasScroll:"hasVerticalScroll",size:"height",wrapperSize:"clientHeight",scrollerSize:"scrollerHeight",maxScroll:"maxScrollY",pos:"y",pointPos:"pageY",translate:"translateY"}:{hasScroll:"hasHorizontalScroll",size:"width",wrapperSize:"clientWidth",scrollerSize:"scrollerWidth",maxScroll:"maxScrollX",pos:"x",pointPos:"pageX",translate:"translateX"}},P.prototype.fade=function(t){var e=t?250:500;this.wrapperStyle[l]=e+"ms",this.wrapperStyle.opacity=t?"1":"0",this.visible=t?1:0},P.prototype.refresh=function(){var t=this.keysMap.hasScroll;if(this._setShowBy(this.bscroll[t])){var e=this.keysMap,i=e.wrapperSize,s=e.scrollerSize,o=e.maxScroll;this.keyVals=this._refreshKeyValues(this.wrapper[i],this.bscroll[s],this.bscroll[o]),this.updatePosAndSize({x:this.bscroll.x,y:this.bscroll.y})}},P.prototype._setShowBy=function(t){return t?!(this.wrapper.style.display=""):!(this.wrapper.style.display="none")},P.prototype._refreshKeyValues=function(t,e,i){var s=Math.max(Math.round(t*t/(e||t||1)),8),o=t-s;return{initialSize:s,maxPos:o,sizeRatio:o/i}},P.prototype.updatePosAndSize=function(t){var e=this._refreshPosAndSizeValue(t,this.keyVals),i=e.pos,s=e.size;this.curPos=i,this._refreshPosAndSizeStyle(s,i)},P.prototype._refreshPosAndSizeValue=function(t,e){var i,s=this.keysMap.pos,o=e.sizeRatio,r=e.initialSize,n=e.maxPos,a=Math.round(o*t[s]);return a<0?(i=Math.max(r+3*a,8),a=0):n<a?a=n+r-(i=Math.max(r-3*(a-n),8)):i=r,{pos:a,size:i}},P.prototype._refreshPosAndSizeStyle=function(t,e){var i=this.keysMap,s=i.translate,o=i.size;this.elStyle[o]=t+"px",this.elStyle[a]=s+"("+e+"px)"+this.bscroll.options.translateZ},P.prototype.setTransitionTime=function(t){void 0===t&&(t=0),this.elStyle[l]=t+"ms"},P.prototype.setTransitionTimingFunction=function(t){this.elStyle[h]=t},P.prototype.startHandler=function(){this.setTransitionTime(),this.bscroll.trigger("beforeScrollStart")},P.prototype.moveHandler=function(t,e){t||this.bscroll.trigger("scrollStart");var i=this._calScrollDesPos(this.curPos,e,this.keyVals);this.direction===f.Vertical?this.bscroll.scrollTo(this.bscroll.x,i):this.bscroll.scrollTo(i,this.bscroll.y),this.bscroll.trigger("scroll",{x:this.bscroll.x,y:this.bscroll.y})},P.prototype._calScrollDesPos=function(t,e,i){var s=i.maxPos,o=i.sizeRatio,r=t+e;return r<0?r=0:s<r&&(r=s),Math.round(r/o)},P.prototype.endHandler=function(t){t&&this.bscroll.trigger("scrollEnd",{x:this.bscroll.x,y:this.bscroll.y})},P.prototype.destroy=function(){this.options.interactive&&this.eventHandler.destroy(),this.wrapper.parentNode.removeChild(this.wrapper),this.hooksHandlers.forEach(function(t){var e=t[0],i=t[1],s=t[2];e.off(i,s)}),this.hooksHandlers.length=0},P.prototype._listen=function(t,e,i){t.on(e,i,this),this.hooksHandlers.push([t,e,i])},P);function P(t,e){this.bscroll=t,this.options=e,this.keyVals={sizeRatio:1,maxPos:0,initialSize:0},this.curPos=0,this.hooksHandlers=[],this.wrapper=e.wrapper,this.wrapperStyle=this.wrapper.style,this.el=this.wrapper.children[0],this.elStyle=this.el.style,this.bscroll=t,this.direction=e.direction,this.keysMap=this._getKeysMap(),e.fade?(this.visible=0,this.wrapperStyle.opacity="0"):this.visible=1,this._listenHooks(e.fade,e.interactive),this.refresh()}function H(t){this.indicators=[],t.options.scrollbar&&(this.indicators=this._initIndicators(t),t.on("destroy",this.destroy,this))}return H.prototype._initIndicators=function(t){for(var e,i=t.options.scrollbar,s=i.fade,o=void 0===s||s,r=i.interactive,n=void 0!==r&&r,a={scrollX:f.Horizontal,scrollY:f.Vertical},h=[],l=0,c=Object.entries(a);l<c.length;l++){var p=c[l],d=p[0],u=p[1];t.options[d]&&(e={wrapper:this._createIndicatorElement(u),direction:u,fade:o,interactive:n},t.wrapper.appendChild(e.wrapper),h.push(new M(t,e)))}return h},H.prototype._createIndicatorElement=function(t){var e=document.createElement("div"),i=document.createElement("div");return e.style.cssText="position:absolute;z-index:9999;pointerEvents:none",i.style.cssText="box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px;",i.className="bscroll-indicator","horizontal"===t?(e.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",i.style.height="100%",e.className="bscroll-horizontal-scrollbar"):(e.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",i.style.width="100%",e.className="bscroll-vertical-scrollbar"),e.style.cssText+=";overflow:hidden",e.appendChild(i),e},H.prototype._insertIndicatorsTo=function(t){for(var e=0,i=this.indicators;e<i.length;e++){var s=i[e];t.wrapper.appendChild(s.wrapper)}},H.prototype.destroy=function(){for(var t=0,e=this.indicators;t<e.length;t++)e[t].destroy()},H.pluginName="scrollbar",H}); |
{ | ||
"name": "@better-scroll/scroll-bar", | ||
"version": "2.0.0-alpha.15", | ||
"version": "2.0.0-alpha.16", | ||
"description": "scrollbar is used to BetterScroll, which behaves like browser scrollbar", | ||
@@ -30,5 +30,5 @@ "author": "huangyi <ustbhuangyi@gmail.com>", | ||
"dependencies": { | ||
"@better-scroll/core": "^2.0.0-alpha.15" | ||
"@better-scroll/core": "^2.0.0-alpha.16" | ||
}, | ||
"gitHead": "92e3d0a6cab65a4ceab8d4de1a0f428f9b6f67d7" | ||
"gitHead": "32658eccb2b0358294eb400fbc46aa4a9311fdba" | ||
} |
@@ -67,3 +67,3 @@ import BScroll from '@better-scroll/core' | ||
indicatorEl.className = 'this.bscroll-indicator' | ||
indicatorEl.className = 'bscroll-indicator' | ||
@@ -73,7 +73,7 @@ if (direction === 'horizontal') { | ||
indicatorEl.style.height = '100%' | ||
scrollbarEl.className = 'this.bscroll-horizontal-scrollbar' | ||
scrollbarEl.className = 'bscroll-horizontal-scrollbar' | ||
} else { | ||
scrollbarEl.style.cssText += ';width:7px;bottom:2px;top:2px;right:1px' | ||
indicatorEl.style.width = '100%' | ||
scrollbarEl.className = 'this.bscroll-vertical-scrollbar' | ||
scrollbarEl.className = 'bscroll-vertical-scrollbar' | ||
} | ||
@@ -80,0 +80,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92133