Skip to content

Commit

Permalink
Add option to enable/disable pinch & double-tap zoom
Browse files Browse the repository at this point in the history
Closes: #687
  • Loading branch information
AntumDeluge committed Mar 18, 2024
1 parent 22fa54a commit 8af5ae1
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ private void onInit() {
viewSettings.setLoadWithOverviewMode(true);
viewSettings.setUseWideViewPort(true);

// disable zoom
viewSettings.setSupportZoom(false);
viewSettings.setBuiltInZoomControls(false);
// zoom controls
viewSettings.setSupportZoom(true);
viewSettings.setBuiltInZoomControls(true);
viewSettings.setDisplayZoomControls(false);

// allow autoplay of music
Expand Down
5 changes: 0 additions & 5 deletions srcjs/stendhal.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
overflow: hidden;
}

/* disable double-tap zoom in browsers that support it */
html {
touch-action: pan-x pan-y; /* manipulation does not work in Chrome */
}

/* disable pull down refresh in browsers that support it */
html, body {
overscroll-behavior: none;
Expand Down
1 change: 1 addition & 0 deletions srcjs/stendhal.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ <h3></h3>
<label class="checksetting"><input type="checkbox" id="chk_activityindicator">Object activity indicator</label>
<label class="checksetting"><input type="checkbox" id="chk_floatchat">Floating chat panel</label>
<label class="checksetting"><input type="checkbox" id="chk_hidechat" class="experimental">Auto-hide chat panel</label>
<label class="checksetting"><input type="checkbox" id="chk_zoom">Touch zoom</label>
</div>
<div id="settings_panel2" class="verticalgroup vgroupcol">
<label class="checksetting"><input type="checkbox" id="chk_dblclick">Double-click items</label>
Expand Down
8 changes: 8 additions & 0 deletions srcjs/stendhal/ui/dialog/SettingsDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ export class SettingsDialog extends DialogContentComponent {
this.createCheckBox("chk_hidechat", "chat.autohide",
"Chat panel will be hidden after sending text", "Chat panel will remain on-screen");

// FIXME: are there unique properties for pinch & tap zooming?
this.createCheckBox("chk_zoom", "zoom.touch",
"Touch zooming enabled (may not work with all browsers)",
"Touch zooming disabled (may not work with all browsers)",
function() {
stendhal.session.update();
});


/* *** center panel *** */

Expand Down
3 changes: 2 additions & 1 deletion srcjs/stendhal/util/ConfigManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export class ConfigManager {
"window.settings": "20,20",
"window.shortcuts": "20,20",
"window.trade": "200,100",
"window.travel-log": "160,50"
"window.travel-log": "160,50",
"zoom.touch": "false"
};

/**
Expand Down
15 changes: 15 additions & 0 deletions srcjs/stendhal/util/SessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export class SessionManager {
}
this.set(key, value);
}

this.update();
}

/**
Expand Down Expand Up @@ -175,6 +177,19 @@ export class SessionManager {
return this.charname || "";
}

/**
* Syncs inteface with updated settings.
*/
update() {
if (stendhal.config.getBoolean("zoom.touch")) {
document.documentElement.style.removeProperty("touch-action");
} else {
// disable double-tap zoom in browsers that support it
// NOTE: "manipulation" does not work in Chrome
document.documentElement.style.setProperty("touch-action", "pan-x pan-y");
}
}

/**
* Detects if test client is being used based on data path.
*
Expand Down

0 comments on commit 8af5ae1

Please sign in to comment.