IOS 키보드 체크

const listener = () => {
  const MIN_KEYBOARD_HEIGHT = 300
  const isMobile = window.innerWidth < 768
  const isKeyboardOpen = isMobile && window.screen.height - MIN_KEYBOARD_HEIGHT > window.visualViewport.height

  document.documentElement.classList.toggle('show-keyboard', isKeyboardOpen)
}

window.visualViewport.addEventListener('resize', listener)

Published by Bathory

안녕하세요.

Leave a comment

댓글 남기기