Skip to content

Commit 3044797

Browse files
committed
WIP - ViewPortZoomHandler
1 parent 21384c4 commit 3044797

File tree

7 files changed

+114
-7
lines changed

7 files changed

+114
-7
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cache:
88
- $HOME/.m2
99
before_install:
1010
# install the gwt-material-jquery because it will depends on built in jquery
11-
- git clone -b release_2.7.0 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
11+
- git clone -b release_2.8.0 https://github.com/GwtMaterialDesign/gwt-material-jquery.git
1212
- cd gwt-material-jquery
1313
- mvn install -DskipTests=true -DdryRun=true
1414
- cd ..

.utility/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -ev
3-
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.7.0" ]; then
3+
if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "release_2.8.0" ]; then
44
echo "<settings><servers><server><id>ossrh</id><username>\${env.OSSRH_USER}</username><password>\${env.OSSRH_PASS}</password></server></servers></settings>" > ~/settings.xml
55
mvn deploy -DskipTests --settings ~/settings.xml
66
fi

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Support documentation can be found [here](https://github.com/GwtMaterialDesign/g
2020
We created <a href="http://gwtmaterialdesign.github.io/gwt-material-demo/apidocs" > Java Docs </a> for developers
2121

2222
## Maven
23-
### Current Version 2.7.0
23+
### Current Version 2.8.0
2424
```xml
2525
<dependency>
2626
<groupId>com.github.gwtmaterialdesign</groupId>
2727
<artifactId>gwt-material</artifactId>
28-
<version>2.7.0</version>
28+
<version>2.8.0</version>
2929
</dependency>
3030
```
3131
### Snapshot Version 2.8.0-SNAPSHOT

gwt-material/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<artifactId>gwt-material-parent</artifactId>
66
<groupId>com.github.gwtmaterialdesign</groupId>
7-
<version>2.7.0</version>
7+
<version>2.8.0-SNAPSHOT</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2023 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+
*/
20+
package gwt.material.design.client.base.viewport;
21+
22+
import com.google.gwt.user.client.Element;
23+
import com.google.gwt.user.client.ui.RootPanel;
24+
import gwt.material.design.client.ui.MaterialToast;
25+
import gwt.material.design.jscore.client.api.viewport.VisualViewport;
26+
27+
public class DefaultViewPortZoomHandler implements ViewPortZoomHandler {
28+
29+
protected int zoomBoundaryLevel;
30+
31+
public DefaultViewPortZoomHandler(int zoomBoundaryLevel) {
32+
this.zoomBoundaryLevel = zoomBoundaryLevel;
33+
}
34+
35+
@Override
36+
public void load() {
37+
gwt.material.design.jscore.client.api.Window.visualViewport.addEventListener("resize", e -> {
38+
checkZoomLevel();
39+
return true;
40+
});
41+
42+
gwt.material.design.jscore.client.api.Window.visualViewport.addEventListener("scroll", e -> {
43+
checkZoomLevel();
44+
return true;
45+
});
46+
}
47+
48+
@Override
49+
public void unload() {
50+
51+
}
52+
53+
protected void checkZoomLevel() {
54+
VisualViewport viewport = gwt.material.design.jscore.client.api.Window.visualViewport;
55+
double width = viewport.width;
56+
double clientWidth = gwt.material.design.jscore.client.api.Window.outerWidth;
57+
int currentZoomLevel = (int) ((clientWidth / width) * 100);
58+
Element element = RootPanel.get().getElement();
59+
if (currentZoomLevel >= zoomBoundaryLevel) {
60+
double excessZoom = currentZoomLevel - zoomBoundaryLevel; // 25
61+
double scale = ((zoomBoundaryLevel - excessZoom) / 100.0);
62+
MaterialToast.fireToast("Current Zoom Level : " + currentZoomLevel);
63+
MaterialToast.fireToast("Zoom Level Boundary : " + zoomBoundaryLevel);
64+
65+
// Standardized the page scale or zoom level.
66+
/**
67+
* transform: scale(0.5);
68+
* transform-origin: 0 0;
69+
* width: calc(100% + 100%);
70+
*/
71+
72+
element.getStyle().setProperty("transform", "scale(" + 0.5 + ")");
73+
element.getStyle().setProperty("transformOrigin", "0 0");
74+
element.getStyle().setProperty("width", "200%");
75+
} else {
76+
element.getStyle().setProperty("transform", "scale(" + 1 + ")");
77+
element.getStyle().setProperty("width", "100%");
78+
}
79+
}
80+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2023 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+
*/
20+
package gwt.material.design.client.base.viewport;
21+
22+
public interface ViewPortZoomHandler {
23+
24+
void load();
25+
26+
void unload();
27+
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.gwtmaterialdesign</groupId>
77
<artifactId>gwt-material-parent</artifactId>
8-
<version>2.7.0</version>
8+
<version>2.8.0-SNAPSHOT</version>
99
<packaging>pom</packaging>
1010
<modules>
1111
<module>gwt-material</module>
@@ -75,7 +75,7 @@
7575
<connection>scm:git:[email protected]:GwtMaterialDesign/gwt-material.git</connection>
7676
<developerConnection>scm:git:[email protected]:GwtMaterialDesign/gwt-material.git</developerConnection>
7777
<url>http://github.com/GwtMaterialDesign/gwt-material</url>
78-
<tag>v2.7.0</tag>
78+
<tag>v2.8.0</tag>
7979
</scm>
8080

8181
<licenses>

0 commit comments

Comments
 (0)