如何在可在桌面上用作滚动的JavaScript中实现触摸事件?

时间:2019-06-13 12:43:34

标签: javascript touch-event dom-events

我使用ScrollMagic库制作了动画,我也在使用GSAP。这是逐步滚动动画的描述。每个数字都是一卷:

  1. 向主体添加溢出隐藏类,以禁用滚动。
  2. 移动信用卡
  3. 移动删除一些图像
  4. 开始进行变换:translate(x,y)rotationZ(zdeg)
  5. 停止滚动并使图像平移

因此,这与鼠标在mousewheel事件上的效果很好。问题是:

当用户来自iOS或Andorid时,实现具有相同效果的触摸滚动的最佳方法是什么? (当用户从​​android,iPhone,iPad等访问我的网站时)

我知道有touchmove事件。

var image = document.getElementById('image-phone');
if(step == 1){
   //do first step
}...

//mousewheel event
window.addEventListener('mousewheel', function (e) {
  //this is implemented
});
//touchnmove event
window.addEventListener('touchmove', function (e) {
  //should I use this event
});

0 个答案:

没有答案