Skip to content

Commit 3b460e5

Browse files
author
Christian
committed
Fixing issue related to the ripples effect
1 parent c83af28 commit 3b460e5

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

src/main/java/gwt/material/design/client/custom/MaterialWidget.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import com.google.gwt.user.client.ui.Widget;
2626

2727
public class MaterialWidget extends Composite{
28-
28+
2929
protected String waves = "";
3030
protected String color = "";
3131
protected String textColor = "";
@@ -37,7 +37,7 @@ public class MaterialWidget extends Composite{
3737
protected String tooltipDelay = "50";
3838
protected boolean disable;
3939
private String padding;
40-
40+
4141
public String getWaves() {
4242
return waves;
4343
}
@@ -74,14 +74,17 @@ public void setType(String type) {
7474
}
7575

7676
public void applyMaterialEffect() {
77-
77+
boolean applyWavesEffect = false;
7878
if(widget!=null){
7979
if(!isDisable()){
80-
if(!waves.isEmpty()) widget.getElement().addClassName("waves-effect waves-" + waves);
80+
if(!waves.isEmpty()) {
81+
applyWavesEffect = true;
82+
widget.getElement().addClassName("waves-effect waves-" + waves);
83+
}
8184
if(!color.isEmpty()) widget.getElement().addClassName(color);
8285
if(!textColor.isEmpty()) widget.getElement().addClassName(textColor + "-text");
8386
if(!align.isEmpty()) widget.getElement().addClassName(align + "-align");
84-
87+
8588
if(!tooltip.isEmpty()) getWidget().addStyleName("tooltipped");
8689
if(!tooltipLocation.isEmpty()) getWidget().getElement().setAttribute("data-position", tooltipLocation);
8790
if(!tooltipDelay.isEmpty()) getWidget().getElement().setAttribute("data-delay", tooltipDelay);
@@ -90,9 +93,10 @@ public void applyMaterialEffect() {
9093
widget.addStyleName("disabled");
9194
widget.getElement().addClassName("grey lighten-2 ");
9295
}
93-
96+
9497
}
9598
initToolTip();
99+
if (applyWavesEffect) initWaves();
96100
}
97101

98102
public Widget getWidget() {
@@ -111,11 +115,11 @@ public void setAlign(String align) {
111115
this.align = align;
112116
}
113117

114-
118+
115119
public String getTooltip() {
116120
return tooltip;
117121
}
118-
122+
119123
public void setTooltip(String tooltip) {
120124
this.tooltip = tooltip;
121125
applyMaterialEffect();
@@ -145,6 +149,15 @@ private native void initToolTip()/*-{
145149
});
146150
}-*/;
147151

152+
/**
153+
* As materialize.js does not provide a init method we are calling displayEffect
154+
* directly. If Materialize ever change this function name we must change it here
155+
* as well.
156+
*/
157+
private native void initWaves()/*-{
158+
$wnd.Waves.displayEffect();
159+
}-*/;
160+
148161
public boolean isDisable() {
149162
return disable;
150163
}
@@ -161,7 +174,7 @@ public void setPadding(String padding) {
161174
this.padding = padding;
162175
this.getElement().getStyle().setPadding(Double.parseDouble(padding), Unit.PCT);
163176
}
164-
165-
166-
177+
178+
179+
167180
}

0 commit comments

Comments
 (0)