class WebHelper { static IsMobileDevice(){ return unityInstance.SendMessage('WebGlController', 'IsMobileDevice_Callback', this.isMobileDevice()); } static isMobileDevice(){ let isIPad = false; let isIpadRatio = window.matchMedia("(max-width: 768px) and (min-aspect-ratio: 3/4)").matches; if (isIpadRatio) { isIPad = true } else { switch (navigator.platform){ case 'MacIntel': if (navigator.maxTouchPoints > 0) { isIPad = true; } break; case 'iPad': isIPad = true; break; } } console.log('is iPad:' + isIPad); let device = false; if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlnackBerry/i) || navigator.userAgent.match(/Widows Phone/i)) { device = true; } else { device = false; } console.log('device mobale:' + device); if (device || isIPad) return 1; else return 0; } // Получить текущую высоту визуального viewport (с учетом клавиатуры) static getVisualViewportHeight() { if (window.visualViewport) { return window.visualViewport.height; } return window.innerHeight; } // Проверить, открыта ли клавиатура (примерно) static isKeyboardOpen() { if (window.visualViewport) { const heightDiff = window.innerHeight - window.visualViewport.height; // Если разница больше 150px, считаем что клавиатура открыта return heightDiff > 150; } return false; } // Прокрутить элемент в видимую область при открытии клавиатуры static scrollIntoViewIfNeeded(element) { if (this.isKeyboardOpen() && element) { setTimeout(() => { element.scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 300); } } }