New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@better-scroll/scroll-bar

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@better-scroll/scroll-bar - npm Package Compare versions

Comparing version

to
2.0.3

46

dist/scroll-bar.esm.js

@@ -10,2 +10,25 @@ /*!

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
// ssr support

@@ -105,25 +128,2 @@ var inBrowser = typeof window !== 'undefined';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var EventEmitter = /** @class */ (function () {

@@ -130,0 +130,0 @@ function EventEmitter(names) {

@@ -16,2 +16,25 @@ /*!

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
// ssr support

@@ -111,25 +134,2 @@ var inBrowser = typeof window !== 'undefined';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var EventEmitter = /** @class */ (function () {

@@ -136,0 +136,0 @@ function EventEmitter(names) {

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ScrollBar=e()}(this,function(){"use strict";var i="undefined"!=typeof window,s=i&&navigator.userAgent.toLowerCase(),o=(s&&/wechatdevtools/.test(s),s&&s.indexOf("android"),function(){if("string"!=typeof s)return;var t=/os (\d\d?_\d(_\d)?)/.exec(s);if(!t)return;var e=t[1].split("_").map(function(t){return parseInt(t,10)});13<=e[0]&&e[1]}(),i&&document.createElement("div").style),e=function(){if(!i)return!1;for(var t=0,e=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];t<e.length;t++){var s=e[t];if(void 0!==o[s.value])return s.key}return!1}();function t(t){return!1===e?t:"standard"===e?"transitionEnd"===t?"transitionend":t:e+t.charAt(0).toUpperCase()+t.substr(1)}function r(t,e,s,i){t.addEventListener(e,s,{passive:!1,capture:!!i})}function n(t,e,s,i){t.removeEventListener(e,s,{capture:!!i})}e&&"standard"!==e&&e.toLowerCase();var a=t("transform"),h=(t("transition"),i&&t("perspective")in o,a),l=t("transitionTimingFunction"),p=t("transitionDuration");t("transitionDelay"),t("transformOrigin"),t("transitionEnd"),t("transitionProperty");var c=(d.prototype.on=function(t,e,s){return void 0===s&&(s=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,s]),this},d.prototype.once=function(s,i,o){var r=this;void 0===o&&(o=this),this.hasType(s);var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.off(s,n),i.apply(o,t)};return n.fn=i,this.on(s,n),this},d.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),!e)return this.events[t]=[],this;var s=this.events[t];if(!s)return this;for(var i=s.length;i--;)(s[i][0]===e||s[i][0]&&s[i][0].fn===e)&&s.splice(i,1);return this}},d.prototype.trigger=function(t){for(var e=[],s=1;s<arguments.length;s++)e[s-1]=arguments[s];this.hasType(t);var i=this.events[t];if(i)for(var o,r=i.length,n=function(){for(var t=0,e=0,s=arguments.length;e<s;e++)t+=arguments[e].length;for(var i=Array(t),o=0,e=0;e<s;e++)for(var r=arguments[e],n=0,a=r.length;n<a;n++,o++)i[o]=r[n];return i}(i),a=0;a<r;a++){var h=n[a],l=h[0],p=h[1];if(l&&!0===(o=l.apply(p,e)))return o}},d.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},d.prototype.destroy=function(){this.events={},this.eventTypes={}},d.prototype.hasType=function(t){var e,s=this.eventTypes;s[t]===t||(e='EventEmitter has used unknown event type: "'+t+'", should be oneof ['+Object.keys(s).map(function(t){return JSON.stringify(t)})+"]",console.error("[BScroll warn]: "+e))},d);function d(t){this.events={},this.eventTypes={},this.registerType(t)}var u=(v.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},v.prototype.addDOMEvents=function(){this.handleDOMEvents(r)},v.prototype.removeDOMEvents=function(){this.handleDOMEvents(n)},v.prototype.handleDOMEvents=function(e){var s=this,i=this.wrapper;this.events.forEach(function(t){e(i,t.name,s,!!t.capture)})},v.prototype.handleEvent=function(e){var s=e.type;this.events.some(function(t){return t.name===s&&(t.handler(e),!0)})},v);function v(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}var f=(y.prototype._start=function(t){var e,s;this.bscroll.scroller.actions.enabled&&(e=t.touches?t.touches[0]:t,t.preventDefault(),t.stopPropagation(),this.initiated=!0,this.moved=!1,this.lastPoint=e[this.indicator.keysMap.pointPos],s=this.bscroll.options.disableMouse,this.moveEventRegister=new u(window,[{name:s?"touchmove":"mousemove",handler:this._move.bind(this)}]),this.hooks.trigger("touchStart"))},y.prototype._move=function(t){var e=(t.touches?t.touches[0]:t)[this.indicator.keysMap.pointPos];t.preventDefault(),t.stopPropagation();var s=e-this.lastPoint;if(this.lastPoint=e,!this.moved)return this.hooks.trigger("touchMove",this.moved,s),void(this.moved=!0);this.hooks.trigger("touchMove",this.moved,s)},y.prototype._end=function(t){this.initiated&&(this.initiated=!1,t.preventDefault(),t.stopPropagation(),this.moveEventRegister.destroy(),this.hooks.trigger("touchEnd",this.moved))},y.prototype.destroy=function(){this.startEventRegister.destroy(),this.moveEventRegister&&this.moveEventRegister.destroy(),this.endEventRegister.destroy()},y);function y(t,e){this.indicator=t,this.options=e,this.bscroll=t.bscroll,this.startEventRegister=new u(this.indicator.el,[{name:e.disableMouse?"touchstart":"mousedown",handler:this._start.bind(this)}]),this.endEventRegister=new u(window,[{name:e.disableMouse?"touchend":"mouseup",handler:this._end.bind(this)}]),this.hooks=new c(["touchStart","touchMove","touchEnd"])}var m=(b.prototype._listenHooks=function(t,e){var s,i,o=this,r=this.bscroll,n=r,a=r.scroller.translater.hooks,h=r.scroller.animater.hooks;this._listen(n,"refresh",this.refresh),this._listen(a,"translate",this.updatePosAndSize),this._listen(h,"time",function(t){o.setTransitionTime(t)}),this._listen(h,"timeFunction",function(t){o.setTransitionTimingFunction(t)}),t&&(this._listen(n,"scrollEnd",function(){o.fade()}),this._listen(n,"scrollStart",function(){o.fade(!0)}),r.eventTypes.mousewheelStart&&r.eventTypes.mousewheelEnd&&(this._listen(n,"mousewheelStart",function(){o.fade(!0)}),this._listen(n,"mousewheelEnd",function(){o.fade()}))),e&&(s=this.bscroll.options.disableMouse,this.eventHandler=new f(this,{disableMouse:s}),i=this.eventHandler.hooks,this._listen(i,"touchStart",this.startHandler),this._listen(i,"touchMove",this.moveHandler),this._listen(i,"touchEnd",this.endHandler))},b.prototype._getKeysMap=function(){return"vertical"===this.direction?{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"}},b.prototype.fade=function(t){var e=t?250:500;this.wrapperStyle[p]=e+"ms",this.wrapperStyle.opacity=t?"1":"0",this.visible=t?1:0},b.prototype.refresh=function(){var t,e,s,i,o=this.keysMap.hasScroll;this._setShowBy(this.bscroll[o])&&(e=(t=this.keysMap).wrapperSize,s=t.scrollerSize,i=t.maxScroll,this.keyVals=this._refreshKeyValues(this.wrapper[e],this.bscroll[s],this.bscroll[i]),this.updatePosAndSize({x:this.bscroll.x,y:this.bscroll.y}))},b.prototype._setShowBy=function(t){return t?!(this.wrapper.style.display=""):!(this.wrapper.style.display="none")},b.prototype._refreshKeyValues=function(t,e,s){var i=Math.max(Math.round(t*t/(e||t||1)),8),o=t-i;return{initialSize:i,maxPos:o,sizeRatio:o/s}},b.prototype.updatePosAndSize=function(t){var e=this._refreshPosAndSizeValue(t,this.keyVals),s=e.pos,i=e.size;this.curPos=s,this._refreshPosAndSizeStyle(i,s)},b.prototype._refreshPosAndSizeValue=function(t,e){var s,i=this.keysMap.pos,o=e.sizeRatio,r=e.initialSize,n=e.maxPos,a=Math.round(o*t[i]);return a<0?(s=Math.max(r+3*a,8),a=0):n<a?a=n+r-(s=Math.max(r-3*(a-n),8)):s=r,{pos:a,size:s}},b.prototype._refreshPosAndSizeStyle=function(t,e){var s=this.keysMap,i=s.translate,o=s.size;this.elStyle[o]=t+"px",this.elStyle[h]=i+"("+e+"px)"+this.bscroll.options.translateZ},b.prototype.setTransitionTime=function(t){void 0===t&&(t=0),this.elStyle[p]=t+"ms"},b.prototype.setTransitionTimingFunction=function(t){this.elStyle[l]=t},b.prototype.startHandler=function(){this.setTransitionTime(),this.bscroll.trigger("beforeScrollStart")},b.prototype.moveHandler=function(t,e){t||this.bscroll.trigger("scrollStart");var s=this._calScrollDesPos(this.curPos,e,this.keyVals);"vertical"===this.direction?this.bscroll.scrollTo(this.bscroll.x,s):this.bscroll.scrollTo(s,this.bscroll.y),this.bscroll.trigger("scroll",{x:this.bscroll.x,y:this.bscroll.y})},b.prototype._calScrollDesPos=function(t,e,s){var i=s.maxPos,o=s.sizeRatio,r=t+e;return r<0?r=0:i<r&&(r=i),Math.round(r/o)},b.prototype.endHandler=function(t){t&&this.bscroll.trigger("scrollEnd",{x:this.bscroll.x,y:this.bscroll.y})},b.prototype.destroy=function(){this.options.interactive&&this.eventHandler.destroy(),this.wrapper.parentNode.removeChild(this.wrapper),this.hooksHandlers.forEach(function(t){var e=t[0],s=t[1],i=t[2];e.off(s,i)}),this.hooksHandlers.length=0},b.prototype._listen=function(t,e,s){t.on(e,s,this),this.hooksHandlers.push([t,e,s])},b);function b(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 g(t){this.indicators=[],this.indicators=this.createIndicators(t),t.on(t.eventTypes.destroy,this.destroy,this)}return g.prototype.createIndicators=function(s){var i,o=this,t=s.options.scrollbar,e=t.fade,r=void 0===e||e,n=t.interactive,a=void 0!==n&&n,h={scrollX:"horizontal",scrollY:"vertical"},l=[];return Object.keys(h).forEach(function(t){var e=h[t];s.options[t]&&(i={wrapper:o.createIndicatorElement(e),direction:e,fade:r,interactive:a},s.wrapper.appendChild(i.wrapper),l.push(new m(s,i)))}),l},g.prototype.createIndicatorElement=function(t){var e=document.createElement("div"),s=document.createElement("div");return e.style.cssText="position:absolute;z-index:9999;pointerEvents:none",s.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;",s.className="bscroll-indicator","horizontal"===t?(e.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",s.style.height="100%",e.className="bscroll-horizontal-scrollbar"):(e.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",s.style.width="100%",e.className="bscroll-vertical-scrollbar"),e.style.cssText+=";overflow:hidden",e.appendChild(s),e},g.prototype.destroy=function(){for(var t=0,e=this.indicators;t<e.length;t++){e[t].destroy()}},g.pluginName="scrollbar",g});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ScrollBar=e()}(this,function(){"use strict";var i="undefined"!=typeof window,s=i&&navigator.userAgent.toLowerCase(),o=(s&&/wechatdevtools/.test(s),s&&s.indexOf("android"),function(){if("string"!=typeof s)return;var t=/os (\d\d?_\d(_\d)?)/.exec(s);if(!t)return;var e=t[1].split("_").map(function(t){return parseInt(t,10)});13<=e[0]&&e[1]}(),i&&document.createElement("div").style),e=function(){if(!i)return!1;for(var t=0,e=[{key:"standard",value:"transform"},{key:"webkit",value:"webkitTransform"},{key:"Moz",value:"MozTransform"},{key:"O",value:"OTransform"},{key:"ms",value:"msTransform"}];t<e.length;t++){var s=e[t];if(void 0!==o[s.value])return s.key}return!1}();function t(t){return!1===e?t:"standard"===e?"transitionEnd"===t?"transitionend":t:e+t.charAt(0).toUpperCase()+t.substr(1)}function r(t,e,s,i){t.addEventListener(e,s,{passive:!1,capture:!!i})}function n(t,e,s,i){t.removeEventListener(e,s,{capture:!!i})}e&&"standard"!==e&&e.toLowerCase();var a=t("transform"),h=(t("transition"),i&&t("perspective")in o,a),l=t("transitionTimingFunction"),p=t("transitionDuration"),c=(t("transitionDelay"),t("transformOrigin"),t("transitionEnd"),t("transitionProperty"),d.prototype.on=function(t,e,s){return void 0===s&&(s=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,s]),this},d.prototype.once=function(s,i,o){var r=this;void 0===o&&(o=this),this.hasType(s);var n=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];r.off(s,n),i.apply(o,t)};return n.fn=i,this.on(s,n),this},d.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),!e)return this.events[t]=[],this;var s=this.events[t];if(!s)return this;for(var i=s.length;i--;)(s[i][0]===e||s[i][0]&&s[i][0].fn===e)&&s.splice(i,1);return this}},d.prototype.trigger=function(t){for(var e=[],s=1;s<arguments.length;s++)e[s-1]=arguments[s];this.hasType(t);var i=this.events[t];if(i)for(var o,r=i.length,n=function(){for(var t=0,e=0,s=arguments.length;e<s;e++)t+=arguments[e].length;for(var i=Array(t),o=0,e=0;e<s;e++)for(var r=arguments[e],n=0,a=r.length;n<a;n++,o++)i[o]=r[n];return i}(i),a=0;a<r;a++){var h=n[a],l=h[0],p=h[1];if(l&&!0===(o=l.apply(p,e)))return o}},d.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},d.prototype.destroy=function(){this.events={},this.eventTypes={}},d.prototype.hasType=function(t){var e,s=this.eventTypes;s[t]===t||(e='EventEmitter has used unknown event type: "'+t+'", should be oneof ['+Object.keys(s).map(function(t){return JSON.stringify(t)})+"]",console.error("[BScroll warn]: "+e))},d);function d(t){this.events={},this.eventTypes={},this.registerType(t)}var u=(v.prototype.destroy=function(){this.removeDOMEvents(),this.events=[]},v.prototype.addDOMEvents=function(){this.handleDOMEvents(r)},v.prototype.removeDOMEvents=function(){this.handleDOMEvents(n)},v.prototype.handleDOMEvents=function(e){var s=this,i=this.wrapper;this.events.forEach(function(t){e(i,t.name,s,!!t.capture)})},v.prototype.handleEvent=function(e){var s=e.type;this.events.some(function(t){return t.name===s&&(t.handler(e),!0)})},v);function v(t,e){this.wrapper=t,this.events=e,this.addDOMEvents()}var f=(y.prototype._start=function(t){var e,s;this.bscroll.scroller.actions.enabled&&(e=t.touches?t.touches[0]:t,t.preventDefault(),t.stopPropagation(),this.initiated=!0,this.moved=!1,this.lastPoint=e[this.indicator.keysMap.pointPos],s=this.bscroll.options.disableMouse,this.moveEventRegister=new u(window,[{name:s?"touchmove":"mousemove",handler:this._move.bind(this)}]),this.hooks.trigger("touchStart"))},y.prototype._move=function(t){var e=(t.touches?t.touches[0]:t)[this.indicator.keysMap.pointPos];t.preventDefault(),t.stopPropagation();var s=e-this.lastPoint;if(this.lastPoint=e,!this.moved)return this.hooks.trigger("touchMove",this.moved,s),void(this.moved=!0);this.hooks.trigger("touchMove",this.moved,s)},y.prototype._end=function(t){this.initiated&&(this.initiated=!1,t.preventDefault(),t.stopPropagation(),this.moveEventRegister.destroy(),this.hooks.trigger("touchEnd",this.moved))},y.prototype.destroy=function(){this.startEventRegister.destroy(),this.moveEventRegister&&this.moveEventRegister.destroy(),this.endEventRegister.destroy()},y);function y(t,e){this.indicator=t,this.options=e,this.bscroll=t.bscroll,this.startEventRegister=new u(this.indicator.el,[{name:e.disableMouse?"touchstart":"mousedown",handler:this._start.bind(this)}]),this.endEventRegister=new u(window,[{name:e.disableMouse?"touchend":"mouseup",handler:this._end.bind(this)}]),this.hooks=new c(["touchStart","touchMove","touchEnd"])}var m=(b.prototype._listenHooks=function(t,e){var s,i,o=this,r=this.bscroll,n=r,a=r.scroller.translater.hooks,h=r.scroller.animater.hooks;this._listen(n,"refresh",this.refresh),this._listen(a,"translate",this.updatePosAndSize),this._listen(h,"time",function(t){o.setTransitionTime(t)}),this._listen(h,"timeFunction",function(t){o.setTransitionTimingFunction(t)}),t&&(this._listen(n,"scrollEnd",function(){o.fade()}),this._listen(n,"scrollStart",function(){o.fade(!0)}),r.eventTypes.mousewheelStart&&r.eventTypes.mousewheelEnd&&(this._listen(n,"mousewheelStart",function(){o.fade(!0)}),this._listen(n,"mousewheelEnd",function(){o.fade()}))),e&&(s=this.bscroll.options.disableMouse,this.eventHandler=new f(this,{disableMouse:s}),i=this.eventHandler.hooks,this._listen(i,"touchStart",this.startHandler),this._listen(i,"touchMove",this.moveHandler),this._listen(i,"touchEnd",this.endHandler))},b.prototype._getKeysMap=function(){return"vertical"===this.direction?{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"}},b.prototype.fade=function(t){var e=t?250:500;this.wrapperStyle[p]=e+"ms",this.wrapperStyle.opacity=t?"1":"0",this.visible=t?1:0},b.prototype.refresh=function(){var t,e,s,i,o=this.keysMap.hasScroll;this._setShowBy(this.bscroll[o])&&(e=(t=this.keysMap).wrapperSize,s=t.scrollerSize,i=t.maxScroll,this.keyVals=this._refreshKeyValues(this.wrapper[e],this.bscroll[s],this.bscroll[i]),this.updatePosAndSize({x:this.bscroll.x,y:this.bscroll.y}))},b.prototype._setShowBy=function(t){return t?!(this.wrapper.style.display=""):!(this.wrapper.style.display="none")},b.prototype._refreshKeyValues=function(t,e,s){var i=Math.max(Math.round(t*t/(e||t||1)),8),o=t-i;return{initialSize:i,maxPos:o,sizeRatio:o/s}},b.prototype.updatePosAndSize=function(t){var e=this._refreshPosAndSizeValue(t,this.keyVals),s=e.pos,i=e.size;this.curPos=s,this._refreshPosAndSizeStyle(i,s)},b.prototype._refreshPosAndSizeValue=function(t,e){var s,i=this.keysMap.pos,o=e.sizeRatio,r=e.initialSize,n=e.maxPos,a=Math.round(o*t[i]);return a<0?(s=Math.max(r+3*a,8),a=0):n<a?a=n+r-(s=Math.max(r-3*(a-n),8)):s=r,{pos:a,size:s}},b.prototype._refreshPosAndSizeStyle=function(t,e){var s=this.keysMap,i=s.translate,o=s.size;this.elStyle[o]=t+"px",this.elStyle[h]=i+"("+e+"px)"+this.bscroll.options.translateZ},b.prototype.setTransitionTime=function(t){void 0===t&&(t=0),this.elStyle[p]=t+"ms"},b.prototype.setTransitionTimingFunction=function(t){this.elStyle[l]=t},b.prototype.startHandler=function(){this.setTransitionTime(),this.bscroll.trigger("beforeScrollStart")},b.prototype.moveHandler=function(t,e){t||this.bscroll.trigger("scrollStart");var s=this._calScrollDesPos(this.curPos,e,this.keyVals);"vertical"===this.direction?this.bscroll.scrollTo(this.bscroll.x,s):this.bscroll.scrollTo(s,this.bscroll.y),this.bscroll.trigger("scroll",{x:this.bscroll.x,y:this.bscroll.y})},b.prototype._calScrollDesPos=function(t,e,s){var i=s.maxPos,o=s.sizeRatio,r=t+e;return r<0?r=0:i<r&&(r=i),Math.round(r/o)},b.prototype.endHandler=function(t){t&&this.bscroll.trigger("scrollEnd",{x:this.bscroll.x,y:this.bscroll.y})},b.prototype.destroy=function(){this.options.interactive&&this.eventHandler.destroy(),this.wrapper.parentNode.removeChild(this.wrapper),this.hooksHandlers.forEach(function(t){var e=t[0],s=t[1],i=t[2];e.off(s,i)}),this.hooksHandlers.length=0},b.prototype._listen=function(t,e,s){t.on(e,s,this),this.hooksHandlers.push([t,e,s])},b);function b(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 g(t){this.indicators=[],this.indicators=this.createIndicators(t),t.on(t.eventTypes.destroy,this.destroy,this)}return g.prototype.createIndicators=function(s){var i,o=this,t=s.options.scrollbar,e=t.fade,r=void 0===e||e,n=t.interactive,a=void 0!==n&&n,h={scrollX:"horizontal",scrollY:"vertical"},l=[];return Object.keys(h).forEach(function(t){var e=h[t];s.options[t]&&(i={wrapper:o.createIndicatorElement(e),direction:e,fade:r,interactive:a},s.wrapper.appendChild(i.wrapper),l.push(new m(s,i)))}),l},g.prototype.createIndicatorElement=function(t){var e=document.createElement("div"),s=document.createElement("div");return e.style.cssText="position:absolute;z-index:9999;pointerEvents:none",s.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;",s.className="bscroll-indicator","horizontal"===t?(e.style.cssText+=";height:7px;left:2px;right:2px;bottom:0",s.style.height="100%",e.className="bscroll-horizontal-scrollbar"):(e.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px",s.style.width="100%",e.className="bscroll-vertical-scrollbar"),e.style.cssText+=";overflow:hidden",e.appendChild(s),e},g.prototype.destroy=function(){for(var t=0,e=this.indicators;t<e.length;t++){e[t].destroy()}},g.pluginName="scrollbar",g});
{
"name": "@better-scroll/scroll-bar",
"version": "2.0.2",
"version": "2.0.3",
"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.2"
"@better-scroll/core": "^2.0.3"
},
"gitHead": "ddaa875797f975b69e58bc66c65735e14b5a46a3"
"gitHead": "e8192135b353685a0f527afc197c21c77a86515c"
}