Capítulo 361 de 411

Chapter 361: ScrollTrigger.isTouch

Core Idea

A way to discern the touch capabilities of the current device - 0 is mouse/pointer only (no touch), 1 is touch-only, 2 accommodates both.

Key Concepts

  • 0: no touch (pointer/mouse only)
  • 1: touch-only device (like a phone)
  • 2: device can accept touch input and mouse/pointer (like Windows tablets)

Code Examples

if (ScrollTrigger.isTouch) {
  // any touch-capable device...
}

// or get more specific:
if (ScrollTrigger.isTouch === 1) {
  // touch-only device
}
  • What it demonstrates: typical usage of ScrollTrigger.isTouch in a GSAP animation.

Key Takeaways

  1. 0 — no touch (pointer/mouse only)
  2. 1 — touch-only device (like a phone)
  3. 2 — device can accept touch input and mouse/pointer (like Windows tablets)