|
17 | 17 | //Initial Parameters |
18 | 18 | params = params || {}; |
19 | 19 | params.margin = params.margin !== undefined && params.margin !== null ? params.margin : 10; |
| 20 | + params.galleryMargin = params.galleryMargin !== undefined && params.galleryMargin !== null ? params.galleryMargin : 17; // 17px is the largest native scrollbar width state of 2017 |
20 | 21 | params.width = params.width || undefined; //width of the whole gallery |
21 | 22 | params.mode = params.mode || 'default'; //default, bootstrap, flickr, small |
22 | 23 | params.jsSetup = params.jsSetup !== undefined && params.jsSetup !== null ? params.jsSetup : true; //if you are going to set the css variables for the elements in CSS |
|
38 | 39 | this.gallerify.renderAsyncImages = function(){ |
39 | 40 | setupChilds(_this, params.margin); |
40 | 41 | if(params.debounceLoad){ |
41 | | - _this.find("img").load(function(){ |
| 42 | + _this.find("img").on('load', function(){ |
42 | 43 | asyncImagesLoadedFinished(); |
43 | 44 | }); |
44 | 45 | }else{ |
45 | | - _this.find("img").load(function(){ |
| 46 | + _this.find("img").on('load', function(){ |
46 | 47 | renderGallery(_this, params); |
47 | 48 | }); |
48 | 49 | } |
|
111 | 112 | ) || //Checking if current row is a complete row |
112 | 113 | _params.lastRow == "fullwidth" //check if a non-complete row should be displayed with the full width |
113 | 114 | ){ |
114 | | - lastRowHeight = renderRow(jChildRows[jChildRows.length - 1], width, _params.margin, screenSettings.maxHeight); |
| 115 | + lastRowHeight = renderRow(jChildRows[jChildRows.length - 1], width, _params.margin, _params.galleryMargin, screenSettings.maxHeight); |
115 | 116 | }else{ |
116 | 117 | if(_params.lastRow === 'hidden' && imagesPerRow !== 1){ |
117 | 118 | hideRow(jChildren); // Don't render last row |
118 | 119 | }else{ // default / adjust |
119 | | - renderLastRow(jChildRows[jChildRows.length - 1], width, _params.margin, lastRowHeight); |
| 120 | + renderLastRow(jChildRows[jChildRows.length - 1], width, _params.margin, _params.galleryMargin, lastRowHeight); |
120 | 121 | } |
121 | 122 |
|
122 | 123 | } |
|
129 | 130 | } |
130 | 131 | } |
131 | 132 |
|
132 | | - function renderRow(jChildren, galleryWidth, margin, maxHeight){ |
| 133 | + function renderRow(jChildren, galleryWidth, margin, galleryMargin, maxHeight){ |
133 | 134 | resizeToSameHeight(jChildren, maxHeight); |
134 | | - return resizeToWidth(jChildren, galleryWidth, margin); //Returning height of the current row |
| 135 | + return resizeToWidth(jChildren, galleryWidth, margin, galleryMargin); //Returning height of the current row |
135 | 136 | } |
136 | 137 |
|
137 | | - function renderLastRow(jChildren, galleryWidth, margin, rowHeight){ |
| 138 | + function renderLastRow(jChildren, galleryWidth, margin, galleryMargin, rowHeight){ |
138 | 139 | rowHeight = resizeToSameHeight(jChildren, rowHeight); |
139 | 140 | var currentWidth = 0; |
140 | 141 | $(jChildren).each( function(){ currentWidth += $(this).width(); }); |
141 | 142 | if(currentWidth > galleryWidth){ |
142 | | - rowHeight = resizeToWidth(jChildren, galleryWidth, margin); |
| 143 | + rowHeight = resizeToWidth(jChildren, galleryWidth, margin, galleryMargin); |
143 | 144 | } |
144 | 145 | return rowHeight; |
145 | 146 | } |
|
156 | 157 | return jChildren[0].height(); //Returning height of the current row |
157 | 158 | } |
158 | 159 |
|
159 | | - function resizeToWidth(jChildren, rowWidth, margin){ |
| 160 | + function resizeToWidth(jChildren, rowWidth, margin, galleryMargin){ |
160 | 161 | var currentWidth = 0; |
161 | 162 | $(jChildren).each( function(){ currentWidth += $(this).width(); }); |
162 | 163 | var marginTotal = (jChildren.length * (margin) * 2); |
163 | 164 | // Adding 17 pixel of margin to the whole gallery because of some scrollbar issue |
164 | 165 | // TODO find workaround here |
165 | | - marginTotal += 17; |
| 166 | + marginTotal += galleryMargin; |
166 | 167 | var factor = (rowWidth - marginTotal) / currentWidth; |
167 | 168 | for (var i = 0; i < jChildren.length; i++){ |
168 | 169 | jChildren[i].css('width', jChildren[i].width() * factor); |
|
0 commit comments