Skip to content

Commit

Permalink
Adjust gestures in iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-HNguyen committed Jul 26, 2024
1 parent 07d5e6a commit 9eb766c
Showing 1 changed file with 37 additions and 12 deletions.
49 changes: 37 additions & 12 deletions 3dwebclient/utils/MobileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

/**
*
*
* Controller for mobile devices
*/

Expand Down Expand Up @@ -54,6 +54,8 @@
this.setInfoboxFullscreen();
this.setToolboxFullscreen();
this.setSplashWindowFullscreen();

this.setGestures();
}

Object.defineProperties(MobileController.prototype, {
Expand Down Expand Up @@ -101,7 +103,7 @@

/**
* True if mobile browser is being used.
*
*
* @returns {Boolean}
*/
MobileController.prototype.isMobile = function () {
Expand Down Expand Up @@ -139,7 +141,7 @@

/**
* Set distance legend to display on the bottom right corner on mobile devices.
*
*
* @returns {undefined}
*/
MobileController.prototype.setDistanceLegend = function () {
Expand All @@ -159,7 +161,7 @@

/**
* Set loading indicator on mobile devices.
*
*
* @returns {undefined}
*/
MobileController.prototype.setLoadingIndicator = function () {
Expand All @@ -180,7 +182,7 @@

/**
* Hide credit logos and texts.
*
*
* @returns {undefined}
*/
MobileController.prototype.hideCredits = function () {
Expand All @@ -194,7 +196,7 @@

/**
* Hide navigation tools (compass + zooming).
*
*
* @returns {undefined}
*/
MobileController.prototype.hideNavigationDiv = function () {
Expand Down Expand Up @@ -231,7 +233,7 @@

/**
* Hide inspector that shows number of cached and loaded tiles.
*
*
* @returns {undefined}
*/
MobileController.prototype.hideInspector = function () {
Expand All @@ -256,7 +258,7 @@

/**
* Automatically hide toolbox/uiMenu when an infox is shown in fullscreen.
*
*
* @returns {undefined}
*/
MobileController.prototype.watchInfoboxVisibility = function () {
Expand Down Expand Up @@ -293,7 +295,7 @@

/**
* Set infobox containing thematic values to fullscreen on mobile devices.
*
*
* @returns {undefined}
*/
MobileController.prototype.setInfoboxFullscreen = function () {
Expand All @@ -310,7 +312,7 @@

/**
* Set toolbox to fullscreen on mobile devices.
*
*
* @returns {undefined}
*/
MobileController.prototype.setToolboxFullscreen = function () {
Expand Down Expand Up @@ -348,7 +350,6 @@
closeIgnoreButtons.classList.add("splashscreen-buttons-mobile");



// Simplify contents of the splash window
var mobileContentUrl = "splash/SplashWindow_Mobile.html";
var http = new XMLHttpRequest();
Expand All @@ -362,6 +363,30 @@
}
};

/**
* Set gesture events.
*
* @returns {undefined}
*/
MobileController.prototype.setGestures = function () {
var scope = this;

if (scope._isMobile) {
if (scope.getMobileOS() === "iOS") {
// Source: https://stackoverflow.com/questions/37808180/disable-viewport-zooming-ios-10-safari/50823326#50823326
window.addEventListener(
"touchmove",
function (event) {
if (event.scale !== 1) {
event.preventDefault();
}
},
{passive: false}
);
}
}
};

/**
* Determine the mobile operating system.
* This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'.
Expand Down Expand Up @@ -392,4 +417,4 @@
};

window.MobileController = MobileController;
})();
})();

0 comments on commit 9eb766c

Please sign in to comment.