diff --git a/angulargrid.js b/angulargrid.js index 068d563..5378271 100644 --- a/angulargrid.js +++ b/angulargrid.js @@ -112,7 +112,8 @@ scrollContainer: '@agScrollContainer', infiniteScroll: '&agInfiniteScroll', infiniteScrollDistance: '=agInfiniteScrollDistance', - infiniteScrollDelay: '=agInfiniteScrollDelay' + infiniteScrollDelay: '=agInfiniteScrollDelay', + reflowedCB: '&agReflowed' }, link: function(scope, element, attrs) { var domElm = element[0], @@ -531,6 +532,13 @@ //re enable infiniteScroll reEnableInfiniteScroll(); + + scope.reflowedCB({ + $event: { + id: scope.agId || null + } + }); + } }); }(reflowCount)); diff --git a/angulargrid.min.js b/angulargrid.min.js index ccc5f7c..8e1b87c 100644 --- a/angulargrid.min.js +++ b/angulargrid.min.js @@ -8,4 +8,4 @@ /* module to create pinterest like responsive masonry grid system for angular */ -!function(a,b){"undefined"!=typeof module&&module.exports?module.exports=b(require("angular"),a):"function"==typeof define&&define.amd?define(["angular"],function(c){return b(c,a)}):b(a.angular,a)}(this,function(a,b,c){"use strict";function i(a){return a.complete&&("undefined"==typeof a.naturalWidth||0!==a.naturalWidth)}function j(a){return Array.prototype.slice.call(a)}var d={gridWidth:300,gutterSize:10,gridNo:"auto",direction:"ltor",refreshOnImgLoad:!0,cssGrid:!1,performantScroll:!1,pageSize:"auto",scrollContainer:"body",infiniteScrollDelay:3e3,infiniteScrollDistance:100},e=a.element,f=function(a){return a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},g={visibility:"hidden",opacity:0,top:0,left:0,width:""},h=function(){var a=e(b);return function(b){return a[0]=b,a}}();return e(document.head).append(""),a.module("angularGrid",[]).directive("angularGrid",["$timeout","$window","$q","angularGridInstance",function(k,l,m,n){return{restrict:"A",scope:{model:"=angularGrid",dep_gridWidth:"=gridWidth",dep_gutterSize:"=gutterSize",dep_refreshOnImgLoad:"=refreshOnImgLoad",dep_direction:"=direction",dep_cssGrid:"=cssGrid",dep_options:"=angularGridOptions",dep_gridNo:"=gridNo",dep_agId:"@angularGridId",gridNo:"=agGridNo",gridWidth:"=agGridWidth",gutterSize:"=agGutterSize",refreshOnImgLoad:"=agRefreshOnImgLoad",direction:"=agDirection",cssGrid:"=agCssGrid",options:"=agOptions",agId:"@",pageSize:"=agPageSize",performantScroll:"=agPerformantScroll",scrollContainer:"@agScrollContainer",infiniteScroll:"&agInfiniteScroll",infiniteScrollDistance:"=agInfiniteScrollDistance",infiniteScrollDelay:"=agInfiniteScrollDelay"},link:function(o,p,q){function y(){x={},Object.keys(d).forEach(function(a){o[a]!==c?x[a]=o[a]:o["dep_"+a]!==c&&(x[a]=o["dep_"+a])}),x=a.extend({},d,x,o.options||o.dep_options),x.cssGrid&&(x.gutterSize=0),"auto"==x.pageSize&&(x.pageSize=b.offsetWidth>=768?2:3)}function A(a,b){b=b||document.body;var c=0,d=0;if(a.offsetParent)do c+=a.offsetLeft,d+=a.offsetTop,a=a.offsetParent;while(a&&a!=b);return{left:c,top:d}}function B(){var a=e(document.querySelector(x.scrollContainer)),b=a[0],c="body"===x.scrollContainer?s:a;return{height:c[0].innerHeight||c[0].offsetHeight,scrollHeight:b.scrollHeight,startFrom:A(r,b).top,$elm:c}}function C(a,b,c){z.pageInfo=[{from:0}];var d,e,f,g=x.pageSize,h=z.scrollContInfo.height,i=h*g,j=Math.ceil(b/i),k=0;for(k=0;kf){if(d.top>f)break}else z.pageInfo[k]||(z.pageInfo[k]={from:l}),z.pageInfo[k].to=l;z.pageInfo=z.pageInfo.map(function(a,b){var c=Math.max(b-1,0),d=Math.min(b+1,z.pageInfo.length-1);return{from:z.pageInfo[c].from,to:z.pageInfo[d].to}})}function D(a){var b,c,d,e;for(d=0,e=u.length;dz.scrollContInfo.startFrom+z.scrollContInfo.height*d&&(c=Math.floor((a-z.scrollContInfo.startFrom)/(z.scrollContInfo.height*d))),c!=z.lastPage){z.lastPage=c;var e=z.pageInfo[c];e&&(p.children().detach(),b=Array.prototype.slice.call(u,e.from,e.to+1),D(b),p.append(b))}}}function F(){clearTimeout(z.infiniteScrollTimeout),z.isLoading=!1}function G(a){if(!z.isLoading&&o.model.length){var b=z.scrollContInfo.scrollHeight,c=z.scrollContInfo.height;a>=b-c*(1+x.infiniteScrollDistance/100)&&(z.isLoading=!0,o.infiniteScroll(),z.infiniteScrollTimeout=setTimeout(F,x.infiniteScrollDelay))}}function H(){var a=this.scrollTop||this.scrollY;x.performantScroll&&E(a),o.infiniteScroll&&G(a)}function I(){var b,a=r.offsetWidth;if(x.cssGrid){b=e(u[0]).clone(),b.css(g).addClass("ag-no-transition ag-clone"),p.append(b);var c=b[0].offsetWidth;return b.remove(),{no:c?Math.floor((a+12)/c):0,width:c}}var d="auto"==x.gridNo?x.gridWidth:Math.floor(a/x.gridNo)-x.gutterSize,f="auto"==x.gridNo?Math.floor((a+x.gutterSize)/(d+x.gutterSize)):x.gridNo,h=(a+x.gutterSize)%(d+x.gutterSize);return d+=Math.floor(h/f),{no:f,width:d}}function J(b,c){var d=c.beforeLoad||a.noop,e=c.onLoad||a.noop,f=c.isLoaded||a.noop,g=c.onFullLoad||a.noop,h=c.ignoreCheck||a.noop,k=b.find("img"),l=[];j(k).forEach(function(a){a.src&&(d(a),i(a)||h(a)?f(a):l.push(m(function(b,c){a.onload=function(){e(a),b()},a.onerror=c})))}),l.length?m.all(l).then(g,g):setTimeout(function(){g()},0)}function K(){if(u&&u.length){v++;var f,b=I(),c=b.width,d=b.no;if(d){var i=[];for(f=0;f.ag-no-transition{-webkit-transition: none !important;transition: none !important;} .angular-grid{position : relative;} .angular-grid > *{opacity : 0} .angular-grid > .angular-grid-item{opacity : 1}"),o.module("angularGrid",[]).directive("angularGrid",["$timeout","$window","$q","angularGridInstance",function(c,f,g,u){return{restrict:"A",scope:{model:"=angularGrid",dep_gridWidth:"=gridWidth",dep_gutterSize:"=gutterSize",dep_refreshOnImgLoad:"=refreshOnImgLoad",dep_direction:"=direction",dep_cssGrid:"=cssGrid",dep_options:"=angularGridOptions",dep_gridNo:"=gridNo",dep_agId:"@angularGridId",gridNo:"=agGridNo",gridWidth:"=agGridWidth",gutterSize:"=agGutterSize",refreshOnImgLoad:"=agRefreshOnImgLoad",direction:"=agDirection",cssGrid:"=agCssGrid",options:"=agOptions",agId:"@",pageSize:"=agPageSize",performantScroll:"=agPerformantScroll",scrollContainer:"@agScrollContainer",infiniteScroll:"&agInfiniteScroll",infiniteScrollDistance:"=agInfiniteScrollDistance",infiniteScrollDelay:"=agInfiniteScrollDelay",reflowedCB:"&agReflowed"},link:function(h,p,m){function S(){H={},Object.keys(r).forEach(function(o){h[o]!==t?H[o]=h[o]:h["dep_"+o]!==t&&(H[o]=h["dep_"+o])}),(H=o.extend({},r,H,h.options||h.dep_options)).cssGrid&&(H.gutterSize=0),"auto"==H.pageSize&&(H.pageSize=n.offsetWidth>=768?2:3)}function v(o,n){n=n||document.body;var t=0,e=0;if(o.offsetParent)do{t+=o.offsetLeft,e+=o.offsetTop,o=o.offsetParent}while(o&&o!=n);return{left:t,top:e}}function I(){var o=a(document.querySelector(H.scrollContainer)),n=o[0],t="body"===H.scrollContainer?k:o;return{height:t[0].innerHeight||t[0].offsetHeight,scrollHeight:n.scrollHeight,startFrom:v(P,n).top,$elm:t}}function C(o,n,t){A.pageInfo=[{from:0}];var e,i,r,a=H.pageSize,l=A.scrollContInfo.height*a,s=Math.ceil(n/l),d=0;for(d=0;dr){if(e.top>r)break}else A.pageInfo[d]||(A.pageInfo[d]={from:c}),A.pageInfo[d].to=c;A.pageInfo=A.pageInfo.map(function(o,n){var t=Math.max(n-1,0),e=Math.min(n+1,A.pageInfo.length-1);return{from:A.pageInfo[t].from,to:A.pageInfo[e].to}})}function y(o){var n,t,e,i;for(e=0,i=N.length;eA.scrollContInfo.startFrom+A.scrollContInfo.height*e&&(t=Math.floor((o-A.scrollContInfo.startFrom)/(A.scrollContInfo.height*e))),t!=A.lastPage){A.lastPage=t;var i=A.pageInfo[t];i&&(p.children().detach(),y(n=Array.prototype.slice.call(N,i.from,i.to+1)),p.append(n))}}}function $(){clearTimeout(A.infiniteScrollTimeout),A.isLoading=!1}function z(o){!A.isLoading&&h.model.length&&o>=A.scrollContInfo.scrollHeight-A.scrollContInfo.height*(1+H.infiniteScrollDistance/100)&&(A.isLoading=!0,h.infiniteScroll(),A.infiniteScrollTimeout=setTimeout($,H.infiniteScrollDelay))}function L(){var o=this.scrollTop||this.scrollY;H.performantScroll&&w(o),h.infiniteScroll&&z(o)}function G(){var o,n=P.offsetWidth;if(H.cssGrid){(o=a(N[0]).clone()).css(s).addClass("ag-no-transition ag-clone"),p.append(o);var t=o[0].offsetWidth;return o.remove(),{no:t?Math.floor((n+12)/t):0,width:t}}var e="auto"==H.gridNo?H.gridWidth:Math.floor(n/H.gridNo)-H.gutterSize,i="auto"==H.gridNo?Math.floor((n+H.gutterSize)/(e+H.gutterSize)):H.gridNo,r=(n+H.gutterSize)%(e+H.gutterSize);return e+=Math.floor(r/i),{no:i,width:e}}function W(n,t){var r=t.beforeLoad||o.noop,a=t.onLoad||o.noop,l=t.isLoaded||o.noop,s=t.onFullLoad||o.noop,d=t.ignoreCheck||o.noop,c=[];i(n.find("img")).forEach(function(o){o.src&&(r(o),e(o)||d(o)?l(o):c.push(g(function(n,t){o.onload=function(){a(o),n()},o.onerror=t})))}),c.length?g.all(c).then(s,s):setTimeout(function(){s()},0)}function x(){if(N&&N.length){F++;var n,t=G(),e=t.width,r=t.no;if(r){var l=[];for(n=0;n