【问题标题】:Divs over a three js animation scrolling down on desktop but not on mobile?在桌面上向下滚动但不在移动设备上的三个 js 动画上的 Divs?
【发布时间】:2016-07-27 15:26:09
【问题描述】:

我在文档正文中有一个三个 js 动画:

container = document.createElement( 'div' );
document.body.appendChild( container );

还有两个 div 层叠在顶部设置:

#holder {
  z-index: 1;
  position: absolute;
  top: 0px;
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
}

#sitearea {
  width: 1000px;
  margin: 0 auto;
}

也是一个媒体查询:

@media screen and (max-width: 1000px) {
  #sitearea {
    width: 100%;
  }
}

动画是交互式的:

document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false );

在桌面上,动画响应鼠标移动,而在移动设备上,它响应触摸。

可以在桌面上向下滚动持有人 div 并在背景动画保持原位的同时显示更多文本。

但持有人 div 在移动设备上没有触摸响应,因此无法向上滑动任何文本。

【问题讨论】:

    标签: javascript css animation three.js


    【解决方案1】:

    添加这些功能:

    function onDocumentTouchStart() {
      var theholder = document.getElementById("holder");
      theholder.addEventListener( 'touchstart', onDocumentTouchStart, false );
    }
    
    function onDocumentTouchMove() {
      var theholder = document.getElementById("holder");
      theholder.addEventListener( 'touchmove', onDocumentTouchMove, false );
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      相关资源
      最近更新 更多