How to implement touch event in javascript that can be used as scroll on desktop?

Viewed 323

I have animation with ScrollMagic library and I am also using GSAP. This is description of animation on scroll in steps. Every number is one scroll:

  1. Add class overflow-hidden to body, to disable scrolling.
  2. Move credit-cards
  3. Move remove some images
  4. Start doing transform: translate(x,y) rotateZ(zdeg)
  5. Stop scrolling and make image that was translated sticky

So this works good with mouse on mousewheel event. The question is:

What is the best way to implement touch scroll with very same effect when user comes from iOS or Andorid. (When user comes to my website from android, iPhone, iPad etc.)

I know that there is touchmove event.

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 Answers
Related