javascript - 在桌面上向下滚动但不是在移动设备上向下滚动的三个 js 动画?

标签 javascript css animation three.js

我在文档正文中有一个三个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 );

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

可以在桌面上向下滚动 holder div 并调出更多文本,同时背景动画保持原位。

但是 holder div 在移动设备上没有触摸响应,因此不能向上滑动任何文本。

最佳答案

添加这些函数:

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

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

关于javascript - 在桌面上向下滚动但不是在移动设备上向下滚动的三个 js 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36464463/

相关文章:

javascript - HTML h1 标签在 javascript+css 动画上方无法正确显示

javascript - 是否可以在不使用 React 应用程序的情况下使用 React-Speech-Recognition?

javascript - 我想要一个粘性标题中的按钮在向下滚动时变成红色

javascript - 禁用 JavaScript 时的 Css 回退

html - 引用外部 CSS 不工作

html - animate.css:如何让 css 动画只在第一次运行?

javascript - xsl :call-template within a javascript function?

javascript - jquery弹出窗口实例重复问题

jquery - 日期选择器上一个和下一个日期超链接的宽度和高度

python - 使用 NetworkX 和 Matplotlib 促进网络增长