Function canScrollHorizontally

  • Whether a scroll container can still scroll horizontally by dx (physical: dx > 0 = to the right) – for left-to-right and right-to-left containers alike.

    Parameters

    • element: {
          clientWidth: number;
          scrollLeft: number;
          scrollWidth: number;
      }

      a scroll container

      • clientWidth: number
      • scrollLeft: number
      • scrollWidth: number
    • dx: number

      physical delta (e.g. WheelEvent.deltaX)

    • rtl: boolean

      the container is right-to-left

    Returns boolean

    true if a scroll by dx would move the content

    Example

    host.addEventListener("wheel", e => {
    const takesIt = canScrollHorizontally(host, e.deltaX, getComputedStyle(host).direction === "rtl");
    console.info(takesIt ? "the element scrolls itself" : "pass it on");
    });

    Since

    1.1.98