Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baron

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baron - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

6

baron.js

@@ -672,7 +672,7 @@ (function(window, undefined) {

if (!scrollingTimer) {
self.$(self.scroller).addClass(self.scrollingCls);
self.$(self.root).addClass(self.scrollingCls);
}
clearTimeout(scrollingTimer);
scrollingTimer = setTimeout(function() {
self.$(self.scroller).removeClass(self.scrollingCls);
self.$(self.root).removeClass(self.scrollingCls);
scrollingTimer = undefined;

@@ -784,3 +784,3 @@ }, 300);

baron.version = '1.1.0';
baron.version = '1.2.0';

@@ -787,0 +787,0 @@ if ($ && $.fn) { // Adding baron to jQuery as plugin

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

!function(t,i){"use strict";function s(e){var r,o,n=!e,l={$:t.jQuery,direction:"v",barOnCls:"baron",resizeDebounce:0,event:function(t,i,s,r){e.$(t)[r||"on"](i,s)},cssGuru:!1};e=e||{};for(var c in l)e[c]===i&&(e[c]=l[c]);r=this instanceof e.$,r?e.root=o=this:o=e.$(e.root||e.scroller);var a=new s.fn.constructor(o,e,n);return a.autoUpdate&&!n&&a.autoUpdate(),a}function e(s,e){var r=0;for((s.length===i||s===t)&&(s=[s]);s[r];)e.call(this,s[r],r),r++}function r(){return(new Date).getTime()}function o(i,s,r){i._eventHandlers=i._eventHandlers||[{element:i.scroller,handler:function(t){i.scroll(t)},type:"scroll"},{element:i.root,handler:function(){i.update()},type:"transitionend animationend"},{element:i.scroller,handler:function(){i.update()},type:"keyup"},{element:i.bar,handler:function(t){t.preventDefault(),i.selection(),i.drag.now=1,i.draggingCls&&h(i.bar).addClass(i.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){i.selection(1),i.drag.now=0,i.draggingCls&&h(i.bar).removeClass(i.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(t){2!=t.button&&i._pos0(t)},type:"touchstart mousedown"},{element:document,handler:function(t){i.drag.now&&i.drag(t)},type:"mousemove touchmove"},{element:t,handler:function(){i.update()},type:"resize"},{element:i.root,handler:function(){i.update()},type:"sizeChange"},{element:i.clipper,handler:function(){i.clipperOnScroll()},type:"scroll"}],e(i._eventHandlers,function(t){t.element&&s(t.element,t.type,t.handler,r)})}function n(t,i,s,e){var r="data-baron-"+i+"-id";if("on"==s)t.setAttribute(r,e);else{if("off"!=s)return t.getAttribute(r);t.removeAttribute(r)}}function l(t){n(t.root,t.direction)&&console.log("Error! Baron for this node already initialized",t.root);var i=new v.prototype.constructor(t);return o(i,t.event,"on"),n(i.root,t.direction,"on",p.length),p.push(i),i.update(),i.scrollEdge=0,t.rtl&&(i.scrollEdge=i.clipper[i.origin.scrollEdge]),i}function c(t){var i={};t=t||{};for(var s in t)t.hasOwnProperty(s)&&(i[s]=t[s]);return i}function a(t){if(this.events&&this.events[t])for(var i=0;i<this.events[t].length;i++){var s=Array.prototype.slice.call(arguments,1);this.events[t][i].apply(this,s)}}if(t){var h=t.$,u=s,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"}};s._instances=p,s.fn={constructor:function(t,s,r){var o=c(s);o.event=function(t,i,r,o){e(t,function(t){s.event(t,i,r,o)})},this.length=0,e.call(this,t,function(t,s){var e=n(t,o.direction),a=+e;if(a==a&&e!=i&&p[a]&&r)this[s]=p[a];else{var h=c(o);o.root&&o.scroller?(h.scroller=o.$(o.scroller,t),h.scroller.length||(h.scroller=t)):h.scroller=t,h.root=t,this[s]=l(h)}this.length=s+1}),this.params=o},dispose:function(){var t=this.params;e(this,function(i){i.dispose(t)}),this.params=null},update:function(){for(var t=0;this[t];)this[t].update.apply(this[t],arguments),t++},baron:function(t){return t.root=[],t.scroller=this.params.scroller,e.call(this,this,function(i){t.root.push(i.root)}),t.direction="v"==this.params.direction?"h":"v",t._chain=!0,s(t)}};var v={};v.prototype={_debounce:function(t,s){var e,o,n=this,l=function(){if(n._disposed)return clearTimeout(e),e=n=null,i;var c=r()-o;s>c&&c>=0?e=setTimeout(l,s-c):(e=null,t())};return function(){o=r(),e||(e=setTimeout(l,s))}},constructor:function(t){function s(t,i){return u(t,i)[0]}function e(t){var i=this.barMinSize||20;t>0&&i>t&&(t=i),this.bar&&u(this.bar).css(this.origin.size,parseInt(t,10)+"px")}function o(t){if(this.bar){var i=u(this.bar).css(this.origin.pos),s=+t+"px";s&&s!=i&&u(this.bar).css(this.origin.pos,s)}}function n(){return v[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function l(t){return t*n.call(this)+this.barTopLimit}function c(t){return(t-this.barTopLimit)/n.call(this)}function h(){return!1}var u,f,p,v,g,m,b,C,z;return C=b=r(),u=this.$=t.$,this.event=t.event,this.events={},this.root=t.root,this.scroller=s(t.scroller),this.bar=s(t.bar,this.root),v=this.track=s(t.track,this.root),!this.track&&this.bar&&(v=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=t.direction,this.origin=d[this.direction],this.barOnCls=t.barOnCls||"_baron",this.scrollingCls=t.scrollingCls,this.draggingCls=t.draggingCls,this.impact=t.impact,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 s="page"+this.origin.x+"Offset",e=this.scroller[s]?s:this.origin.scroll;return t!==i&&(this.scroller[e]=t),this.scroller[e]},this.rpos=function(t){var i,s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return i=t?this.pos(t*s):this.pos(),i/(s||1)},this.barOn=function(t){this.barOnCls&&(t||this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize]?u(this.root).hasClass(this.barOnCls)&&u(this.root).removeClass(this.barOnCls):u(this.root).hasClass(this.barOnCls)||u(this.root).addClass(this.barOnCls))},this._pos0=function(t){p=this.cursor(t)-f},this.drag=function(t){var i=c.call(this,this.cursor(t)-p),s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=i*s},this.selection=function(t){this.event(document,"selectpos selectstart",h,t?"off":"on")},this.resize=function(){function t(){var t,i,e=s.scroller[s.origin.crossOffset],o=s.scroller[s.origin.crossClient];if(o>0&&0===e&&(e=o+17),e){s.barOn(),o=s.scroller[s.origin.crossClient];var n=s.impact?"scroller"==s.impact:"v"==s.direction;if(n){var l=e-o;t=u(s.clipper).css(s.origin.crossSize),i=s.clipper[s.origin.crossClient]+l+"px",t!=i&&s._setCrossSizes(s.scroller,i)}else t=u(s.clipper).css(s.origin.crossSize),i=o+"px",t!=i&&s._setCrossSizes(s.clipper,i)}Array.prototype.unshift.call(arguments,"resize"),a.apply(s,arguments),C=r()}var s=this,e=s.resizeDebounce===i?300:s.resizeDebounce,o=0;r()-C<e&&(clearTimeout(g),o=e),o?g=setTimeout(t,o):t()},this.updatePositions=function(){var t,i=this;i.bar&&(t=(v[i.origin.client]-i.barTopLimit)*i.scroller[i.origin.client]/i.scroller[i.origin.scrollSize],parseInt(z,10)!=parseInt(t,10)&&(e.call(i,t),z=t),f=l.call(i,i.rpos()),o.call(i,f)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(i,arguments),b=r()},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(m||t.$(t.scroller).addClass(t.scrollingCls),clearTimeout(m),m=setTimeout(function(){t.$(t.scroller).removeClass(t.scrollingCls),m=i},300))},this.clipperOnScroll=function(){"h"!=this.direction&&(this.clipper[this.origin.scrollEdge]=this.scrollEdge)},this._setCrossSizes=function(t,i){var s={};s[this.origin.crossSize]=i,s[this.origin.crossMinSize]=i,s[this.origin.crossMaxSize]=i,this.$(t).css(s)},this._dumbCss=function(i){if(!t.cssGuru){var s=i?"hidden":null,e=i?"none":null;this.$(this.clipper).css({overflow:s,msOverflowStyle:e});var r=i?"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},update:function(t){return a.call(this,"upd",t),this._dumbCss(!0),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,i,s){for(var e=t.split(" "),r=0;r<e.length;r++)"init"==e[r]?i.call(this,s):(this.events[e[r]]=this.events[e[r]]||[],this.events[e[r]].push(function(t){i.call(this,t||s)}))}},s.fn.constructor.prototype=s.fn,v.prototype.constructor.prototype=v.prototype,s.noConflict=function(){return t.baron=u,s},s.version="1.1.0",h&&h.fn&&(h.fn.baron=s),t.baron=s,"undefined"!=typeof module&&(module.exports=s.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 i;for(var s in t)c[s]=t[s];if(n=this.$(c.elements,this.scroller)){l=this.scroller[this.origin.client];for(var e=0;e<n.length;e++)i={},i[this.origin.size]=n[e][this.origin.offset],n[e].parentNode!==this.scroller&&this.$(n[e].parentNode).css(i),i={},i[this.origin.crossSize]=n[e].parentNode[this.origin.crossClient],this.$(n[e]).css(i),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?(i={},i[this.origin.pos]=n[0].parentNode[this.origin.offset],this.$(this.track).css(i)):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,i=d(this)[0].parentNode,s=i.offsetTop,e=0;e<n.length;e++)n[e]===this&&(t=e);var r=s-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 i=0;this[i];)e.call(this[i],t),i++;return this}}(window),function(t){var i=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null,s=function(){function t(){o.root[o.origin.offset]?e():s()}function s(){r||(r=setInterval(function(){o.root[o.origin.offset]&&(e(),o.update())},300))}function e(){clearInterval(r),r=null}var r,o=this,n=o._debounce(function(){o.update()},300);this._observer=new i(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})};baron.fn.autoUpdate=function(t){if(!i)return this;for(var e=0;this[e];)s.call(this[e],t),e++;return this}}(window),function(t,i){var s=function(t){var i,s,e,r,o,n=this;r=t.screen||.9,t.forward&&(i=this.$(t.forward,this.clipper),o={element:i,handler:function(){var i=n.pos()-t.delta||30;n.pos(i)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.backward&&(s=this.$(t.backward,this.clipper),o={element:s,handler:function(){var i=n.pos()+t.delta||30;n.pos(i)},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){var i=t["offset"+n.origin.x],s=n.bar[n.origin.offsetPos],e=0;s>i?e=-1:i>s+n.bar[n.origin.offset]&&(e=1);var o=n.pos()+e*r*n.scroller[n.origin.client];n.pos(o)},type:"mousedown"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")))};baron.fn.controls=function(t){for(var i=0;this[i];)s.call(this[i],t),i++;return this}}(window),function(t,i){var s=function(t){function i(){return m.scroller[m.origin.scroll]+m.scroller[m.origin.offset]}function s(){return m.scroller[m.origin.scrollSize]}function e(){return m.scroller[m.origin.client]}function r(t,i){var s=5e-4*t;return Math.floor(i-s*(t+550))}function o(t){h=t,t?(n(),l=setInterval(n,200)):clearInterval(l)}function n(){var n,l,h={},w=i(),$=s(),S=1==b;if(l=0,b>0&&(l=40),n=r(z,l),w>=$-z&&b>-1?S&&(z+=n):z=0,0>z&&(z=0),h[f]=z+"px",e()<=s()){m.$(u).css(h);for(var _=0;_<v.length;_++)m.$(v[_].self).css(v[_].property,Math.min(z/p*100,100)+"%")}g&&z&&m.$(m.root).addClass(g),0==z&&t.onCollapse&&t.onCollapse(),b=0,c=setTimeout(function(){b=-1},y),d&&z>p&&!a&&(d(),a=!0),0==z?C++:C=0,C>1&&(o(!1),a=!1,g&&m.$(m.root).removeClass(g))}var l,c,a,h,u=this.$(t.block),f=t.size||this.origin.size,p=t.limit||80,d=t.onExpand,v=t.elements||[],g=t.inProgress||"",m=this,b=0,C=0,z=0,y=t.waiting||500;this.on("init",function(){o(!0)}),this.on("dispose",function(){o(!1)}),this.event(this.scroller,"mousewheel DOMMouseScroll",function(t){var e=t.wheelDelta<0||t.originalEvent&&t.originalEvent.wheelDelta<0||t.detail>0;e&&(b=1,clearTimeout(c),!h&&i()>=s()&&o(!0))})};baron.fn.pull=function(t){for(var i=0;this[i];)s.call(this[i],t),i++;return this}}(window);
!function(t,i){"use strict";function s(e){var r,o,n=!e,l={$:t.jQuery,direction:"v",barOnCls:"baron",resizeDebounce:0,event:function(t,i,s,r){e.$(t)[r||"on"](i,s)},cssGuru:!1};e=e||{};for(var c in l)e[c]===i&&(e[c]=l[c]);r=this instanceof e.$,r?e.root=o=this:o=e.$(e.root||e.scroller);var a=new s.fn.constructor(o,e,n);return a.autoUpdate&&!n&&a.autoUpdate(),a}function e(s,e){var r=0;for((s.length===i||s===t)&&(s=[s]);s[r];)e.call(this,s[r],r),r++}function r(){return(new Date).getTime()}function o(i,s,r){i._eventHandlers=i._eventHandlers||[{element:i.scroller,handler:function(t){i.scroll(t)},type:"scroll"},{element:i.root,handler:function(){i.update()},type:"transitionend animationend"},{element:i.scroller,handler:function(){i.update()},type:"keyup"},{element:i.bar,handler:function(t){t.preventDefault(),i.selection(),i.drag.now=1,i.draggingCls&&h(i.bar).addClass(i.draggingCls)},type:"touchstart mousedown"},{element:document,handler:function(){i.selection(1),i.drag.now=0,i.draggingCls&&h(i.bar).removeClass(i.draggingCls)},type:"mouseup blur touchend"},{element:document,handler:function(t){2!=t.button&&i._pos0(t)},type:"touchstart mousedown"},{element:document,handler:function(t){i.drag.now&&i.drag(t)},type:"mousemove touchmove"},{element:t,handler:function(){i.update()},type:"resize"},{element:i.root,handler:function(){i.update()},type:"sizeChange"},{element:i.clipper,handler:function(){i.clipperOnScroll()},type:"scroll"}],e(i._eventHandlers,function(t){t.element&&s(t.element,t.type,t.handler,r)})}function n(t,i,s,e){var r="data-baron-"+i+"-id";if("on"==s)t.setAttribute(r,e);else{if("off"!=s)return t.getAttribute(r);t.removeAttribute(r)}}function l(t){n(t.root,t.direction)&&console.log("Error! Baron for this node already initialized",t.root);var i=new v.prototype.constructor(t);return o(i,t.event,"on"),n(i.root,t.direction,"on",p.length),p.push(i),i.update(),i.scrollEdge=0,t.rtl&&(i.scrollEdge=i.clipper[i.origin.scrollEdge]),i}function c(t){var i={};t=t||{};for(var s in t)t.hasOwnProperty(s)&&(i[s]=t[s]);return i}function a(t){if(this.events&&this.events[t])for(var i=0;i<this.events[t].length;i++){var s=Array.prototype.slice.call(arguments,1);this.events[t][i].apply(this,s)}}if(t){var h=t.$,u=s,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"}};s._instances=p,s.fn={constructor:function(t,s,r){var o=c(s);o.event=function(t,i,r,o){e(t,function(t){s.event(t,i,r,o)})},this.length=0,e.call(this,t,function(t,s){var e=n(t,o.direction),a=+e;if(a==a&&e!=i&&p[a]&&r)this[s]=p[a];else{var h=c(o);o.root&&o.scroller?(h.scroller=o.$(o.scroller,t),h.scroller.length||(h.scroller=t)):h.scroller=t,h.root=t,this[s]=l(h)}this.length=s+1}),this.params=o},dispose:function(){var t=this.params;e(this,function(i){i.dispose(t)}),this.params=null},update:function(){for(var t=0;this[t];)this[t].update.apply(this[t],arguments),t++},baron:function(t){return t.root=[],t.scroller=this.params.scroller,e.call(this,this,function(i){t.root.push(i.root)}),t.direction="v"==this.params.direction?"h":"v",t._chain=!0,s(t)}};var v={};v.prototype={_debounce:function(t,s){var e,o,n=this,l=function(){if(n._disposed)return clearTimeout(e),e=n=null,i;var c=r()-o;s>c&&c>=0?e=setTimeout(l,s-c):(e=null,t())};return function(){o=r(),e||(e=setTimeout(l,s))}},constructor:function(t){function s(t,i){return u(t,i)[0]}function e(t){var i=this.barMinSize||20;t>0&&i>t&&(t=i),this.bar&&u(this.bar).css(this.origin.size,parseInt(t,10)+"px")}function o(t){if(this.bar){var i=u(this.bar).css(this.origin.pos),s=+t+"px";s&&s!=i&&u(this.bar).css(this.origin.pos,s)}}function n(){return v[this.origin.client]-this.barTopLimit-this.bar[this.origin.offset]}function l(t){return t*n.call(this)+this.barTopLimit}function c(t){return(t-this.barTopLimit)/n.call(this)}function h(){return!1}var u,f,p,v,g,m,b,C,z;return C=b=r(),u=this.$=t.$,this.event=t.event,this.events={},this.root=t.root,this.scroller=s(t.scroller),this.bar=s(t.bar,this.root),v=this.track=s(t.track,this.root),!this.track&&this.bar&&(v=this.bar.parentNode),this.clipper=this.scroller.parentNode,this.direction=t.direction,this.origin=d[this.direction],this.barOnCls=t.barOnCls||"_baron",this.scrollingCls=t.scrollingCls,this.draggingCls=t.draggingCls,this.impact=t.impact,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 s="page"+this.origin.x+"Offset",e=this.scroller[s]?s:this.origin.scroll;return t!==i&&(this.scroller[e]=t),this.scroller[e]},this.rpos=function(t){var i,s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];return i=t?this.pos(t*s):this.pos(),i/(s||1)},this.barOn=function(t){this.barOnCls&&(t||this.scroller[this.origin.client]>=this.scroller[this.origin.scrollSize]?u(this.root).hasClass(this.barOnCls)&&u(this.root).removeClass(this.barOnCls):u(this.root).hasClass(this.barOnCls)||u(this.root).addClass(this.barOnCls))},this._pos0=function(t){p=this.cursor(t)-f},this.drag=function(t){var i=c.call(this,this.cursor(t)-p),s=this.scroller[this.origin.scrollSize]-this.scroller[this.origin.client];this.scroller[this.origin.scroll]=i*s},this.selection=function(t){this.event(document,"selectpos selectstart",h,t?"off":"on")},this.resize=function(){function t(){var t,i,e=s.scroller[s.origin.crossOffset],o=s.scroller[s.origin.crossClient];if(o>0&&0===e&&(e=o+17),e){s.barOn(),o=s.scroller[s.origin.crossClient];var n=s.impact?"scroller"==s.impact:"v"==s.direction;if(n){var l=e-o;t=u(s.clipper).css(s.origin.crossSize),i=s.clipper[s.origin.crossClient]+l+"px",t!=i&&s._setCrossSizes(s.scroller,i)}else t=u(s.clipper).css(s.origin.crossSize),i=o+"px",t!=i&&s._setCrossSizes(s.clipper,i)}Array.prototype.unshift.call(arguments,"resize"),a.apply(s,arguments),C=r()}var s=this,e=s.resizeDebounce===i?300:s.resizeDebounce,o=0;r()-C<e&&(clearTimeout(g),o=e),o?g=setTimeout(t,o):t()},this.updatePositions=function(){var t,i=this;i.bar&&(t=(v[i.origin.client]-i.barTopLimit)*i.scroller[i.origin.client]/i.scroller[i.origin.scrollSize],parseInt(z,10)!=parseInt(t,10)&&(e.call(i,t),z=t),f=l.call(i,i.rpos()),o.call(i,f)),Array.prototype.unshift.call(arguments,"scroll"),a.apply(i,arguments),b=r()},this.scroll=function(){var t=this;t.updatePositions(),t.scrollingCls&&(m||t.$(t.root).addClass(t.scrollingCls),clearTimeout(m),m=setTimeout(function(){t.$(t.root).removeClass(t.scrollingCls),m=i},300))},this.clipperOnScroll=function(){"h"!=this.direction&&(this.clipper[this.origin.scrollEdge]=this.scrollEdge)},this._setCrossSizes=function(t,i){var s={};s[this.origin.crossSize]=i,s[this.origin.crossMinSize]=i,s[this.origin.crossMaxSize]=i,this.$(t).css(s)},this._dumbCss=function(i){if(!t.cssGuru){var s=i?"hidden":null,e=i?"none":null;this.$(this.clipper).css({overflow:s,msOverflowStyle:e});var r=i?"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},update:function(t){return a.call(this,"upd",t),this._dumbCss(!0),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,i,s){for(var e=t.split(" "),r=0;r<e.length;r++)"init"==e[r]?i.call(this,s):(this.events[e[r]]=this.events[e[r]]||[],this.events[e[r]].push(function(t){i.call(this,t||s)}))}},s.fn.constructor.prototype=s.fn,v.prototype.constructor.prototype=v.prototype,s.noConflict=function(){return t.baron=u,s},s.version="1.2.0",h&&h.fn&&(h.fn.baron=s),t.baron=s,"undefined"!=typeof module&&(module.exports=s.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 i;for(var s in t)c[s]=t[s];if(n=this.$(c.elements,this.scroller)){l=this.scroller[this.origin.client];for(var e=0;e<n.length;e++)i={},i[this.origin.size]=n[e][this.origin.offset],n[e].parentNode!==this.scroller&&this.$(n[e].parentNode).css(i),i={},i[this.origin.crossSize]=n[e].parentNode[this.origin.crossClient],this.$(n[e]).css(i),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?(i={},i[this.origin.pos]=n[0].parentNode[this.origin.offset],this.$(this.track).css(i)):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,i=d(this)[0].parentNode,s=i.offsetTop,e=0;e<n.length;e++)n[e]===this&&(t=e);var r=s-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 i=0;this[i];)e.call(this[i],t),i++;return this}}(window),function(t){var i=t.MutationObserver||t.WebKitMutationObserver||t.MozMutationObserver||null,s=function(){function t(){o.root[o.origin.offset]?e():s()}function s(){r||(r=setInterval(function(){o.root[o.origin.offset]&&(e(),o.update())},300))}function e(){clearInterval(r),r=null}var r,o=this,n=o._debounce(function(){o.update()},300);this._observer=new i(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})};baron.fn.autoUpdate=function(t){if(!i)return this;for(var e=0;this[e];)s.call(this[e],t),e++;return this}}(window),function(t,i){var s=function(t){var i,s,e,r,o,n=this;r=t.screen||.9,t.forward&&(i=this.$(t.forward,this.clipper),o={element:i,handler:function(){var i=n.pos()-t.delta||30;n.pos(i)},type:"click"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")),t.backward&&(s=this.$(t.backward,this.clipper),o={element:s,handler:function(){var i=n.pos()+t.delta||30;n.pos(i)},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){var i=t["offset"+n.origin.x],s=n.bar[n.origin.offsetPos],e=0;s>i?e=-1:i>s+n.bar[n.origin.offset]&&(e=1);var o=n.pos()+e*r*n.scroller[n.origin.client];n.pos(o)},type:"mousedown"},this._eventHandlers.push(o),this.event(o.element,o.type,o.handler,"on")))};baron.fn.controls=function(t){for(var i=0;this[i];)s.call(this[i],t),i++;return this}}(window),function(t,i){var s=function(t){function i(){return m.scroller[m.origin.scroll]+m.scroller[m.origin.offset]}function s(){return m.scroller[m.origin.scrollSize]}function e(){return m.scroller[m.origin.client]}function r(t,i){var s=5e-4*t;return Math.floor(i-s*(t+550))}function o(t){h=t,t?(n(),l=setInterval(n,200)):clearInterval(l)}function n(){var n,l,h={},w=i(),$=s(),S=1==b;if(l=0,b>0&&(l=40),n=r(z,l),w>=$-z&&b>-1?S&&(z+=n):z=0,0>z&&(z=0),h[f]=z+"px",e()<=s()){m.$(u).css(h);for(var _=0;_<v.length;_++)m.$(v[_].self).css(v[_].property,Math.min(z/p*100,100)+"%")}g&&z&&m.$(m.root).addClass(g),0==z&&t.onCollapse&&t.onCollapse(),b=0,c=setTimeout(function(){b=-1},y),d&&z>p&&!a&&(d(),a=!0),0==z?C++:C=0,C>1&&(o(!1),a=!1,g&&m.$(m.root).removeClass(g))}var l,c,a,h,u=this.$(t.block),f=t.size||this.origin.size,p=t.limit||80,d=t.onExpand,v=t.elements||[],g=t.inProgress||"",m=this,b=0,C=0,z=0,y=t.waiting||500;this.on("init",function(){o(!0)}),this.on("dispose",function(){o(!1)}),this.event(this.scroller,"mousewheel DOMMouseScroll",function(t){var e=t.wheelDelta<0||t.originalEvent&&t.originalEvent.wheelDelta<0||t.detail>0;e&&(b=1,clearTimeout(c),!h&&i()>=s()&&o(!0))})};baron.fn.pull=function(t){for(var i=0;this[i];)s.call(this[i],t),i++;return this}}(window);

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

## 1.2.0
- `scrollingCls` param now sets on `root`, not `scroller`.
## 1.1.0

@@ -2,0 +6,0 @@

{
"name": "baron",
"description": "A small, fast and crossbrowser custom scrollbar with native system scroll mechanic.",
"version": "1.1.0",
"version": "1.2.0",
"readmeFilename": "README.md",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/Diokuz/baron",

@@ -5,4 +5,6 @@ [![Build Status](https://travis-ci.org/Diokuz/baron.svg)](https://travis-ci.org/Diokuz/baron)

Baron — a small, fast and crossbrowser custom scrollbar with native system scroll mechanic.
<img src="http://diokuz.github.io/pics/demo.gif" width="475px" height="331px" alt="Baron demo">
Baron — a small, fast and crossbrowser custom scrollbar with native system scroll mechanic.
## [Demo](http://diokuz.github.io/baron/)

@@ -9,0 +11,0 @@

@@ -672,7 +672,7 @@ (function(window, undefined) {

if (!scrollingTimer) {
self.$(self.scroller).addClass(self.scrollingCls);
self.$(self.root).addClass(self.scrollingCls);
}
clearTimeout(scrollingTimer);
scrollingTimer = setTimeout(function() {
self.$(self.scroller).removeClass(self.scrollingCls);
self.$(self.root).removeClass(self.scrollingCls);
scrollingTimer = undefined;

@@ -784,3 +784,3 @@ }, 300);

baron.version = '1.1.0';
baron.version = '1.2.0';

@@ -787,0 +787,0 @@ if ($ && $.fn) { // Adding baron to jQuery as plugin

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc