Skip to content

Commit 86c6b06

Browse files
committed
Fixed issues on Pushpin - specially the bottom param.
Added java docs to pushpin component for better clarity.
1 parent 7ff1e8a commit 86c6b06

File tree

2 files changed

+47
-11
lines changed

2 files changed

+47
-11
lines changed

gwt-material/src/main/java/gwt/material/design/client/js/JsPushpinOptions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
public class JsPushpinOptions {
2828

2929
@JsProperty
30-
public double top;
30+
public Object top;
3131

3232
@JsProperty
33-
public double offset;
33+
public Object offset;
3434

3535
@JsProperty
36-
public double bottom;
36+
public Object bottom;
3737

3838
}

gwt-material/src/main/java/gwt/material/design/client/ui/MaterialPushpin.java

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*/
2020
package gwt.material.design.client.ui;
2121

22+
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.core.client.Scheduler;
2224
import com.google.gwt.user.client.ui.Widget;
2325
import gwt.material.design.client.js.JsPushpinOptions;
2426

@@ -40,16 +42,50 @@
4042
*/
4143
public class MaterialPushpin {
4244

43-
public static void apply(Widget widget, double offset) {
44-
apply(widget, 0, 0, offset);
45+
/**
46+
* A pushpinned element has 3 states. One above and below the scrolling threshold,
47+
* and the pinned state where the element becomes fixed.
48+
*
49+
* @param widget - Target widget to apply the pushpin feature
50+
* @param offset - The offset from the top the element will be fixed at. (Default: 0)
51+
*/
52+
public static void apply(Widget widget, Double offset) {
53+
apply(widget, null, null, offset);
4554
}
4655

47-
public static void apply(Widget widget, double top, double bottom, double offset) {
48-
JsPushpinOptions options = new JsPushpinOptions();
49-
options.top = top;
50-
options.offset = offset;
51-
options.bottom = bottom;
56+
/**
57+
* A pushpinned element has 3 states. One above and below the scrolling threshold,
58+
* and the pinned state where the element becomes fixed.
59+
*
60+
* @param widget - Target widget to apply the pushpin feature
61+
* @param top - The distance in pixels from the top of the page where the element becomes fixed. (Default: 0)
62+
* @param offset - The offset from the top the element will be fixed at. (Default: 0)
63+
*/
64+
public static void apply(Widget widget, Double top, Double offset) {
65+
apply(widget, top, null, offset);
66+
}
67+
68+
/**
69+
* A pushpinned element has 3 states. One above and below the scrolling threshold,
70+
* and the pinned state where the element becomes fixed.
71+
*
72+
* @param widget - Target widget to apply the pushpin feature
73+
* @param top - The distance in pixels from the top of the page where the element becomes fixed. (Default: 0)
74+
* @param bottom - The distance in pixels from the top of the page where the elements stops being fixed. (Default: Infinity)
75+
* @param offset - The offset from the top the element will be fixed at. (Default: 0)
76+
*/
77+
public static void apply(Widget widget, Double top, Double bottom, Double offset) {
78+
Scheduler.get().scheduleDeferred(() -> {
79+
JsPushpinOptions options = new JsPushpinOptions();
80+
options.top = (top != null) ? top : 0;
81+
options.offset = (offset != null) ? offset : 0;
82+
options.bottom = (bottom != null) ? bottom : "Infinity";
83+
84+
GWT.log(top + " : Top");
85+
GWT.log(offset + " : Offset");
86+
GWT.log(bottom + " : Bottom");
5287

53-
$(widget.getElement()).pushpin(options);
88+
$(widget.getElement()).pushpin(options);
89+
});
5490
}
5591
}

0 commit comments

Comments
 (0)