我想在用户向下滚动手机时显示全屏

问题描述

用户在移动设备上向下滚动时,我试图隐藏浏览器地址栏。 我知道API只能由用户手势启动,而touchend可以是用户手势。 所以我像这样添加了eventlistener,但它仍然给我一个错误。 无法在“元素”上执行“ requestFullscreen”:API只能通过用户手势启动。

 addEventListener('touchmove',onScroll,{passive: false});

  function onScroll(e) {
      e.preventDefault
      addEventListener('touchend',onTouchEnd);

  }

  function onTouchEnd(e) {
          e.preventDefault
          if (!window.document.fullscreenElement) {
              window.document.documentElement.requestFullscreen()
                  .catch(err => {console.log(err);});
          } else {
              window.document.exitFullscreen();
          }
  }

用户向下滚动时如何隐藏浏览器地址栏,而当用户在移动设备上向上滚动时如何显示呢?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)