Skip to content

Commit cd53417

Browse files
committed
Added Cutout Max Height.
1 parent b1069f9 commit cd53417

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

src/main/java/gwt/material/design/addins/client/cutout/CutoutConfig.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class CutoutConfig {
2424
protected boolean absolute;
2525
protected int addedOffsetTop;
2626
protected int width;
27+
protected int maxHeight = 0;
28+
protected int maxWidth = 0;
2729

2830
public CutoutConfig() {
2931
}
@@ -41,23 +43,44 @@ public int getWidth() {
4143
return width;
4244
}
4345

44-
public void setWidth(int width) {
46+
public <M extends CutoutConfig> M setWidth(int width) {
4547
this.width = width;
48+
return (M) this;
4649
}
4750

4851
public boolean isAbsolute() {
4952
return absolute;
5053
}
5154

52-
public void setAbsolute(boolean absolute) {
55+
public <M extends CutoutConfig> M setAbsolute(boolean absolute) {
5356
this.absolute = absolute;
57+
return (M) this;
5458
}
5559

5660
public int getAddedOffsetTop() {
5761
return addedOffsetTop;
5862
}
5963

60-
public void setAddedOffsetTop(int addedOffsetTop) {
64+
public <M extends CutoutConfig> M setAddedOffsetTop(int addedOffsetTop) {
6165
this.addedOffsetTop = addedOffsetTop;
66+
return (M) this;
67+
}
68+
69+
public int getMaxHeight() {
70+
return maxHeight;
71+
}
72+
73+
public <M extends CutoutConfig> M setMaxHeight(int maxHeight) {
74+
this.maxHeight = maxHeight;
75+
return (M) this;
76+
}
77+
78+
public int getMaxWidth() {
79+
return maxWidth;
80+
}
81+
82+
public <M extends CutoutConfig> M setMaxWidth(int maxWidth) {
83+
this.maxWidth = maxWidth;
84+
return (M) this;
6285
}
6386
}

src/main/java/gwt/material/design/addins/client/cutout/MaterialCutOut.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ protected void setupCutOutPosition(Element cutOut, Element relativeTo, int paddi
389389
boolean absolute = config != null && config.isAbsolute();
390390
int addedOffsetTop = config != null ? config.getAddedOffsetTop() : 0;
391391
int overrideWidth = config != null ? config.getWidth() : 0;
392+
int maxHeight = config != null ? config.getMaxHeight() : 0;
393+
int maxWidth = config != null ? config.getMaxWidth() : 0;
392394
float top = (absolute ? relativeTo.getAbsoluteTop() : relativeTo.getOffsetTop()) - (Math.max($("html").scrollTop(), $("body").scrollTop()));
393395
top = top + addedOffsetTop;
394396

@@ -414,7 +416,9 @@ protected void setupCutOutPosition(Element cutOut, Element relativeTo, int paddi
414416
top -= padding;
415417
left -= padding;
416418
width += padding * 2;
419+
width = maxWidth > 0 ? maxWidth : width;
417420
height += padding * 2;
421+
height = maxHeight > 0 ? maxHeight : height;
418422

419423
$(cutOut).css("top", top + "px");
420424
$(cutOut).css("left", left + "px");

src/main/java/gwt/material/design/incubator/client/viewer/js/ViewerMethod.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2022 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
120
package gwt.material.design.incubator.client.viewer.js;
221

322
import jsinterop.annotations.JsMethod;

0 commit comments

Comments
 (0)