ux-doubleScroll.min.js |
|
! ux-angularjs-datagrid v.1.4.11 (c) 2016, Obogo https://github.com/obogo/ux-angularjs-datagrid License: MIT. |
(function (exports, global) {
if (typeof define === "function" && define.amd) {
define(exports);
} else if (typeof module !== "undefined" && module.exports) {
module.exports = exports;
} else {
global.ux = exports;
}
!function(a,b){"function"==typeof define&&define.amd?define(a):"undefined"!=typeof module&&module.exports?module.exports=a:b.ux=a,a.datagrid.events.DOUBLE_SCROLL_SCROLL_TO_TOP="datagrid:doubleScrollScrollToTop",a.datagrid.events.DOUBLE_SCROLL_SCROLL_TO_BOTTOM="datagrid:doubleScrollScrollToBottom",angular.module("ux").directive("uxDoubleScroll",["$window",function(b){return{link:function(c,d,e){function f(){var a=d[0].querySelectorAll(".datagrid")[0].attributes.getNamedItem("data-addons");return a&&a.value.match(/iScrollAddon/)?!0:!1}function g(){d[0].style.overflowY="auto",d[0].style.overflowX="hidden",n(),m(),c.doubleScroll=C,c.$on(a.datagrid.events.RESIZE,p),L?j():i(),y=c.$watch(h)}function h(){clearTimeout(A),A=setTimeout(function(){p()&&h()},100)}function i(){d[0].addEventListener("scroll",o,!0),s&&t.isReady()?(p(),o(null)):x=c.$on(a.datagrid.events.ON_LISTENERS_READY,function(){x(),m(),p(),o(null),k(),t.scrollHistory&&t.scrollHistory.getCurrentScroll()&&l(),c.$on(a.datagrid.events.ON_RENDER_AFTER_DATA_CHANGE,function(){w&&t.getContentHeight()&&t.getContentHeight()<t.getViewportHeight()&&t.scrollModel.removeTouchEvents()})}),c.$on(a.datagrid.events.ON_SCROLL_STOP,function(){n(),clearInterval(B),t.values.scroll<=0?B=setInterval(function(){d[0].scrollTop>.1?d[0].scrollTop*=.1:(d[0].scrollTop=0,clearInterval(B))},10):d[0].scrollTop=d[0].scrollHeight-d[0].offsetHeight})}function j(){function b(a,b){J=a.y,K=0,clearInterval(B),B=setInterval(function(){var c,e=window.getComputedStyle(d[0].children[0]);e?(c=parseInt(e.webkitTransform.match(/(\-?\d+)\)$/)[1],10),c!==J&&(K=c-J,J=c,c===b.maxScrollY&&(clearInterval(B),B=setTimeout(function(){clearTimeout(B),l(),a.scrollBy(0,5*K,500)},0)))):clearInterval(B)},10)}u=new IScroll(d[0],{bounce:!1,mouseWheel:!0,bindToWrapper:!0,click:!0}),u.on("scrollStart",function(){w&&(p(),b(v.iScroll,u))}),u.on("scrollEnd",function(){v||n();u.y<=u.maxScrollY&&l()}),c.$on(a.datagrid.events.ON_SCROLL_START,function(){var a=v||n();a.iScroll&&(a.iScroll.options.bounce=!1),!w&&a.iScroll.y>=0?k():w&&a.iScroll.enabled&&a.iScroll.disable()}),c.$on(a.datagrid.events.ON_SCROLL_STOP,function(){!w&&v.iScroll.y>=0&&k()}),c.$on(a.datagrid.events.AFTER_SCROLL_HISTORY_INIT_SCROLL,function(){v.scrollHistory&&v.scrollHistory.getCurrentScroll()&&(u.enable(),u.scrollTo(0,u.maxScrollY))}),x=c.$on(a.datagrid.events.ON_LISTENERS_READY,function(){x(),n(),m(),p(),x=c.$on(a.datagrid.events.ON_AFTER_RENDER,function(){v||n();x(),p(),k(),t.scrollHistory&&t.scrollHistory.getCurrentScroll()&&l()})})}function k(){C.log("enable doubleScroll disable scroll"),L&&!w?(!v||!v.iScroll||t.scrollHistory&&t.scrollHistory.getCurrentScroll()||(C.log(" scroll grid to 0"),v.iScroll.scrollTo(0,0),v.iScroll.disable()),u.enable(),t.getContentHeight()>t.getViewportHeight()&&u.scrollTo(0,0)):w||(d[0].scrollTop=0,s.scrollTop=0),w=!0}function l(){C.log("disable doubleScroll enable scroll"),L&&w?(u.scrollTo(0,u.maxScrollY),u.disable(),v.iScroll.enable(),v.iScroll.scrollBy(0,-1)):L||(d[0].scrollTop=d[0].scrollHeight-d[0].offsetHeight),w=!1}function m(){s||(s=d[0].querySelector(E))}function n(){for(var a=c.$$childHead;a;){if(a.datagrid)return t=a.datagrid,v=a.datagrid&&a.datagrid.scrollModel;a=a.$$nextSibling}return v}function o(a){if(C.log("onScroll"),m(),!s)throw new Error(E?'selector "'+E+'" did not select any objects':"double scroll requires a selector.");D.scrollTop+D.offsetHeight<D.scrollHeight?"hidden"!==s.style.overflowY&&(C.log(" target.overflowY = hidden"),s.style.overflowY="hidden"):"auto"!==s.style.overflowY&&(C.log(" target.overflowY = auto"),s.style.overflowY="auto")}function p(){var a=q(),b=d[0].offsetHeight;if(I!==a||z!==b){if(r(a))return I=a,z=b,!0}else!w&&s&&s.children[0]&&s.children[0].offsetHeight+F<b&&k();return!1}function q(){for(var a,c,e,f=d.children(),g=f.children(),h=0,i=g.length,j=0;i>h&&g[h]!==s&&!g[h].contains(s);)a=b.getComputedStyle(g[h]),H!==!1?(c=parseInt(a.paddingTop,10),e=parseInt(a.paddingBottom,10)):(c=0,e=0),j+=g[h].offsetHeight+c+e,h+=1;return G&&(F=j),j}function r(a){if(C.log("onSizeChange"),s){var b,c=angular.element(s).scope(),e=d.children(),f=d[0].offsetHeight;return b=a+f-F,s.style.height=f-F+"px",e[0].style.height=b+"px",c.datagrid.updateHeights(),L&&(u.refresh(),c.datagrid.scrollHistory&&!c.datagrid.scrollHistory.isComplete()&&u.scrollTo(0,u.maxScrollY)),!0}return m(),!1}var s,t,u,v,w,x,y,z,A,B,C=a.logWrapper("doubleScroll",{},"red",function(){a.util.apply(c.$emit,c,arguments)}),D=d[0],E=c.$eval(e.uxDoubleScroll),F=c.$eval(e.targetOffset)||0,G=c.$eval(e.dynamicOffset),H=c.$eval(e.targetPadding),I=0,J=0,K=0,L=f();C.resize=function(a){C.log("resize"),void 0!==a&&(d[0].style.height=a+"px"),p()},C.scrollToTop=function(){k()},C.scrollToBottom=function(){l()},c.$on("$destroy",function(){y(),clearTimeout(A),clearInterval(B),C.destroyLogger(),C=null,L?(u.destroy(),u=null):d[0].removeEventListener("scroll",o)}),g()}}}])}(this.ux=this.ux||{},function(){return this}());
|
¶ sourceMappingURL=ux-doubleScroll.min.js.map |
}(this.ux = this.ux || {}, function() {return this;}()));
|