UMD Web Utilities Library
    Preparing search index...

    Function setupSwipeDetection

    • Creates touch swipe event detection for mobile interactions

      Sets up touch event listeners to detect horizontal swipes with configurable threshold and timing constraints. Useful for mobile carousels, image galleries, etc.

      Parameters

      • container: { callback: (swipedRight: boolean) => void; container: HTMLElement }

        The element to attach swipe detection to

      Returns void

      const carousel = document.querySelector('.carousel');
      setupSwipeDetection({
      container: carousel,
      callback: (swipedRight) => {
      if (swipedRight) {
      // Swipe right - go to previous slide
      showPreviousSlide();
      } else {
      // Swipe left - go to next slide
      showNextSlide();
      }
      }
      });