Disable Pinch Zoom on iOS (#1369)
This commit is contained in:
parent
af8248dcf2
commit
66b8a2803c
@ -27,6 +27,7 @@ import useShowTransition from '../../hooks/useShowTransition';
|
|||||||
import useBackgroundMode from '../../hooks/useBackgroundMode';
|
import useBackgroundMode from '../../hooks/useBackgroundMode';
|
||||||
import useBeforeUnload from '../../hooks/useBeforeUnload';
|
import useBeforeUnload from '../../hooks/useBeforeUnload';
|
||||||
import useOnChange from '../../hooks/useOnChange';
|
import useOnChange from '../../hooks/useOnChange';
|
||||||
|
import usePreventIosPinchZoom from '../../hooks/usePreventIosPinchZoom';
|
||||||
import { processDeepLink } from '../../util/deeplink';
|
import { processDeepLink } from '../../util/deeplink';
|
||||||
import { LOCATION_HASH } from '../../hooks/useHistoryBack';
|
import { LOCATION_HASH } from '../../hooks/useHistoryBack';
|
||||||
|
|
||||||
@ -222,6 +223,8 @@ const Main: FC<StateProps & DispatchProps> = ({
|
|||||||
useBackgroundMode(handleBlur, handleFocus);
|
useBackgroundMode(handleBlur, handleFocus);
|
||||||
useBeforeUnload(handleBlur);
|
useBeforeUnload(handleBlur);
|
||||||
|
|
||||||
|
usePreventIosPinchZoom(isMediaViewerOpen);
|
||||||
|
|
||||||
function stopEvent(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
function stopEvent(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|||||||
21
src/hooks/usePreventIosPinchZoom.ts
Normal file
21
src/hooks/usePreventIosPinchZoom.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { useEffect } from '../lib/teact/teact';
|
||||||
|
import { IS_IOS } from '../util/environment';
|
||||||
|
|
||||||
|
export default function usePreventIosPinchZoom(isDisabled = false) {
|
||||||
|
// Disable viewport zooming on iOS Safari
|
||||||
|
useEffect(() => {
|
||||||
|
if (!IS_IOS || isDisabled) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('gesturestart', preventEvent);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener('gesturestart', preventEvent);
|
||||||
|
};
|
||||||
|
}, [isDisabled]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function preventEvent(e: Event) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-title" content="Telegram WebZ">
|
<meta name="apple-mobile-web-app-title" content="Telegram WebZ">
|
||||||
<meta name="application-name" content="Telegram WebZ">
|
<meta name="application-name" content="Telegram WebZ">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user