Comparing version 2.0.2 to 2.1.0
18
baron.js
@@ -391,7 +391,2 @@ (function(window, undefined) { | ||
out.scrollEdge = 0; | ||
if (params.rtl) { | ||
out.scrollEdge = out.clipper[out.origin.scrollEdge]; // initial position | ||
} | ||
return out; | ||
@@ -515,2 +510,3 @@ } | ||
this.direction = params.direction; | ||
this.rtl = params.rtl; | ||
this.origin = origin[this.direction]; | ||
@@ -636,2 +632,3 @@ this.barOnCls = params.barOnCls || '_baron'; | ||
// also fires on init | ||
// Note: max/min-size didnt sets if size did not really changed (for example, on init in Chrome) | ||
this.resize = function() { | ||
@@ -750,6 +747,11 @@ var self = this; | ||
this.clipperOnScroll = function() { | ||
if (this.direction == 'h') return; | ||
// WTF is this line? https://github.com/Diokuz/baron/issues/134 | ||
// if (this.direction == 'h') return; | ||
// clipper.scrollLeft = initial scroll position (0 for ltr, 20 for rtl) | ||
this.clipper[this.origin.scrollEdge] = this.scrollEdge; | ||
// assign `initial scroll position` to `clipper.scrollLeft` (0 for ltr, ~20 for rtl) | ||
if (!this.rtl) { | ||
this.clipper[this.origin.scrollEdge] = 0; | ||
} else { | ||
this.clipper[this.origin.scrollEdge] = this.clipper[this.origin.scrollSize]; | ||
} | ||
}; | ||
@@ -756,0 +758,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,s){"use strict";function i(e){var r,o,n=!!e,l={$:t.jQuery,direction:"v",barOnCls:"_scrollbar",resizeDebounce:0,event:function(t,s,i,r){e.$(t)[r||"on"](s,i)},cssGuru:!1,impact:"scroller"};e=e||{};for(var c in l)e[c]===s&&(e[c]=l[c]);r=e.$&&this instanceof e.$,r?e.root=o=this:o=e.$?e.$(e.root||e.scroller):[];var a=new i.fn.constructor(o,e,n);return a.autoUpdate&&a.autoUpdate(),a}function e(i,e){var r=0;for((i.length===s||i===t)&&(i=[i]);i[r];)e.call(this,i[r],r),r++}function r(){return(new Date).getTime()}function o(s,i,r){s._eventHandlers=s._eventHandlers||[{element:s.scroller,handler:function(t){s.scroll(t)},type:"scroll"},{element:s.root,handler:function(){s.update()},type:"transitionend animationend"},{element:s.scroller,handler:function(){s.update()},type:"keyup"},{element:s.bar,handler:function(t){t.preventDefault(),s.selection(),s.drag.now=1,s.draggingCls&&h(s.root).addClass(s.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){s.selection(1),s.drag.now=0,s.draggingCls&&h(s.root).removeClass(s.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(t){2!=t.button&&s._pos0(t)},type:"touchstart mousedown"},{element:document,handler:function(t){s.drag.now&&s.drag(t)},type:"mousemove touchmove"},{element:t,handler:function(){s.update()},type:"resize"},{element:s.root,handler:function(){s.update()},type:"sizeChange"},{element:s.clipper,handler:function(){s.clipperOnScroll()},type:"scroll"}],e(s._eventHandlers,function(t){t.element&&i(t.element,t.type,t.handler,r)})}function n(t,s,i,e){var r="data-baron-"+s+"-id";if("on"==i)t.setAttribute(r,e);else{if("off"!=i)return t.getAttribute(r);t.removeAttribute(r)}}function l(t){var s=new C.prototype.constructor(t);return o(s,t.event,"on"),n(s.root,t.direction,"on",p.length),p.push(s),s.update(),s.scrollEdge=0,t.rtl&&(s.scrollEdge=s.clipper[s.origin.scrollEdge]),s}function c(t){var s={};t=t||{};for(var i in t)t.hasOwnProperty(i)&&(s[i]=t[i]);return s}function a(t){if(this.events&&this.events[t])for(var s=0;s<this.events[t].length;s++){var i=Array.prototype.slice.call(arguments,1);this.events[t][s].apply(this,i)}}if(t){var h=t.$,u=i,f=["left","top","right","bottom","width","height"],p=[],d={v:{x:"Y",pos:f[1],oppos:f[3],crossPos:f[0],crossOpPos:f[2],size:f[5],crossSize:f[4],crossMinSize:"min-"+f[4],crossMaxSize:"max-"+f[4],client:"clientHeight",crossClient:"clientWidth",scrollEdge:"scrollLeft",offset:"offsetHeight",crossOffset:"offsetWidth",offsetPos:"offsetTop",scroll:"scrollTop",scrollSize:"scrollHeight"},h:{x:"X",pos:f[0],oppos:f[2],crossPos:f[1],crossOpPos:f[3],size:f[4],crossSize:f[5],crossMinSize:"min-"+f[5],crossMaxSize:"max-"+f[5],client:"clientWidth",crossClient:"clientHeight",scrollEdge:"scrollTop",offset:"offsetWidth",crossOffset:"offsetHeight",offsetPos:"offsetLeft",scroll:"scrollLeft",scrollSize:"scrollWidth"}},g=17,v=15,m=/[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/,b=m.test(t.navigator.userAgent);i.fn={constructor:function(t,i,r){var o=c(i);o.event=function(t,s,r,o){e(t,function(t){i.event(t,s,r,o)})},this.length=0,e.call(this,t,function(t,i){var e=n(t,o.direction),r=+e;if(r==r&&e!=s&&p[r])this[i]=p[r];else{var a=c(o);if(o.root&&o.scroller){if(a.scroller=o.$(o.scroller,t),!a.scroller.length)return console.log("Scroller not found!",t,o.scroller),s}else a.scroller=t;a.root=t,this[i]=l(a)}this.length=i+1}),this.params=o},dispose:function(){var t=this.params;e(this,function(s,i){s.dispose(t),p[i]=null}),this.params=null},update:function(){var t=arguments;e(this,function(s,i){s.update.apply(s,t)})},baron:function(t){return t.root=[],t.scroller=this.params.scroller,e.call(this,this,function(s){t.root.push(s.root)}),t.direction="v"==this.params.direction?"h":"v",t._chain=!0,i(t)}};var C={};C.prototype={_debounce:function(t,i){var e,o,n=this,l=function(){if(n._disposed)return clearTimeout(e),e=n=null,s;var c=r()-o;i>c&&c>=0?e=setTimeout(l,i-c):(e=null,t())};return function(){o=r(),e||(e=setTimeout(l,i))}},constructor:function(i){function e(t,s){return f(t,s)[0]}function o(t){var s=this.barMinSize||20;t>0&&s>t&&(t=s),this.bar&&f(this.bar).css(this.origin.size,parseInt(t,10)+"px")}function n(t){if(this.bar){var s=f(this.bar).css(this.origin.pos),i=+t+"px";i&&i!=s&&f(this.bar).css(this.origin.pos,i)}}function l(){return C[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function c(t){return t*l.call(this)+this.barTopLimit}function h(t){return(t-this.barTopLimit)/l.call(this)}function u(){return!1}var f,p,m,C,y,z,$,w,S;if(w=$=r(),f=this.$=i.$,this.event=i.event,this.events={},this.root=i.root,this.scroller=e(i.scroller),this.bar=e(i.bar,this.root),C=this.track=e(i.track,this.root),!this.track&&this.bar&&(C=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=i.direction,this.origin=d[this.direction],this.barOnCls=i.barOnCls||"_baron",this.scrollingCls=i.scrollingCls,this.draggingCls=i.draggingCls,this.impact=i.impact,this.barTopLimit=0,this.resizeDebounce=i.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 i="page"+this.origin.x+"Offset",e=this.scroller[i]?i:this.origin.scroll;return t!==s&&(this.scroller[e]=t),this.scroller[e]},this.rpos=function(t){var s,i=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return s=t?this.pos(t*i):this.pos(),s/(i||1)},this.barOn=function(t){this.barOnCls&&(t||this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize]?f(this.root).hasClass(this.barOnCls)&&f(this.root).removeClass(this.barOnCls):f(this.root).hasClass(this.barOnCls)||f(this.root).addClass(this.barOnCls))},this._pos0=function(t){m=this.cursor(t)-p},this.drag=function(t){var s=h.call(this,this.cursor(t)-m),i=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=s*i},this.selection=function(t){this.event(document,"selectpos selectstart",u,t?"off":"on")},this.resize=function(){function t(){var t,s,e=i.scroller[i.origin.crossOffset],o=i.scroller[i.origin.crossClient],n=0;if(b?n=v:o>0&&0===e&&(e=o+g),e)if(i.barOn(),o=i.scroller[i.origin.crossClient],"scroller"==i.impact){var l=e-o+n;t=f(i.scroller).css(i.origin.crossSize),s=i.clipper[i.origin.crossClient]+l+"px",t!=s&&i._setCrossSizes(i.scroller,s)}else t=f(i.clipper).css(i.origin.crossSize),s=o+"px",t!=s&&i._setCrossSizes(i.clipper,s);Array.prototype.unshift.call(arguments,"resize"),a.apply(i,arguments),w=r()}var i=this,e=i.resizeDebounce===s?300:i.resizeDebounce,o=0;r()-w<e&&(clearTimeout(y),o=e),o?y=setTimeout(t,o):t()},this.updatePositions=function(){var t,s=this;s.bar&&(t=(C[s.origin.client]-s.barTopLimit)*s.scroller[s.origin.client]/s.scroller[s.origin.scrollSize],parseInt(S,10)!=parseInt(t,10)&&(o.call(s,t),S=t),p=c.call(s,s.rpos()),n.call(s,p)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(s,arguments),$=r()},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(z||t.$(t.root).addClass(t.scrollingCls),clearTimeout(z),z=setTimeout(function(){t.$(t.root).removeClass(t.scrollingCls),z=s},300))},this.clipperOnScroll=function(){"h"!=this.direction&&(this.clipper[this.origin.scrollEdge]=this.scrollEdge)},this._setCrossSizes=function(t,s){var i={};i[this.origin.crossSize]=s,i[this.origin.crossMinSize]=s,i[this.origin.crossMaxSize]=s,this.$(t).css(i)},this._dumbCss=function(t){if(!i.cssGuru){var s=t?"hidden":null,e=t?"none":null;this.$(this.clipper).css({overflow:s,msOverflowStyle:e});var r=t?"scroll":null,o="v"==this.direction?"y":"x",n={};n["overflow-"+o]=r,n["box-sizing"]="border-box",n.margin="0",n.border="0",this.$(this.scroller).css(n)}},this._dumbCss(!0),b){var _="paddingRight",x={},O=t.getComputedStyle(this.scroller)[[_]];this.scroller[this.origin.crossOffset]-this.scroller[this.origin.crossClient];"h"==i.direction?_="paddingBottom":i.rtl&&(_="paddingLeft");var T=parseInt(O,10);T!=T&&(T=0),x[_]=v+T+"px",f(this.scroller).css(x)}return this},update:function(t){return a.call(this,"upd",t),this.resize(1),this.updatePositions(),this},dispose:function(t){o(this,this.event,"off"),n(this.root,t.direction,"off"),"v"==t.direction?this._setCrossSizes(this.scroller,""):this._setCrossSizes(this.clipper,""),this._dumbCss(!1),this.barOn(!0),a.call(this,"dispose"),this._disposed=!0},on:function(t,s,i){for(var e=t.split(" "),r=0;r<e.length;r++)"init"==e[r]?s.call(this,i):(this.events[e[r]]=this.events[e[r]]||[],this.events[e[r]].push(function(t){s.call(this,t||i)}))}},i.fn.constructor.prototype=i.fn,C.prototype.constructor.prototype=C.prototype,i.noConflict=function(){return t.baron=u,i},i.version="2.0.1",h&&h.fn&&(h.fn.baron=i),t.baron=i,"undefined"!=typeof module&&(module.exports=i.noConflict())}}(window),function(t,s){var e=function(t){function e(t,i,e){var r=1==e?"pos":"oppos";l<(c.minView||0)&&(i=s),this.$(n[t]).css(this.origin.pos,"").css(this.origin.oppos,"").removeClass(c.outside),i!==s&&(i+="px",this.$(n[t]).css(this.origin[r],i).addClass(c.outside))}function r(t){try{i=document.createEvent("WheelEvent"),i.initWebKitWheelEvent(t.originalEvent.wheelDeltaX,t.originalEvent.wheelDeltaY),f.dispatchEvent(i),t.preventDefault()}catch(t){}}function o(t){var s;for(var i in t)c[i]=t[i];if(n=this.$(c.elements,this.scroller)){l=this.scroller[this.origin.client];for(var e=0;e<n.length;e++)s={},s[this.origin.size]=n[e][this.origin.offset],n[e].parentNode!==this.scroller&&this.$(n[e].parentNode).css(s),s={},s[this.origin.crossSize]=n[e].parentNode[this.origin.crossClient],this.$(n[e]).css(s),l-=n[e][this.origin.offset],u[e]=n[e].parentNode[this.origin.offsetPos],a[e]=a[e-1]||0,h[e]=h[e-1]||Math.min(u[e],0),n[e-1]&&(a[e]+=n[e-1][this.origin.offset],h[e]+=n[e-1][this.origin.offset]),(0!=e||0!=u[e])&&(this.event(n[e],"mousewheel",r,"off"),this.event(n[e],"mousewheel",r));c.limiter&&n[0]&&(this.track&&this.track!=this.scroller?(s={},s[this.origin.pos]=n[0].parentNode[this.origin.offset],this.$(this.track).css(s)):this.barTopLimit=n[0].parentNode[this.origin.offset],this.scroll()),c.limiter===!1&&(this.barTopLimit=0)}var o={element:n,handler:function(){for(var t,s=d(this)[0].parentNode,i=s.offsetTop,e=0;e<n.length;e++)n[e]===this&&(t=e);var r=i-a[t];c.scroll?c.scroll({x1:g.scroller.scrollTop,x2:r}):g.scroller.scrollTop=r},type:"click"};c.clickable&&(this._eventHandlers.push(o),p(o.element,o.type,o.handler,"on"))}var n,l,c={outside:"",inside:"",before:"",after:"",past:"",future:"",radius:0,minView:0},a=[],h=[],u=[],f=this.scroller,p=this.event,d=this.$,g=this;this.on("init",o,t);var v=[],m=[];this.on("init scroll",function(){var t,i,r;if(n){for(var o,f=0;f<n.length;f++)t=0,u[f]-this.pos()<h[f]+c.radius?(t=1,i=a[f]):u[f]-this.pos()>h[f]+l-c.radius?(t=2,i=this.scroller[this.origin.client]-n[f][this.origin.offset]-a[f]-l):(t=3,i=s),r=!1,(u[f]-this.pos()<h[f]||u[f]-this.pos()>h[f]+l)&&(r=!0),(t!=v[f]||r!=m[f])&&(e.call(this,f,i,t),v[f]=t,m[f]=r,o=!0);if(o)for(f=0;f<n.length;f++)1==v[f]&&c.past&&this.$(n[f]).addClass(c.past).removeClass(c.future),2==v[f]&&c.future&&this.$(n[f]).addClass(c.future).removeClass(c.past),3==v[f]?((c.future||c.past)&&this.$(n[f]).removeClass(c.past).removeClass(c.future),c.inside&&this.$(n[f]).addClass(c.inside)):c.inside&&this.$(n[f]).removeClass(c.inside),v[f]!=v[f+1]&&1==v[f]&&c.before?this.$(n[f]).addClass(c.before).removeClass(c.after):v[f]!=v[f-1]&&2==v[f]&&c.after?this.$(n[f]).addClass(c.after).removeClass(c.before):this.$(n[f]).removeClass(c.before).removeClass(c.after),c.grad&&(m[f]?this.$(n[f]).addClass(c.grad):this.$(n[f]).removeClass(c.grad))}}),this.on("resize upd",function(t){o.call(this,t&&t.fix)})};baron.fn.fix=function(t){for(var s=0;this[s];)e.call(this[s],t),s++;return this}}(window),function(t){var s=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null,i=function(){function t(){o.root[o.origin.offset]?e():i()}function i(){r||(r=setInterval(function(){o.root[o.origin.offset]&&(e(),o.update())},300))}function e(){clearInterval(r),r=null}var r,o=this;if(!this._au){var n=o._debounce(function(){o.update()},300);this._observer=new s(function(){t(),o.update(),n()}),this.on("init",function(){o._observer.observe(o.root,{childList:!0,subtree:!0,characterData:!0}),t()}),this.on("dispose",function(){o._observer.disconnect(),e(),delete o._observer}),this._au=!0}};baron.fn.autoUpdate=function(t){if(!s)return this;for(var e=0;this[e];)i.call(this[e],t),e++;return this}}(window),function(t,s){var i=function(t){var s,i,e,r,o,n=this;r=t.screen||.9,t.forward&&(s=this.$(t.forward,this.clipper),o={element:s,handler:function(){var s=n.pos()+(t.delta||30);n.pos(s)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.backward&&(i=this.$(t.backward,this.clipper),o={element:i,handler:function(){var s=n.pos()-(t.delta||30);n.pos(s)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.track&&(e=t.track===!0?this.track:this.$(t.track,this.clipper)[0],e&&(o={element:e,handler:function(t){if(t.target==e){var s=t["offset"+n.origin.x],i=n.bar[n.origin.offsetPos],o=0;i>s?o=-1:s>i+n.bar[n.origin.offset]&&(o=1);var l=n.pos()+o*r*n.scroller[n.origin.client];n.pos(l)}},type:"mousedown"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")))};baron.fn.controls=function(t){for(var s=0;this[s];)i.call(this[s],t),s++;return this}}(window); | ||
!function(t,s){"use strict";function i(e){var r,o,n=!!e,l={$:t.jQuery,direction:"v",barOnCls:"_scrollbar",resizeDebounce:0,event:function(t,s,i,r){e.$(t)[r||"on"](s,i)},cssGuru:!1,impact:"scroller"};e=e||{};for(var c in l)e[c]===s&&(e[c]=l[c]);r=e.$&&this instanceof e.$,r?e.root=o=this:o=e.$?e.$(e.root||e.scroller):[];var a=new i.fn.constructor(o,e,n);return a.autoUpdate&&a.autoUpdate(),a}function e(i,e){var r=0;for((i.length===s||i===t)&&(i=[i]);i[r];)e.call(this,i[r],r),r++}function r(){return(new Date).getTime()}function o(s,i,r){s._eventHandlers=s._eventHandlers||[{element:s.scroller,handler:function(t){s.scroll(t)},type:"scroll"},{element:s.root,handler:function(){s.update()},type:"transitionend animationend"},{element:s.scroller,handler:function(){s.update()},type:"keyup"},{element:s.bar,handler:function(t){t.preventDefault(),s.selection(),s.drag.now=1,s.draggingCls&&h(s.root).addClass(s.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){s.selection(1),s.drag.now=0,s.draggingCls&&h(s.root).removeClass(s.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(t){2!=t.button&&s._pos0(t)},type:"touchstart mousedown"},{element:document,handler:function(t){s.drag.now&&s.drag(t)},type:"mousemove touchmove"},{element:t,handler:function(){s.update()},type:"resize"},{element:s.root,handler:function(){s.update()},type:"sizeChange"},{element:s.clipper,handler:function(){s.clipperOnScroll()},type:"scroll"}],e(s._eventHandlers,function(t){t.element&&i(t.element,t.type,t.handler,r)})}function n(t,s,i,e){var r="data-baron-"+s+"-id";if("on"==i)t.setAttribute(r,e);else{if("off"!=i)return t.getAttribute(r);t.removeAttribute(r)}}function l(t){var s=new C.prototype.constructor(t);return o(s,t.event,"on"),n(s.root,t.direction,"on",p.length),p.push(s),s.update(),s}function c(t){var s={};t=t||{};for(var i in t)t.hasOwnProperty(i)&&(s[i]=t[i]);return s}function a(t){if(this.events&&this.events[t])for(var s=0;s<this.events[t].length;s++){var i=Array.prototype.slice.call(arguments,1);this.events[t][s].apply(this,i)}}if(t){var h=t.$,u=i,f=["left","top","right","bottom","width","height"],p=[],d={v:{x:"Y",pos:f[1],oppos:f[3],crossPos:f[0],crossOpPos:f[2],size:f[5],crossSize:f[4],crossMinSize:"min-"+f[4],crossMaxSize:"max-"+f[4],client:"clientHeight",crossClient:"clientWidth",scrollEdge:"scrollLeft",offset:"offsetHeight",crossOffset:"offsetWidth",offsetPos:"offsetTop",scroll:"scrollTop",scrollSize:"scrollHeight"},h:{x:"X",pos:f[0],oppos:f[2],crossPos:f[1],crossOpPos:f[3],size:f[4],crossSize:f[5],crossMinSize:"min-"+f[5],crossMaxSize:"max-"+f[5],client:"clientWidth",crossClient:"clientHeight",scrollEdge:"scrollTop",offset:"offsetWidth",crossOffset:"offsetHeight",offsetPos:"offsetLeft",scroll:"scrollLeft",scrollSize:"scrollWidth"}},v=17,g=15,m=/[\s\S]*Macintosh[\s\S]*\) Gecko[\s\S]*/,b=m.test(t.navigator.userAgent);i.fn={constructor:function(t,i,r){var o=c(i);o.event=function(t,s,r,o){e(t,function(t){i.event(t,s,r,o)})},this.length=0,e.call(this,t,function(t,i){var e=n(t,o.direction),r=+e;if(r==r&&e!=s&&p[r])this[i]=p[r];else{var a=c(o);if(o.root&&o.scroller){if(a.scroller=o.$(o.scroller,t),!a.scroller.length)return console.log("Scroller not found!",t,o.scroller),s}else a.scroller=t;a.root=t,this[i]=l(a)}this.length=i+1}),this.params=o},dispose:function(){var t=this.params;e(this,function(s,i){s.dispose(t),p[i]=null}),this.params=null},update:function(){var t=arguments;e(this,function(s,i){s.update.apply(s,t)})},baron:function(t){return t.root=[],t.scroller=this.params.scroller,e.call(this,this,function(s){t.root.push(s.root)}),t.direction="v"==this.params.direction?"h":"v",t._chain=!0,i(t)}};var C={};C.prototype={_debounce:function(t,i){var e,o,n=this,l=function(){if(n._disposed)return clearTimeout(e),e=n=null,s;var c=r()-o;i>c&&c>=0?e=setTimeout(l,i-c):(e=null,t())};return function(){o=r(),e||(e=setTimeout(l,i))}},constructor:function(i){function e(t,s){return f(t,s)[0]}function o(t){var s=this.barMinSize||20;t>0&&s>t&&(t=s),this.bar&&f(this.bar).css(this.origin.size,parseInt(t,10)+"px")}function n(t){if(this.bar){var s=f(this.bar).css(this.origin.pos),i=+t+"px";i&&i!=s&&f(this.bar).css(this.origin.pos,i)}}function l(){return C[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function c(t){return t*l.call(this)+this.barTopLimit}function h(t){return(t-this.barTopLimit)/l.call(this)}function u(){return!1}var f,p,m,C,y,z,$,w,S;if(w=$=r(),f=this.$=i.$,this.event=i.event,this.events={},this.root=i.root,this.scroller=e(i.scroller),this.bar=e(i.bar,this.root),C=this.track=e(i.track,this.root),!this.track&&this.bar&&(C=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=i.direction,this.rtl=i.rtl,this.origin=d[this.direction],this.barOnCls=i.barOnCls||"_baron",this.scrollingCls=i.scrollingCls,this.draggingCls=i.draggingCls,this.impact=i.impact,this.barTopLimit=0,this.resizeDebounce=i.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 i="page"+this.origin.x+"Offset",e=this.scroller[i]?i:this.origin.scroll;return t!==s&&(this.scroller[e]=t),this.scroller[e]},this.rpos=function(t){var s,i=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return s=t?this.pos(t*i):this.pos(),s/(i||1)},this.barOn=function(t){this.barOnCls&&(t||this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize]?f(this.root).hasClass(this.barOnCls)&&f(this.root).removeClass(this.barOnCls):f(this.root).hasClass(this.barOnCls)||f(this.root).addClass(this.barOnCls))},this._pos0=function(t){m=this.cursor(t)-p},this.drag=function(t){var s=h.call(this,this.cursor(t)-m),i=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=s*i},this.selection=function(t){this.event(document,"selectpos selectstart",u,t?"off":"on")},this.resize=function(){function t(){var t,s,e=i.scroller[i.origin.crossOffset],o=i.scroller[i.origin.crossClient],n=0;if(b?n=g:o>0&&0===e&&(e=o+v),e)if(i.barOn(),o=i.scroller[i.origin.crossClient],"scroller"==i.impact){var l=e-o+n;t=f(i.scroller).css(i.origin.crossSize),s=i.clipper[i.origin.crossClient]+l+"px",t!=s&&i._setCrossSizes(i.scroller,s)}else t=f(i.clipper).css(i.origin.crossSize),s=o+"px",t!=s&&i._setCrossSizes(i.clipper,s);Array.prototype.unshift.call(arguments,"resize"),a.apply(i,arguments),w=r()}var i=this,e=i.resizeDebounce===s?300:i.resizeDebounce,o=0;r()-w<e&&(clearTimeout(y),o=e),o?y=setTimeout(t,o):t()},this.updatePositions=function(){var t,s=this;s.bar&&(t=(C[s.origin.client]-s.barTopLimit)*s.scroller[s.origin.client]/s.scroller[s.origin.scrollSize],parseInt(S,10)!=parseInt(t,10)&&(o.call(s,t),S=t),p=c.call(s,s.rpos()),n.call(s,p)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(s,arguments),$=r()},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(z||t.$(t.root).addClass(t.scrollingCls),clearTimeout(z),z=setTimeout(function(){t.$(t.root).removeClass(t.scrollingCls),z=s},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,s){var i={};i[this.origin.crossSize]=s,i[this.origin.crossMinSize]=s,i[this.origin.crossMaxSize]=s,this.$(t).css(i)},this._dumbCss=function(t){if(!i.cssGuru){var s=t?"hidden":null,e=t?"none":null;this.$(this.clipper).css({overflow:s,msOverflowStyle:e});var r=t?"scroll":null,o="v"==this.direction?"y":"x",n={};n["overflow-"+o]=r,n["box-sizing"]="border-box",n.margin="0",n.border="0",this.$(this.scroller).css(n)}},this._dumbCss(!0),b){var _="paddingRight",x={},O=t.getComputedStyle(this.scroller)[[_]];this.scroller[this.origin.crossOffset]-this.scroller[this.origin.crossClient];"h"==i.direction?_="paddingBottom":i.rtl&&(_="paddingLeft");var T=parseInt(O,10);T!=T&&(T=0),x[_]=g+T+"px",f(this.scroller).css(x)}return this},update:function(t){return a.call(this,"upd",t),this.resize(1),this.updatePositions(),this},dispose:function(t){o(this,this.event,"off"),n(this.root,t.direction,"off"),"v"==t.direction?this._setCrossSizes(this.scroller,""):this._setCrossSizes(this.clipper,""),this._dumbCss(!1),this.barOn(!0),a.call(this,"dispose"),this._disposed=!0},on:function(t,s,i){for(var e=t.split(" "),r=0;r<e.length;r++)"init"==e[r]?s.call(this,i):(this.events[e[r]]=this.events[e[r]]||[],this.events[e[r]].push(function(t){s.call(this,t||i)}))}},i.fn.constructor.prototype=i.fn,C.prototype.constructor.prototype=C.prototype,i.noConflict=function(){return t.baron=u,i},i.version="2.0.1",h&&h.fn&&(h.fn.baron=i),t.baron=i,"undefined"!=typeof module&&(module.exports=i.noConflict())}}(window),function(t,s){var e=function(t){function e(t,i,e){var r=1==e?"pos":"oppos";l<(c.minView||0)&&(i=s),this.$(n[t]).css(this.origin.pos,"").css(this.origin.oppos,"").removeClass(c.outside),i!==s&&(i+="px",this.$(n[t]).css(this.origin[r],i).addClass(c.outside))}function r(t){try{i=document.createEvent("WheelEvent"),i.initWebKitWheelEvent(t.originalEvent.wheelDeltaX,t.originalEvent.wheelDeltaY),f.dispatchEvent(i),t.preventDefault()}catch(t){}}function o(t){var s;for(var i in t)c[i]=t[i];if(n=this.$(c.elements,this.scroller)){l=this.scroller[this.origin.client];for(var e=0;e<n.length;e++)s={},s[this.origin.size]=n[e][this.origin.offset],n[e].parentNode!==this.scroller&&this.$(n[e].parentNode).css(s),s={},s[this.origin.crossSize]=n[e].parentNode[this.origin.crossClient],this.$(n[e]).css(s),l-=n[e][this.origin.offset],u[e]=n[e].parentNode[this.origin.offsetPos],a[e]=a[e-1]||0,h[e]=h[e-1]||Math.min(u[e],0),n[e-1]&&(a[e]+=n[e-1][this.origin.offset],h[e]+=n[e-1][this.origin.offset]),(0!=e||0!=u[e])&&(this.event(n[e],"mousewheel",r,"off"),this.event(n[e],"mousewheel",r));c.limiter&&n[0]&&(this.track&&this.track!=this.scroller?(s={},s[this.origin.pos]=n[0].parentNode[this.origin.offset],this.$(this.track).css(s)):this.barTopLimit=n[0].parentNode[this.origin.offset],this.scroll()),c.limiter===!1&&(this.barTopLimit=0)}var o={element:n,handler:function(){for(var t,s=d(this)[0].parentNode,i=s.offsetTop,e=0;e<n.length;e++)n[e]===this&&(t=e);var r=i-a[t];c.scroll?c.scroll({x1:v.scroller.scrollTop,x2:r}):v.scroller.scrollTop=r},type:"click"};c.clickable&&(this._eventHandlers.push(o),p(o.element,o.type,o.handler,"on"))}var n,l,c={outside:"",inside:"",before:"",after:"",past:"",future:"",radius:0,minView:0},a=[],h=[],u=[],f=this.scroller,p=this.event,d=this.$,v=this;this.on("init",o,t);var g=[],m=[];this.on("init scroll",function(){var t,i,r;if(n){for(var o,f=0;f<n.length;f++)t=0,u[f]-this.pos()<h[f]+c.radius?(t=1,i=a[f]):u[f]-this.pos()>h[f]+l-c.radius?(t=2,i=this.scroller[this.origin.client]-n[f][this.origin.offset]-a[f]-l):(t=3,i=s),r=!1,(u[f]-this.pos()<h[f]||u[f]-this.pos()>h[f]+l)&&(r=!0),(t!=g[f]||r!=m[f])&&(e.call(this,f,i,t),g[f]=t,m[f]=r,o=!0);if(o)for(f=0;f<n.length;f++)1==g[f]&&c.past&&this.$(n[f]).addClass(c.past).removeClass(c.future),2==g[f]&&c.future&&this.$(n[f]).addClass(c.future).removeClass(c.past),3==g[f]?((c.future||c.past)&&this.$(n[f]).removeClass(c.past).removeClass(c.future),c.inside&&this.$(n[f]).addClass(c.inside)):c.inside&&this.$(n[f]).removeClass(c.inside),g[f]!=g[f+1]&&1==g[f]&&c.before?this.$(n[f]).addClass(c.before).removeClass(c.after):g[f]!=g[f-1]&&2==g[f]&&c.after?this.$(n[f]).addClass(c.after).removeClass(c.before):this.$(n[f]).removeClass(c.before).removeClass(c.after),c.grad&&(m[f]?this.$(n[f]).addClass(c.grad):this.$(n[f]).removeClass(c.grad))}}),this.on("resize upd",function(t){o.call(this,t&&t.fix)})};baron.fn.fix=function(t){for(var s=0;this[s];)e.call(this[s],t),s++;return this}}(window),function(t){var s=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null,i=function(){function t(){o.root[o.origin.offset]?e():i()}function i(){r||(r=setInterval(function(){o.root[o.origin.offset]&&(e(),o.update())},300))}function e(){clearInterval(r),r=null}var r,o=this;if(!this._au){var n=o._debounce(function(){o.update()},300);this._observer=new s(function(){t(),o.update(),n()}),this.on("init",function(){o._observer.observe(o.root,{childList:!0,subtree:!0,characterData:!0}),t()}),this.on("dispose",function(){o._observer.disconnect(),e(),delete o._observer}),this._au=!0}};baron.fn.autoUpdate=function(t){if(!s)return this;for(var e=0;this[e];)i.call(this[e],t),e++;return this}}(window),function(t,s){var i=function(t){var s,i,e,r,o,n=this;r=t.screen||.9,t.forward&&(s=this.$(t.forward,this.clipper),o={element:s,handler:function(){var s=n.pos()+(t.delta||30);n.pos(s)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.backward&&(i=this.$(t.backward,this.clipper),o={element:i,handler:function(){var s=n.pos()-(t.delta||30);n.pos(s)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.track&&(e=t.track===!0?this.track:this.$(t.track,this.clipper)[0],e&&(o={element:e,handler:function(t){if(t.target==e){var s=t["offset"+n.origin.x],i=n.bar[n.origin.offsetPos],o=0;i>s?o=-1:s>i+n.bar[n.origin.offset]&&(o=1);var l=n.pos()+o*r*n.scroller[n.origin.client];n.pos(l)}},type:"mousedown"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")))};baron.fn.controls=function(t){for(var s=0;this[s];)i.call(this[s],t),s++;return this}}(window); |
@@ -0,1 +1,8 @@ | ||
## 2.1.0 | ||
- Rework of cross-scroll bugs issue https://github.com/Diokuz/baron/issues/134 | ||
- Add tests for scroll-scroll bugs | ||
- Update uglify-js package | ||
- Change `main` field to prod version of baron | ||
## 2.0.2 | ||
@@ -130,2 +137,2 @@ | ||
- "require()" support added | ||
- Server-side "usage" handler added | ||
- Server-side "usage" handler added |
{ | ||
"name": "baron", | ||
"description": "A small, fast and crossbrowser custom scrollbar with native system scroll mechanic.", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"readmeFilename": "README.md", | ||
"homepage": "https://github.com/Diokuz/baron", | ||
"scripts": { | ||
"start": "gulp build" | ||
"start": "gulp build", | ||
"test": "gulp t" | ||
}, | ||
@@ -22,3 +23,3 @@ "authors": [ | ||
], | ||
"main": "./baron.js", | ||
"main": "./baron.min.js", | ||
"devDependencies": { | ||
@@ -32,3 +33,3 @@ "chai": "~3.2.0", | ||
"gulp-remove-code": "^1.0.2", | ||
"gulp-uglify": "^1.4.0", | ||
"gulp-uglify": "^1.5.2", | ||
"jscs": "~2.1.1", | ||
@@ -35,0 +36,0 @@ "jshint-summary": "^0.4.0", |
@@ -391,7 +391,2 @@ (function(window, undefined) { | ||
out.scrollEdge = 0; | ||
if (params.rtl) { | ||
out.scrollEdge = out.clipper[out.origin.scrollEdge]; // initial position | ||
} | ||
return out; | ||
@@ -515,2 +510,3 @@ } | ||
this.direction = params.direction; | ||
this.rtl = params.rtl; | ||
this.origin = origin[this.direction]; | ||
@@ -636,2 +632,3 @@ this.barOnCls = params.barOnCls || '_baron'; | ||
// also fires on init | ||
// Note: max/min-size didnt sets if size did not really changed (for example, on init in Chrome) | ||
this.resize = function() { | ||
@@ -750,6 +747,11 @@ var self = this; | ||
this.clipperOnScroll = function() { | ||
if (this.direction == 'h') return; | ||
// WTF is this line? https://github.com/Diokuz/baron/issues/134 | ||
// if (this.direction == 'h') return; | ||
// clipper.scrollLeft = initial scroll position (0 for ltr, 20 for rtl) | ||
this.clipper[this.origin.scrollEdge] = this.scrollEdge; | ||
// assign `initial scroll position` to `clipper.scrollLeft` (0 for ltr, ~20 for rtl) | ||
if (!this.rtl) { | ||
this.clipper[this.origin.scrollEdge] = 0; | ||
} else { | ||
this.clipper[this.origin.scrollEdge] = this.clipper[this.origin.scrollSize]; | ||
} | ||
}; | ||
@@ -756,0 +758,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
131306
2665