-
Notifications
You must be signed in to change notification settings - Fork 123
/
baron.min.js
1 lines (1 loc) · 14.3 KB
/
baron.min.js
1
!function(t){function e(r){if(i[r])return i[r].exports;var s=i[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var i={};e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,r){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=3)}([function(t,e,i){"use strict";function r(t,e){for(var i in t)t.hasOwnProperty(i)&&e(i,t[i])}var s=!1;try{var o=Object.defineProperty({},"passive",{get:function(){s=!0}});window.addEventListener("test",null,o)}catch(t){}t.exports.event=function(t,e,i,r){var o="on"==r?"add":"remove";e.split(" ").forEach(function(e){var r=!1;-1!=["scroll","touchstart","touchmove"].indexOf(e)&&s&&(r={passive:!0}),t[o+"EventListener"](e,i,r)})},t.exports.css=function(t,e,i){var s;if(void 0===i){if("string"==typeof e)return t.style[e];s=e}else s={},s[e]=i;r(s,function(e,i){t.style[e]=i})},t.exports.add=function(t,e){e&&t.classList.add(e)},t.exports.rm=function(t,e){e&&t.classList.remove(e)},t.exports.has=function(t,e){return!!e&&t.classList.contains(e)},t.exports.clone=function(t){var e={};return r(t||{},function(t,i){e[t]=i}),e},t.exports.qs=function(t,e){return t instanceof HTMLElement?t:(e||document).querySelector(t)},t.exports.each=r},function(t,e,i){"use strict";function r(t){var e,i,r=t&&t[0]||t,s="string"==typeof t||r instanceof HTMLElement,o=s?{root:t}:m(t),n={direction:"v",barOnCls:"_scrollbar",resizeDebounce:0,event:p,cssGuru:!1,impact:"scroller",position:"static"};o=o||{};for(var a in n)null==o[a]&&(o[a]=n[a]);e=this&&this instanceof u.jQuery,o._chain?i=o.root:e?o.root=i=this[0]:i=b(o.root||o.scroller);var h=l(i,o.direction),f=+h;if(o.index=f,f==f&&null!==h&&z[f])return z[f];o.root&&o.scroller?o.scroller=b(o.scroller,i):o.scroller=i,o.root=i;var d=c(o);return d.autoUpdate&&d.autoUpdate(),d}function s(t,e){var i=0,r=t;for(void 0!==r.length&&r!==u||(r=[r]);r[i];)e.call(this,r[i],i),i++}function o(){return(new Date).getTime()}function n(t,e,i){t._eventHandlers=t._eventHandlers||[{element:t.scroller,handler:function(e){t.scroll(e)},type:"scroll"},{element:t.root,handler:function(){t.update()},type:"transitionend animationend"},{element:t.scroller,handler:function(){t.update()},type:"keyup"},{element:t.bar,handler:function(e){e.preventDefault(),t.selection(),t.drag.now=1,t.draggingCls&&d(t.root,t.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){t.selection(1),t.drag.now=0,t.draggingCls&&g(t.root,t.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(e){2!=e.button&&t._pos0(e)},type:"touchstart mousedown"},{element:document,handler:function(e){t.drag.now&&t.drag(e)},type:"mousemove touchmove"},{element:u,handler:function(){t.update()},type:"resize"},{element:t.root,handler:function(){t.update()},type:"sizeChange"},{element:t.clipper,handler:function(){t.clipperOnScroll()},type:"scroll"}],s(t._eventHandlers,function(t){if(t.element)if(t.element.length&&t.element!==u)for(var r=0;r<t.element.length;r++)e(t.element[r],t.type,t.handler,i);else e(t.element,t.type,t.handler,i)})}function l(t,e,i,r){var s="data-baron-"+e+"-id";return"on"==i?t.setAttribute(s,r):"off"==i&&t.removeAttribute(s),t.getAttribute(s)}function c(t){var e=new r.prototype.constructor(t);return n(e,t.event,"on"),l(e.root,t.direction,"on",z.length),z.push(e),e.update(),e}function a(t){if(this.events&&this.events[t])for(var e=0;e<this.events[t].length;e++){var i=Array.prototype.slice.call(arguments,1);this.events[t][e].apply(this,i)}}var h=function(){return this||(0,eval)("this")}(),u=h&&h.window||h,p=i(0).event,f=i(0).css,d=i(0).add,v=i(0).has,g=i(0).rm,m=i(0).clone,b=i(0).qs,y=r,x=["left","top","right","bottom","width","height"],z=[],w={v:{x:"Y",pos:x[1],oppos:x[3],crossPos:x[0],crossOpPos:x[2],size:x[5],crossSize:x[4],crossMinSize:"min-"+x[4],crossMaxSize:"max-"+x[4],client:"clientHeight",crossClient:"clientWidth",scrollEdge:"scrollLeft",offset:"offsetHeight",crossOffset:"offsetWidth",offsetPos:"offsetTop",scroll:"scrollTop",scrollSize:"scrollHeight"},h:{x:"X",pos:x[0],oppos:x[2],crossPos:x[1],crossOpPos:x[3],size:x[4],crossSize:x[5],crossMinSize:"min-"+x[5],crossMaxSize:"max-"+x[5],client:"clientWidth",crossClient:"clientHeight",scrollEdge:"scrollTop",offset:"offsetWidth",crossOffset:"offsetHeight",offsetPos:"offsetLeft",scroll:"scrollLeft",scrollSize:"scrollWidth"}},C=15,S=/[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/,_=S.test(u.navigator&&u.navigator.userAgent);r.prototype={_debounce:function(t,e){var i,r,s=this,n=function(){if(s._disposed)return clearTimeout(i),void(i=s=null);var l=o()-r;l<e&&l>=0?i=setTimeout(n,e-l):(i=null,t())};return function(){r=o(),i||(i=setTimeout(n,e))}},constructor:function(t){function e(t){var e=this.barMinSize||20,i=t;i>0&&i<e&&(i=e),this.bar&&f(this.bar,this.origin.size,parseInt(i,10)+"px")}function i(t){if(this.bar){var e=f(this.bar,this.origin.pos),i=+t+"px";i&&i!=e&&f(this.bar,this.origin.pos,i)}}function r(){return p[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function s(t){return t*r.call(this)+this.barTopLimit}function n(t){return(t-this.barTopLimit)/r.call(this)}function l(){return!1}var c,h,p,m,y,x,z;if(x=o(),this.params=t,this.event=t.event,this.events={},this.root=t.root,this.scroller=b(t.scroller),this.bar=b(t.bar,this.root),p=this.track=b(t.track,this.root),!this.track&&this.bar&&(p=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=t.direction,this.rtl=t.rtl,this.origin=w[this.direction],this.barOnCls=t.barOnCls,this.scrollingCls=t.scrollingCls,this.draggingCls=t.draggingCls,this.impact=t.impact,this.position=t.position,this.rtl=t.rtl,this.barTopLimit=0,this.resizeDebounce=t.resizeDebounce,this.cursor=function(t){return t["client"+this.origin.x]||(((t.originalEvent||t).touches||{})[0]||{})["page"+this.origin.x]},this.pos=function(t){var e="page"+this.origin.x+"Offset",i=this.scroller[e]?e:this.origin.scroll;return void 0!==t&&(this.scroller[i]=t),this.scroller[i]},this.rpos=function(t){var e=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return(t?this.pos(t*e):this.pos())/(e||1)},this.barOn=function(t){if(this.barOnCls){var e=this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize];t||e?v(this.root,this.barOnCls)&&g(this.root,this.barOnCls):v(this.root,this.barOnCls)||d(this.root,this.barOnCls)}},this._pos0=function(t){h=this.cursor(t)-c},this.drag=function(t){var e=n.call(this,this.cursor(t)-h),i=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=e*i},this.selection=function(t){this.event(document,"selectpos selectstart",l,t?"off":"on")},this.resize=function(){function t(){var t,i,r=e.scroller[e.origin.crossOffset],s=e.scroller[e.origin.crossClient],n=0;if(_?n=C:s>0&&0===r&&(r=s+17),r)if(e.barOn(),"scroller"==e.impact){var l=r-s+n;if("static"==e.position)t=f(e.scroller,e.origin.crossSize),i=e.clipper[e.origin.crossClient]+l+"px",t!=i&&e._setCrossSizes(e.scroller,i);else{var c={},h=e.rtl?"Left":"Right";"h"==e.direction&&(h="Bottom"),c["padding"+h]=l+"px",f(e.scroller,c)}}else t=f(e.clipper,e.origin.crossSize),i=s+"px",t!=i&&e._setCrossSizes(e.clipper,i);Array.prototype.unshift.call(arguments,"resize"),a.apply(e,arguments),x=o()}var e=this,i=void 0===e.resizeDebounce?300:e.resizeDebounce,r=0;o()-x<i&&(clearTimeout(m),r=i),r?m=setTimeout(t,r):t()},this.updatePositions=function(t){var r,o=this;o.bar&&(r=(p[o.origin.client]-o.barTopLimit)*o.scroller[o.origin.client]/o.scroller[o.origin.scrollSize],(t||parseInt(z,10)!=parseInt(r,10))&&(e.call(o,r),z=r),c=s.call(o,o.rpos()),i.call(o,c)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(o,arguments)},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(y||d(t.root,t.scrollingCls),clearTimeout(y),y=setTimeout(function(){g(t.root,t.scrollingCls),y=void 0},300))},this.clipperOnScroll=function(){this.rtl?this.clipper[this.origin.scrollEdge]=this.clipper[this.origin.scrollSize]:this.clipper[this.origin.scrollEdge]=0},this._setCrossSizes=function(t,e){var i={};i[this.origin.crossSize]=e,i[this.origin.crossMinSize]=e,i[this.origin.crossMaxSize]=e,f(t,i)},this._dumbCss=function(e){if(!t.cssGuru){var i=e?"hidden":null,r=e?"none":null;f(this.clipper,{overflow:i,msOverflowStyle:r,position:"static"==this.position?"":"relative"});var s=e?"scroll":null,o="v"==this.direction?"y":"x",n={};n["overflow-"+o]=s,n["box-sizing"]="border-box",n.margin="0",n.border="0","absolute"==this.position&&(n.position="absolute",n.top="0","h"==this.direction?n.left=n.right="0":(n.bottom="0",n.right=this.rtl?"0":"",n.left=this.rtl?"":"0")),f(this.scroller,n)}},this._dumbCss(!0),_){var S="paddingRight",O={},T=u.getComputedStyle(this.scroller)[[S]];"h"==t.direction?S="paddingBottom":t.rtl&&(S="paddingLeft");var L=parseInt(T,10);L!=L&&(L=0),O[S]=C+L+"px",f(this.scroller,O)}return this},update:function(t){return a.call(this,"upd",t),this.resize(1),this.updatePositions(1),this},dispose:function(){n(this,this.event,"off"),l(this.root,this.params.direction,"off"),"v"==this.params.direction?this._setCrossSizes(this.scroller,""):this._setCrossSizes(this.clipper,""),this._dumbCss(!1),this.barOn(!0),a.call(this,"dispose"),z[this.params.index]=null,this.params=null,this._disposed=!0},on:function(t,e,i){for(var r=t.split(" "),s=0;s<r.length;s++)"init"==r[s]?e.call(this,i):(this.events[r[s]]=this.events[r[s]]||[],this.events[r[s]].push(function(t){e.call(this,t||i)}))},baron:function(t){return t.root=this.params.root,t.scroller=this.params.scroller,t.direction="v"==this.params.direction?"h":"v",t._chain=!0,r(t)}},r.prototype.constructor.prototype=r.prototype,r.noConflict=function(){return u.baron=y,r},r.version="3.0.1",r.prototype.autoUpdate=i(2)(u),r.prototype.fix=i(5),r.prototype.controls=i(4),t.exports=r},function(t,e,i){"use strict";function r(t){function e(){o.root[o.origin.offset]?r():i()}function i(){s||(s=setInterval(function(){o.root[o.origin.offset]&&(r(),o.update())},300))}function r(){clearInterval(s),s=null}var s,o=this;if(!this._au){var n=o._debounce(function(){o.update()},300);this._observer=new t(function(){e(),o.update(),n()}),this.on("init",function(){o._observer.observe(o.root,{childList:!0,subtree:!0,characterData:!0}),e()}),this.on("dispose",function(){o._observer.disconnect(),r(),delete o._observer}),this._au=!0}}t.exports=function(t){var e=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null;return function(){return e?(r.call(this,e),this):this}}},function(t,e,i){var r=i(1);window.baron=r,window.jQuery&&window.jQuery.fn&&(window.jQuery.fn.baron=r)},function(t,e,i){"use strict";var r=i(0).qs;t.exports=function(t){var e,i,s,o,n,l=this;o=t.screen||.9,t.forward&&(e=r(t.forward,this.clipper),n={element:e,handler:function(){var e=l.pos()+(t.delta||30);l.pos(e)},type:"click"},this._eventHandlers.push(n),this.event(n.element,n.type,n.handler,"on")),t.backward&&(i=r(t.backward,this.clipper),n={element:i,handler:function(){var e=l.pos()-(t.delta||30);l.pos(e)},type:"click"},this._eventHandlers.push(n),this.event(n.element,n.type,n.handler,"on")),t.track&&(s=!0===t.track?this.track:r(t.track,this.clipper))&&(n={element:s,handler:function(t){if(t.target==s){var e=t["offset"+l.origin.x],i=l.bar[l.origin.offsetPos],r=0;e<i?r=-1:e>i+l.bar[l.origin.offset]&&(r=1);var n=l.pos()+r*o*l.scroller[l.origin.client];l.pos(n)}},type:"mousedown"},this._eventHandlers.push(n),this.event(n.element,n.type,n.handler,"on"))}},function(t,e,i){"use strict";var r=(i(6),i(0).css),s=i(0).add,o=i(0).rm;t.exports=function(t){function e(t,e,i){var n=e,h=1==i?"pos":"oppos";c<(a.minView||0)&&(n=void 0),r(l[t],this.origin.pos,""),r(l[t],this.origin.oppos,""),o(l[t],a.outside),void 0!==n&&(n+="px",r(l[t],this.origin[h],n),s(l[t],a.outside))}function i(t){try{var e=document.createEvent("WheelEvent");e.initWebKitWheelEvent(t.originalEvent.wheelDeltaX,t.originalEvent.wheelDeltaY),f.dispatchEvent(e),t.preventDefault()}catch(t){}}function n(t){var e;for(var s in t)a[s]=t[s];if(a.elements instanceof HTMLElement?l=[a.elements]:"string"==typeof a.elements?l=this.scroller.querySelectorAll(a.elements):a.elements&&a.elements[0]instanceof HTMLElement&&(l=a.elements),l){c=this.scroller[this.origin.client];for(var o=0;o<l.length;o++)e={},e[this.origin.size]=l[o][this.origin.offset]+"px",l[o].parentNode!==this.scroller&&r(l[o].parentNode,e),e={},e[this.origin.crossSize]=l[o].parentNode[this.origin.crossClient]+"px",r(l[o],e),c-=l[o][this.origin.offset],p[o]=l[o].parentNode[this.origin.offsetPos],h[o]=h[o-1]||0,u[o]=u[o-1]||Math.min(p[o],0),l[o-1]&&(h[o]+=l[o-1][this.origin.offset],u[o]+=l[o-1][this.origin.offset]),0==o&&0==p[o]||(this.event(l[o],"mousewheel",i,"off"),this.event(l[o],"mousewheel",i));a.limiter&&l[0]&&(this.track&&this.track!=this.scroller?(e={},e[this.origin.pos]=l[0].parentNode[this.origin.offset]+"px",r(this.track,e)):this.barTopLimit=l[0].parentNode[this.origin.offset],this.scroll()),!1===a.limiter&&(this.barTopLimit=0)}var n={element:l,handler:function(){for(var t,e=this.parentNode,i=e.offsetTop,r=0;r<l.length;r++)l[r]===this&&(t=r);var s=i-h[t];a.scroll?a.scroll({x1:v.scroller.scrollTop,x2:s}):v.scroller.scrollTop=s},type:"click"};if(a.clickable){this._eventHandlers.push(n);for(var f=0;f<n.element.length;f++)d(n.element[f],n.type,n.handler,"on")}}var l,c,a={outside:"",inside:"",before:"",after:"",past:"",future:"",radius:0,minView:0},h=[],u=[],p=[],f=this.scroller,d=this.event,v=this;this.on("init",n,t);var g=[],m=[];return this.on("init scroll",function(){var t,i,r,n;if(l){var f;for(n=0;n<l.length;n++)t=0,p[n]-this.pos()<u[n]+a.radius?(t=1,i=h[n]):p[n]-this.pos()>u[n]+c-a.radius?(t=2,i=this.scroller[this.origin.client]-l[n][this.origin.offset]-h[n]-c):(t=3,i=void 0),r=!1,(p[n]-this.pos()<u[n]||p[n]-this.pos()>u[n]+c)&&(r=!0),t==g[n]&&r==m[n]||(e.call(this,n,i,t),g[n]=t,m[n]=r,f=!0);if(f)for(n=0;n<l.length;n++)1==g[n]&&a.past&&(s(l[n],a.past),o(l[n],a.future)),2==g[n]&&a.future&&(s(l[n],a.future),o(l[n],a.past)),3==g[n]&&(o(l[n],a.past),o(l[n],a.future),s(l[n],a.inside)),g[n]!=g[n+1]&&1==g[n]?(s(l[n],a.before),o(l[n],a.after)):g[n]!=g[n-1]&&2==g[n]?(s(l[n],a.after),o(l[n],a.before)):(o(l[n],a.before),o(l[n],a.after)),a.grad&&(m[n]?s(l[n],a.grad):o(l[n],a.grad))}}),this.on("resize upd",function(t){n.call(this,t&&t.fix)}),this}},function(t,e){t.exports=function(t,e,i){var r=console[t]||console.log,s=["Baron: "+e,i];Function.prototype.apply.call(r,console,s)}}]);