Skip to content

Commit 7a0327e

Browse files
committed
CircularProgress and Masonry Fixes
1 parent ccf4476 commit 7a0327e

File tree

7 files changed

+121
-47
lines changed

7 files changed

+121
-47
lines changed

src/main/java/gwt/material/design/addins/client/base/constants/AddinsCssName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public interface AddinsCssName {
108108
String OVERLAY_TAB = "overlay-tab";
109109
String MATERIAL_NOTE = "material-note";
110110
String CIRCULAR_PROGRESS = "circular-progress";
111+
String CIRCULAR_LABEL = "circular-label";
111112
String EMPTY_STATE = "empty-state";
112113
String TIMELINE = "timeline";
113114
String TIMELINE_CONTENT = "timeline-content";

src/main/java/gwt/material/design/addins/client/circularprogress/MaterialCircularProgress.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public MaterialCircularProgress() {
9292
protected void onLoad() {
9393
super.onLoad();
9494

95-
label.setSize(getSize());
95+
96+
label.setSize(getSize(), isResponsive());
9697
add(label);
9798

9899

src/main/java/gwt/material/design/addins/client/circularprogress/ui/CircularProgressLabel.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,35 @@
1919
*/
2020
package gwt.material.design.addins.client.circularprogress.ui;
2121

22-
import com.google.gwt.dom.client.Style;
22+
import gwt.material.design.addins.client.base.constants.AddinsCssName;
2323
import gwt.material.design.client.ui.html.Span;
2424

2525
public class CircularProgressLabel extends Span {
2626

27+
public CircularProgressLabel() {
28+
setInitialClasses(AddinsCssName.CIRCULAR_LABEL);
29+
}
30+
2731
@Override
2832
protected void onLoad() {
2933
super.onLoad();
3034
}
3135

32-
public void setSize(double size) {
33-
setWidth(size + "px");
34-
setHeight(size + "px");
35-
getElement().getStyle().setLineHeight(size, Style.Unit.PX);
36+
public void setSize(double size, boolean responsive) {
37+
String width = "";
38+
String height = "";
39+
String lineHeight = "";
40+
if (responsive) {
41+
width = "100%";
42+
height = "100%";
43+
lineHeight = "calc(50% - " + getElement().getStyle().getFontSize() + "px";
44+
} else {
45+
width = size + "px";
46+
height = size + "px";
47+
lineHeight = size + "px";
48+
}
49+
setWidth(width);
50+
setHeight(height);
51+
getElement().getStyle().setProperty("lineHeight", lineHeight);
3652
}
3753
}

src/main/resources/gwt/material/design/addins/client/circularprogress/resources/css/circleprogress.css

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,34 @@
22
position: relative;
33
}
44

5-
.circular-progress span:nth-child(2) {
5+
.circular-progress .circular-label {
66
position: absolute;
77
top: 0;
88
text-align: center;
99
left: 0px;
1010
width: 100%;
1111
}
1212

13+
.col.circular-progress .circular-label {
14+
left: 12px;
15+
}
16+
17+
/** Responsive **/
1318
.circular-progress.responsive canvas {
1419
max-width: 100%;
1520
min-width: 100%;
21+
max-height: 100%;
22+
min-height: 100%;
23+
height: auto !important;
1624
}
1725

18-
.col.circular-progress span:nth-child(2) {
19-
left: 12px;
20-
}
21-
22-
.col.circular-progress {
23-
padding: 0px;
26+
.circular-progress.responsive .circular-label {
27+
width: 100%;
28+
margin: auto;
29+
top: 0;
30+
left: 0;
31+
bottom: 0;
32+
right: 0;
33+
display: table;
34+
font-size: 30px;
2435
}
Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
.circular-progress{position:relative}.circular-progress span:nth-child(2){position:absolute;top:0;text-align:center;left:0;width:100%}.circular-progress.responsive canvas{max-width:100%;min-width:100%}.col.circular-progress span:nth-child(2){left:12px}.col.circular-progress{padding:0}
1+
.circular-progress {
2+
position: relative;
3+
}
4+
5+
.circular-progress .circular-label {
6+
position: absolute;
7+
top: 0;
8+
text-align: center;
9+
left: 0px;
10+
width: 100%;
11+
}
12+
13+
.col.circular-progress .circular-label {
14+
left: 12px;
15+
}
16+
17+
/** Responsive **/
18+
.circular-progress.responsive canvas {
19+
max-width: 100%;
20+
min-width: 100%;
21+
max-height: 100%;
22+
min-height: 100%;
23+
height: auto !important;
24+
}
25+
26+
.circular-progress.responsive .circular-label {
27+
width: 100%;
28+
margin: auto;
29+
top: 0;
30+
left: 0;
31+
bottom: 0;
32+
right: 0;
33+
display: table;
34+
font-size: 30px;
35+
}

src/main/resources/gwt/material/design/addins/client/masonry/resources/js/imageloaded.js

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*!
2-
* imagesLoaded PACKAGED v4.1.0
2+
* imagesLoaded PACKAGED v4.1.4
33
* JavaScript is all like "You images are done yet or what?"
44
* MIT License
55
*/
66

77
/**
8-
* EvEmitter v1.0.1
8+
* EvEmitter v1.1.0
99
* Lil' event emitter
1010
* MIT License
1111
*/
@@ -14,7 +14,7 @@
1414

1515
( function( global, factory ) {
1616
// universal module definition
17-
/* jshint strict: false */ /* globals define, module */
17+
/* jshint strict: false */ /* globals define, module, window */
1818
if ( typeof define == 'function' && define.amd ) {
1919
// AMD - RequireJS
2020
define( 'ev-emitter/ev-emitter',factory );
@@ -26,7 +26,7 @@
2626
global.EvEmitter = factory();
2727
}
2828

29-
}( this, function() {
29+
}( typeof window != 'undefined' ? window : this, function() {
3030

3131

3232

@@ -59,8 +59,8 @@
5959
// set once flag
6060
// set onceEvents hash
6161
var onceEvents = this._onceEvents = this._onceEvents || {};
62-
// set onceListeners array
63-
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || [];
62+
// set onceListeners object
63+
var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
6464
// set flag
6565
onceListeners[ listener ] = true;
6666

@@ -85,13 +85,14 @@
8585
if ( !listeners || !listeners.length ) {
8686
return;
8787
}
88-
var i = 0;
89-
var listener = listeners[i];
88+
// copy over to avoid interference if .off() in listener
89+
listeners = listeners.slice(0);
9090
args = args || [];
9191
// once stuff
9292
var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
9393

94-
while ( listener ) {
94+
for ( var i=0; i < listeners.length; i++ ) {
95+
var listener = listeners[i]
9596
var isOnce = onceListeners && onceListeners[ listener ];
9697
if ( isOnce ) {
9798
// remove listener
@@ -102,20 +103,22 @@
102103
}
103104
// trigger listener
104105
listener.apply( this, args );
105-
// get next listener
106-
i += isOnce ? 0 : 1;
107-
listener = listeners[i];
108106
}
109107

110108
return this;
111109
};
112110

111+
proto.allOff = function() {
112+
delete this._events;
113+
delete this._onceEvents;
114+
};
115+
113116
return EvEmitter;
114117

115118
}));
116119

117120
/*!
118-
* imagesLoaded v4.1.0
121+
* imagesLoaded v4.1.4
119122
* JavaScript is all like "You images are done yet or what?"
120123
* MIT License
121124
*/
@@ -146,7 +149,7 @@
146149
);
147150
}
148151

149-
})( window,
152+
})( typeof window !== 'undefined' ? window : this,
150153

151154
// -------------------------- factory -------------------------- //
152155

@@ -167,22 +170,23 @@
167170
return a;
168171
}
169172

173+
var arraySlice = Array.prototype.slice;
174+
170175
// turn element or nodeList into an array
171176
function makeArray( obj ) {
172-
var ary = [];
173177
if ( Array.isArray( obj ) ) {
174178
// use object if already an array
175-
ary = obj;
176-
} else if ( typeof obj.length == 'number' ) {
179+
return obj;
180+
}
181+
182+
var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
183+
if ( isArrayLike ) {
177184
// convert nodeList to array
178-
for ( var i=0; i < obj.length; i++ ) {
179-
ary.push( obj[i] );
180-
}
181-
} else {
182-
// array of single index
183-
ary.push( obj );
185+
return arraySlice.call( obj );
184186
}
185-
return ary;
187+
188+
// array of single index
189+
return [ obj ];
186190
}
187191

188192
// -------------------------- imagesLoaded -------------------------- //
@@ -198,13 +202,19 @@
198202
return new ImagesLoaded( elem, options, onAlways );
199203
}
200204
// use elem as selector string
205+
var queryElem = elem;
201206
if ( typeof elem == 'string' ) {
202-
elem = document.querySelectorAll( elem );
207+
queryElem = document.querySelectorAll( elem );
208+
}
209+
// bail if bad element
210+
if ( !queryElem ) {
211+
console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
212+
return;
203213
}
204214

205-
this.elements = makeArray( elem );
215+
this.elements = makeArray( queryElem );
206216
this.options = extend( {}, this.options );
207-
217+
// shift arguments if no options set
208218
if ( typeof options == 'function' ) {
209219
onAlways = options;
210220
} else {
@@ -223,9 +233,7 @@
223233
}
224234

225235
// HACK check async to allow time to bind listeners
226-
setTimeout( function() {
227-
this.check();
228-
}.bind( this ));
236+
setTimeout( this.check.bind( this ) );
229237
}
230238

231239
ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
@@ -393,7 +401,9 @@
393401
};
394402

395403
LoadingImage.prototype.getIsImageComplete = function() {
396-
return this.img.complete && this.img.naturalWidth !== undefined;
404+
// check for non-zero, non-undefined naturalWidth
405+
// fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
406+
return this.img.complete && this.img.naturalWidth;
397407
};
398408

399409
LoadingImage.prototype.confirm = function( isLoaded, message ) {
@@ -484,3 +494,4 @@
484494
return ImagesLoaded;
485495

486496
});
497+

src/main/resources/gwt/material/design/addins/client/masonry/resources/js/imageloaded.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)